I have a CSV file with ID, X, Y, NAME and ZoomLabel. I have been successful with putting the Point Feature on the map.
Now I am trying to annotate the locations with the NAME field.
I used the following code and uploaded the CSV file, yet the annotation does not appear, what feature/command should I use. This is the code which I'm trying to run for getting the text on the map?
// Load the CSV file as a table
var table = ee.FeatureCollection('users/yourUsername/path/to/test.csv');
// Define a visualization style for the points (red color)
var pointStyle = {
color: 'FF0000', // Red color
pointSize: 5,
width: 1,
};
// Add the points to the map with the specified style
Map.addLayer(table, pointStyle, 'Points');
// Define a function to create text annotations from the NAME column
function addTextAnnotations(feature) {
// Extract the NAME property
var name = ee.String(feature.get('NAME'));
// Create a text annotation
var annotation = ee.Feature(feature.geometry()).set('text', name);
return annotation;
}
// Map the text annotations over the feature collection
var textAnnotations = table.map(addTextAnnotations);
// Create a text visualization style
var textStyle = {
fontSize: 12,
color: '000000', // Black color
};
// Add the text annotations to the map with the specified style
Map.addLayer(textAnnotations.style(textStyle), {}, 'Annotations');
// Center the map on the points
Map.centerObject(table, 10); // You can adjust the zoom level (10 in this case) to your preference