1
我已經建立了一個應用程序來搜索我的位置。如何啓用谷歌地圖控制器(右,右..等箭頭)
下面是它工作正常的代碼
var map;
var gdir;
var geocoder = null;
var addressMarker;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
map.setCenter(new GLatLng(51.519853,-0.122566), 14)
var point = new GLatLng(51.519853,-0.122566); //CHANGE THESE COORDINATES
map.addOverlay(new GMarker(point));
map.openInfoWindow(map.getCenter(),html)
}
}
function setDirections(fromAddress) {
gdir.load("from: " + fromAddress + " to: 51.519741,-0.122596 ");
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) {
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) {
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_BAD_KEY) {
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) {
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
} else {
alert("An unknown error occurred.");
}
}
function onGDirectionsLoad(){}
。但沒有導航鍵。 任何人都可以告訴我如何激活它請
我試着把這段代碼。沒有您使用的哪一個谷歌地圖API的版本中正常工作:( – Muhammed
? – NT3RP
V2 '' – Muhammed