Google map V3 Set Center to specific Marker

后端 未结 6 840
深忆病人
深忆病人 2020-12-05 13:04

I am using Google Map V3 to display a list of markers pulled from a DB, using MYsql and PHP. MY markers are set on the map using the full address (from DB, including postcod

6条回答
  •  伪装坚强ぢ
    2020-12-05 13:41

    may be this will help:

    map.setCenter(window.markersArray[2].getPosition());
    

    all the markers info are in markersArray array and it is global. So you can access it from anywhere using window.variablename. Each marker has a unique id and you can put that id in the key of array. so you create marker like this:

    window.markersArray[2] = new google.maps.Marker({
                position: new google.maps.LatLng(23.81927, 90.362349),          
                map: map,
                title: 'your info '  
            });
    

    Hope this will help.

提交回复
热议问题