如何检索给定地名的经度和纬度?
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以从链接按钮获取Google地图。首先右键单击地图并在此处“居中地图”,然后单击左侧窗格上的“链接”按钮,创建所需的位置中心。下一步查找ll
parm。这包含经度和纬度。
示例:
http://maps.google.com.my/?ll=3.009556,101.748505&spn=0.341477,0.676346&t=m&z=11
答案 2 :(得分:0)
这是使用谷歌地理编码API时google.js文件中包含的两个功能 我已经用一些标记和其他更多选项重新创建它请看看它。当您为函数提供名称时,它会为您提供lat和lng。
function load() {
//$("#text1").autocomplete(source: arr);
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var center = new GLatLng(19.11340, 72.83526);
map.setCenter(center, 12);
geocoder = new GClientGeocoder();
var marker = new GMarker(center, { draggable: true });
map.addOverlay(marker);
document.getElementById("lat").innerHTML = center.lat().toFixed(5);
document.getElementById("lng").innerHTML = center.lng().toFixed(5);
GEvent.addListener(marker, "dragend", function () {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("lat").innerHTML = point.lat().toFixed(5);
document.getElementById("lng").innerHTML = point.lng().toFixed(5);
});
GEvent.addListener(map, "moveend", function () {
map.clearOverlays();
var center = map.getCenter();
var marker = new GMarker(center, { draggable: true });
map.addOverlay(marker);
document.getElementById("lat").innerHTML = center.lat().toFixed(5);
document.getElementById("lng").innerHTML = center.lng().toFixed(5);
GEvent.addListener(marker, "dragend", function () {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("lat").innerHTML = point.lat().toFixed(5);
document.getElementById("lng").innerHTML = point.lng().toFixed(5);
});
});
}
}
function showAddress() {
load();
var address = $("#text1").val();
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
if (geocoder) {
geocoder.getLatLng(
address,
function (point) {
if (!point) {
alert(address + " not found");
} else {
document.getElementById("lat").innerHTML = point.lat().toFixed(5);
document.getElementById("lng").innerHTML = point.lng().toFixed(5);
map.clearOverlays()
map.setCenter(point, 13);
var marker = new GMarker(point, { draggable: true });
map.addOverlay(marker);
GEvent.addListener(marker, "dragend", function () {
var pt = marker.getPoint();
map.panTo(pt);
document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
});
GEvent.addListener(map, "moveend", function () {
map.clearOverlays();
var center = map.getCenter();
var marker = new GMarker(center, { draggable: true });
map.addOverlay(marker);
document.getElementById("lat").innerHTML = center.lat().toFixed(5);
document.getElementById("lng").innerHTML = center.lng().toFixed(5);
GEvent.addListener(marker, "dragend", function () {
var pt = marker.getPoint();
map.panTo(pt);
document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
});
});
}
}
);
}
}