당신은
편집을 게시물 코드의 좌표를 얻기 위해 google's geocoding을 사용할 수 있습니다 : 나는 당신이 그러나 확인과 같은 질문의 의미를 변경하는 등 정말하지 않습니다. 시험해 보시기 바랍니다. :
// Creating an array that will contain the coordinates
// for New York, San Francisco, and Seattle
var places = [];
// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var result;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://maps.googleapis.com/maps/api/geocode/json?address=your+code&sensor=false",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
result = eval('(' + xmlhttp.responseText + ')');
if (result.status == "OK") {
var location = new google.maps.LatLng(result.results[0].geometry.location.lat, result.results[0].geometry.location.lng);
places.push(location);
가능한 작은 오류가 있음에도 불구하고이 방법을 사용해보십시오.
EDIT2 : 나는 지금 simpler solution을 발견했다 :
// Creating an array that will contain the coordinates
// for New York, San Francisco, and Seattle
var places = [];
// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': "your+code"}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
//var marker = new google.maps.Marker({
//map: map,
//position: results[0].geometry.location
//});
places.push(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
감사합니다, 나는 홀로 내가 가지고있는 현재의 코드와 병합 시작하는 위치의 아무 생각도 없어. – Rob
내가 제공 한 사이트를 살펴보고 : http://www.w3schools.com/xml/xml_http.asp 과 같이 요청을 작성하십시오. http://maps.googleapis.com/maps/api/geocode/json? address = SW1A + 0AA Google의 eval json 응답 및 – slawekwin
센서가 지오 코드 요청에서 잊어 버렸습니다. maps.googleapis.com/maps/api/geocode/json?address=SW1A+0AA&sensor = false – slawekwin