Google Maps own marker image

I’m wondering is there any way to add custom marker image to my .js file? For exampe I create custom field in my admin area to upload marker image. Now I want to use it in my .js file

var mapMarker = new google.maps.Marker({
    position: new google.maps.LatLng(x, y),
    map: new google.maps.Map(mapElement, mapOptions),
    icon: 'MY ICON HERE', <- here I want to add my icon
    title: 'Title'
});

How can I do it?

Just put your marker in the images folder inside the theme folder and then set this:

icon:window.location.protocol+"//"+window.location.host+"//user/themes/mytheme/images/mymarker.png"

1 Like

Thank you! I added this. Now I have error like this
GET http://localhost//user/themes/hlg/images/marker.png not found
I’m on localhost, inside GRAV folder so path should be
window.location.protocol+“//”+window.location.host+“/GRAV/user/themes/hlg/images/marker.png”,
but what I want to move my entire dir into another server etc? How can I add relative path? When I move my dir to GRAV2 for example my path should be /GRAV2/user etc. How to do it automatically?