I have a polygon layer geojson that show the states of the US. I use this layer on a google maps (using the google maps js api).
I can get the polygons to display, but I want to set labels on each state. How do I add the labels to the state?
here’s my code:
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: latitude, lng: longitude},
zoom: 13
});
map.addListener("zoom_changed", () => {
if (map.getZoom() < 8) {
console.log(map.getZoom() + " Get States")
map.data.forEach(function(feature) {
map.data.remove(feature);
});
map.data.loadGeoJson(
"data/states.json"
);
}
else {
console.log(map.getZoom() + " Get Counties")
map.data.forEach(function(feature) {
map.data.remove(feature);
});
map.data.loadGeoJson(
"data/counties.json"
);
}
});