0

我想知道是否有人知道一个好的 Javascript/Query 地图控件,它允许用户点击一个位置。完成此操作后,控件将使用用户刚刚选择的 GPS 坐标进行回调。

有谁知道这样的控制。

我一直在寻找,但还没有找到任何东西。

这是在 MVC3 应用程序中使用的。

欢迎所有建议。

4

1 回答 1

4

来自谷歌地图 API (https://developers.google.com/maps/documentation/javascript/events#EventListeners)

var map;
function initialize() 
{
    var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
    var mapOptions = 
    {
        zoom: 4,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

    google.maps.event.addListener(map, 'click', function(event) 
    {
        placeMarker(event.latLng);
    });
}

function placeMarker(location) 
{
    var marker = new google.maps.Marker(
    {
        position: location,
        map: map
    });

    map.setCenter(location);
}

演示https://google-developers.appspot.com/maps/documentation/javascript/examples/event-arguments

于 2012-11-12T19:56:06.150 回答