0

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

1 Answer 1

0

style() doesn't do text. Your only option is the text module from gena. See this previous question:

Google Earth Engine - Add text label at lat/lon location?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.