1
내 위치를 검색하는 응용 프로그램을 빌드했습니다.Google지도 컨트롤러를 사용 설정하는 방법 (오른쪽, 오른쪽 화살표 등)
는 여기가 잘 작동 코드
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(){}
입니다. 하지만 탐색 키가 없습니다. 내가 활성화 할 수있는 방법은 무엇이든지 말해 줄 수 있습니다.
이 코드를 삽입하려고합니다. 제대로 작동하지 않습니다 :( – Muhammed
당신이 어느 Google지도 API의 버전을 사용하고 있습니까? – NT3RP
V2 '<스크립트 SRC = "http://maps.google.com/maps?file=api & V = 2 & 센서 = 거짓 & 키 = ABQIAAAAzxCDBo1gy7W4QXIrmi9j2xTRTQz9XleK5_XejzX1GPWUDLY8xhSTdYSSU-w7OM78KatDMAVKJ - hHjw "유형 ="텍스트/자바 스크립트 ">' – Muhammed