0

我正在使用此代码来获取谷歌地图。它具有纬度和经度值,但我有一个具有纬度和经度的数据库。我想在这张地图中使用数据库中的纬度和经度,怎么做?

这是我的谷歌地图 javascript

  <script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(12.91869,77.594051);
    var myOptions = {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
    });
    var infowindow =  new google.maps.InfoWindow({
        map: map,
        position: latlng,
        });
    map.openInfoWindow(latlng,
                       document.createTextNode("Hello, world"));
  }
</script>

谁能帮我...?

提前致谢.....

4

1 回答 1

0

Just a method you can follow to go ahead-

Firstly load the latlng values from the database and store them in an array.

Then pass this array of latlng's to a javascript function that will display this latlng values on the map. The function will essentially contain a loop that will display each of these latlng's one by one on the map along with a marker.

You should first try working with an array of latlng's hardcoded in an array of javascript. Then it would be easy dealing with values retrieved from a database.

于 2012-09-18T08:30:27.570 回答