I want to color some geometry using API, but I found some of the geometry didn’t work like what it is on the cloud style editing webpage. For exameple, below I want to color the poi.emergency, but it just color the whole map instead of color the selected geometry.
function initMap() {
// Create a new StyledMapType object, passing it an array of styles,
// and the name to be displayed on the map type control.
const styledMapType = new google.maps.StyledMapType(
[
{
"featureType": "administrative",
"elementType": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "land",
"elementType": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
featureType: "poi.park",
elementType: "geometry.fill",
stylers: [{ color: "#a5b076" }],
},
{
featureType: "poi.emergency",
elementType: "geometry.fill",
stylers: [{color: "#00bfff"}]
},
{ name: "LandUse" },
]
);
// Create a map object, and include the MapTypeId to add
// to the map type control.
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 55.647, lng: 37.581 },
zoom: 13,
//mapId: "38041c807200bb37",
mapTypeControlOptions: {
mapTypeIds: [],
},
});
//Associate the styled map with the MapTypeId and set it to display.
map.mapTypes.set("LandUse", styledMapType);
map.setMapTypeId("LandUse");
}
window.initMap = initMap;
see if you encouter the same case….