how to change the marker image in google maps [duplicate]

删除回忆录丶 提交于 2019-12-25 20:02:54

问题


i have 20 markers from which i want to show 10 markers with similar marker and with similar label ("A") , and other 10 i want to show with different marker image and different label ("B") . im getting all the marker with same image and same label

js fiddle https://jsfiddle.net/9yq8y1p2/4/

var initMap =    function () {
    var labels = '0123456789';
    var labelIndex = 0;
    var myLatLng = { lat: 17.446507, lng: 78.383033, deviceId: 'a' };
    var citymap = {
         hyderabad: {
              center: { lat: 17.446507, lng: 78.383033 },
              population: 5000
         }
    };
    var map = new google.maps.Map(document.getElementById('map'), {
         zoom: 18,
         center: myLatLng,
    });
}

回答1:


      var marker = new google.maps.Marker({
                        position: location,
                        icon: condition ? image_1 :image_2,
                        map: map
                    });

You can mention the condition for which you want image_1 as marker.



来源:https://stackoverflow.com/questions/44341194/how-to-change-the-marker-image-in-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!