Skip to content Skip to sidebar Skip to footer

Google Api Multiple Markers With Different Colours Depending On A Class

So I have this code below the markers are created by a CMS system using the Postal code and City. Everything is working ok but what I am trying to do is change the colour of each

Solution 1:

you can create 1 array of type (restaurants,hotels) or set default value of validate

and try this code:

var marker_new = new Array();
var url = "";
if(a == "hotels"){
   url = "http://exampl.com/yellow.png";   
}else{
   url = "http://exampl.com/green.png"
}
marker_new[i] = google.maps.Marker({
                                 icon: _url;
                                 position: place.geometry.location,
                                 map: map
                               });

How to use

    marker_new[i] = new google.maps.Marker({
      position: place.geometry.location,
      map: map
    });
    iw = new google.maps.InfoWindow({
      content: getIWContent(place)
    });
    iw.open(map, marker_new[i]);     

how to use

          marker_new[i] = new google.maps.Marker({
            position: results[i].geometry.location,
            animation: google.maps.Animation.DROP
          });
          google.maps.event.addListener(marker_new[i], 'click', getDetails(results[i], i));

or read more in: How can I modify the markers?

Post a Comment for "Google Api Multiple Markers With Different Colours Depending On A Class"