English 中文(简体)
• 如何在网上浏览图上展示参观点
原标题:How to show a visitors location on google map in web app

我正在使用jquery移动电话进行简单的网络浏览。 我正试图展示一张角图,显示参观者在地图上的位置。 下面的法典是目前使用的一米,但是它显示的是具体的协调。

Can anyone help me change this so that it shows the visitors location? I have tried several solutions but have had no luck. Thank you!

<script>
$( #map_result ).live( pageshow ,function(event){
loadMap(48.870181,2.779852);
});
function loadMap(Lat, Long){
 var myLatlng = new google.maps.LatLng(Lat, Long);
 var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
 }
 map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
最佳回答

为此:

$( #map_result ).live( pageshow , function (event) {
    navigator.geolocation.getCurrentPosition(function (location) {
        loadMap(location.coords.latitude, location.coords.longitude);
    });

});

function loadMap(Lat, Long) {
    var myLatlng = new google.maps.LatLng(Lat, Long);
    var myOptions = {
        zoom: 13,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
问题回答

暂无回答




相关问题
How to decide the current point reach on google map?

How to decide the current point reach on google map? I have a list of points (pickup points) of a route that I want to show in my google map with polyline. Now i have to get the current location of ...

Topographical or relief data in Map APIs

I was wondering if anyone knew of any map APIs that offer topographical or relief data? I ve had a quick look at Google and Bing APIs, but could find nothing there. Google allow you to view a map as ...

Using maps on Windows Mobile

I m experimenting with maps on different mobile platforms. Getting Google Maps to work on Android was easy, following this tutorial. Getting the same to work on Windows Mobile is a different matter. ...

Adding a custom icon to a google map

I need a hand adding a custom icon to some Google Maps javascript. Code below for your reference: function populateMap() { var map = new GMap2(document.getElementById("map")); map.setCenter(new ...

RSS to KML Overlay

I m want to display my blog as a Google Map overlay (each post contains geotags). How can I dynamically create a KML overlay from an RSS? Or better, how can I create a loop (PHP) that would display ...

开放街道地图管理员

我需要开放Street的标记管理员。 地图,如山角地图。

热门标签