也許給你體驗,你應該嘗試使用gmap3 jQuery的。它使用Google Maps API v3,但將API抽象化,使其更易於使用。他們有你應該學習的example。它需要一個地址並返回一個可能的位置。
下面,我已經修改,這將提醒位置的例子 - 希望給你一個良好的開端:
$("#test").gmap3();
$('#address').autocomplete({
//This bit uses the geocoder to fetch address values
source: function(request, response) {
$("#test").gmap3({
action:'getAddress',
address: request.term,
callback:function(results){
if (!results) return;
response($.map(results, function(item) {
alert("The location is", item.geometry.location.lat(), item.geometry.location.lon());
return {
label: item.formatted_address,
value: item.formatted_address,
latLng: item.geometry.location
}
}));
}
});
},
//This bit is executed upon selection of an address
select: function(event, ui) {
$("#test").gmap3(
{action:'clear', name:'marker'},
{action:'addMarker',
latLng:ui.item.latLng,
map:{center:true}
}
);
}
});
您所有的問題都非常相似......。 – Widor
這是另一個任務:o其他人我沒有使用緯度和經度.. 也使用OSM還有因爲其他任務是自由的谷歌API – ronnie
我看到更大的和大的。只是要小心,不要讓他們問我「爲我做我的工作」,就這些。 – Widor