How do i change the icon of a marker on google maps when I mouseover the text in a div? I managed to change the marker icon onmouseover the marker in the map itself using
google.maps.event.addListener(marker1, "mouseover", function(event) {
this.setIcon("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=1|ffffff|c41200");
}
EDIT:
Here is what I have now:
function initialize(){
....
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(1.288693,103.846733),
map: map,
icon: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=1|c41200|ffffff"
});
....
}
function changeMarker(marker) {
alert(marker);
}
and
<div id="searchresult" onmouseover="changeMarker(marker1)">
I’m using Chrome. In the console, onmouseover the div I get the error “Uncaught ReferenceError: marker1 is not defined”
Add a onmouseover property to the div. Let’s say it was called changeMarker.
Your div could then look like:
I would recommend however caching the MarkerImage (since it seems pretty static) so that Google doesn’t need to keep regenerating the graph image.
You can set other properties of the image. See the documentation