1
你好我使用以下GeoLocation中的功能正如你看到它在字段中的值寫入到讓訪客瀏覽HTML5的jQuery GeoLocation中與谷歌地圖
function success(position) {
var s = document.querySelector('#location');
if (s.className == 'success') {
return;
}
s.value = "found you!";
s.className = 'success';
var mapcanvas = document.createElement('div');
mapcanvas.id = 'mapcanvas';
mapcanvas.style.height = '200px';
mapcanvas.style.width = '380px';
document.querySelector('article').appendChild(mapcanvas);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"You are here!"
});
}
function error(msg) {
var s = document.querySelector('#status');
s.innerHTML = typeof msg == 'string' ? msg : "failed";
s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
的位置「找到你了!」當過程成功時。
現在我需要而不是寫「找到你!」我需要寫下訪客的位置。
因此,如果成員是在羅馬,它會寫「羅馬,意大利」
如何實現的呢?
感謝您的幫助!
mmhh?更直接的東西? –