Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Google Maps own marker image

Started by Matt 9 years ago · 2 replies · 1333 views
9 years ago

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

TXT
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?

9 years ago

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
9 years ago

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

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?

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 2 days ago
0 70 2 days ago
General · by Veehem, 3 days ago
0 111 3 days ago
General · by milkboy, 4 days ago
0 113 4 days ago
General · by ian russell, 2 weeks ago
2 205 1 week ago
General · by pamtbaau, 1 month ago
2 462 2 weeks ago