Using Google Maps v3, PHP and Json to plot markers

前端 未结 1 751
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-03 16:26

I am creating a map using the new(ish) v3 of the Google Maps API

I have managed to get a map displaying using code as below:

var myLatlng = new google.ma         


        
1条回答
  •  时光说笑
    2021-02-03 16:51

    Well I think I have solved it, however if it is a stupid way of doing it please leave an answer!

    I ended up using

    var poiJson = ;
    
        for (var i = 0;i < poiJson.length; i += 1) {
            var lat = poiJson[i].poiLat;
            var lon = poiJson[i].poiLon;
            addMarker(lat,lon,i);
        };
    
        function addMarker(lat,lng,no){
        var latlng = new google.maps.LatLng(lat,lng);  
        var marker = new google.maps.Marker({
        position: latlng,
        map: map
        });
        };
    

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