Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Google Maps own marker image

Started by Matt 9 years ago · 2 replies · 1499 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 jeremycherfas, 4 days ago
3 95 2 hours ago
General · by Old Man Umby, 2 days ago
1 60 2 days ago
General · by Sebastian, 4 days ago
1 81 4 days ago
General · by Andy Miller, 2 weeks ago
0 216 2 weeks ago
General · by ready-4-IT, 6 months ago
1 716 3 weeks ago