jeffreykemp / jk64-plugin-reportmap

Report Google Map APEX Plugin
https://jeffreykemp.github.io/jk64-plugin-reportmap/
MIT License
42 stars 16 forks source link

Place marker with custom icon #157

Closed gabriellangon closed 1 year ago

gabriellangon commented 2 years ago

Hi, How can I place marker on a map with a custom icon using the plugin API ? gotoPosByString API or Plugin Action Place Marker doesn't offer this possibility.

Is there a possibility to change the default red marker icon?

Thanks for your help.

jeffreykemp commented 2 years ago

Great question - unfortunately the plugin doesn't currently support customising the user pin declaratively. I'll keep this issue open as an enhancement request.

For now you can do this programmatically using JavaScript, e.g.:

var mymap = $("#map_mymap").reportmap("instance").map,
    mypos = new google.maps.LatLng(-31.82531,115.84366),
    myicon = 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/'
        + 'spotlight-waypoint-blue.png'
        + '&scale=2.0';

var mypin = new google.maps.Marker({
    map       : mymap,
    position  : mypos,
    title     : "Hello world",
    icon      : myicon
});

You will need to set the Static ID on your map region (e.g. "xyz"), then refer to $("#map_xyz") in the first line.

gabriellangon commented 2 years ago

The code works for me. Thanks for you answer !