Google API multiple markers with different colours depending on a class

后端 未结 1 1199
礼貌的吻别
礼貌的吻别 2020-12-22 11:52

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 o

相关标签:
1条回答
  • 2020-12-22 12:18

    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?

    0 讨论(0)
提交回复
热议问题