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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Google Maps own marker image

Started by Matt 9 years ago · 2 replies · 1156 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 Jerry Hunt, 4 days ago
2 74 6 hours ago
General · by pamtbaau, 12 hours ago
1 47 11 hours ago
General · by Andy Miller, 24 hours ago
0 44 24 hours ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 39 5 days ago