I am currently working on a project using Vue2 with version 3.54 of Google Maps, which is necessary for the advancedMarkers feature.
https://maps.googleapis.com/maps/api/js?key=${this.mapKey}&callback=isMapLoad&libraries=marker&v=3.54
I have gone through all the documentation on styling maps and have successfully styled maps in previous versions. However, I am facing difficulty in implementing it now.
I attempted to set a style during initialization:
this.map = new google.maps.Map(document.getElementById('map'), {
mapId: 'GMAP_ID',
language: this.$i18n.locale,
center: this.defaultCoords,
zoom: this.zoom,
styles: [
{
featureType: 'water',
elementType: 'all',
stylers: [
{
color: '#f40000',
},
{
visibility: 'on',
},
],
}
]
})
And also tried setting it after initialization:
const styledMapType = new google.maps.StyledMapType(
[
{
featureType: 'water',
elementType: 'all',
stylers: [
{
color: '#f40000',
},
{
visibility: 'on',
},
],
}
]
)
this.map.mapTypes.set('styled_map', styledMapType)
this.map.setMapTypeId('styled_map')
// Added libraries maps to script URL to enable StyledMapType
Despite not receiving any errors, no changes were reflected in both cases. What else can I try?
UPDATE
A functional example showcasing the issue can be found here: https://jsfiddle.net/981w4zxb/1/
If you remove the mapId
as shown in the example, the style is applied, but the markers cease to function. On the other hand, adding the mapid
displays advanced markers but does not apply the styles
.
The goal is to incorporate both - utilizing advanced markers along with legacy styles without reliance on the cloud service.