Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Stroke Color of Marker Icon

I am using for a Google Maps Marker (V3) the icon in the following way:

var marker = new google.maps.Marker({
    id: "theId",
    icon: {
        path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
        strokeColor: "green"
    },
    map: map,
    title: "theTitle",
    position: someLatitudeLongitude
});

Now after creating this marker I like to change the color run-time with a color panel. Now this works perfectly for a polyline or polygon, but for the marker not quite well: it is changed but not real-time updated.

Code:

selectedShape.icon.strokeColor = color; 

PROBLEM: Does not show color change on map. Only after saving and reloading the map, the correct color is shown.

For a polygon I use:

selectedShape.set('strokeColor', color);

This works fine.

So is there a set like operator for the marker or a partial refresh?

Thanks for any help.

Best regards,

Evert Wiesenekker

like image 297
Stackbever Avatar asked Aug 29 '13 13:08

Stackbever


1 Answers

I would bind on an event where the color changes, then call marker.setIcon(icon_options) on the marker to pass in the new values.

like image 92
Cole Pilegard Avatar answered Oct 03 '22 21:10

Cole Pilegard