Google地图:考虑到Lat Long坐标 [英] Google Maps: Given the Lat Long coordinates

查看:135
本文介绍了Google地图:考虑到Lat Long坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Lat Long坐标(在JS数组中),我们如何在这些坐标上绘制带有标记的Google Map.

I have the the following Lat Long coordinates (in a JS array), how can we draw the Google Map with markers on these coordinates.

请举一个简单的例子,因为API文档中的例子并不能给出确切的结论或对我来说太复杂了.

Please give a simple example, as the examples in the API documentation do not really give a conclusive answer or are too complex for me.

43.82846160000000000000,-79.53560419999997000000

43.82846160000000000000, -79.53560419999997000000

43.65162010000000000000,-79.73558579999997000000

43.65162010000000000000, -79.73558579999997000000

43.75846240000000000000,-79.22252100000003000000

43.75846240000000000000, -79.22252100000003000000

43.71773540000000000000,-79.74897190000002000000

43.71773540000000000000, -79.74897190000002000000

谢谢.

推荐答案

您可以尝试

var map,
locations = [
    [43.82846160000000000000, -79.53560419999997000000],
    [43.65162010000000000000, -79.73558579999997000000],
    [43.75846240000000000000, -79.22252100000003000000],
    [43.71773540000000000000, -79.74897190000002000000]
];
var myOptions = {
    zoom: 6,
    center: new google.maps.LatLng(locations[0][0], locations[0][1]),
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map($('#map')[0], myOptions);
var infowindow = new google.maps.InfoWindow(), marker, i;
for (i = 0; i < locations.length; i++) {  
    marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][0], locations[i][1]),
        map: map
    });

    google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
            infowindow.setContent('Current location is: '+ locations[i][0]+', '+locations[i][1]);
            infowindow.open(map, marker);
        }
    })(marker, i));
}

演示 .

这篇关于Google地图:考虑到Lat Long坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆