미성년자 용 Google 지오 코딩 스크립트를 찾으려고합니다. 내가 찾은 것들은 매우 크고 복잡하지만, 이것은 매우 간단합니다. 그것이하지 않는 유일한 것은 실제로 다른 것과 같이 두 개의 입력 상자에 좌표를 넣습니다. 나는 그것이 긴/위도 입력 필드에 좌표를 넣어 어떻게합니까 http://jsfiddle.net/Rr5PL/89/Google 지오 코더 - 입력란에 좌표 추가
: 여기
는 코드 작동합니까? 지도에 표시 할 때 사용하기 때문에 저장해야합니다.var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
}
function codeAddress() {
var address = document.getElementById('address').value;
geocoder.geocode({ 'address': address}, 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
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
왜 입력란에 입력 하시겠습니까? 이미 변수에 저장되어 있습니다. – Marcelo
URL을 URL (예 : www.url.com/search?long=123lat=456 – Jimmy
)로 전달하고 싶습니다. Javascript 변수에서 가져올 수 있습니다. 입력 필드가 필요하지 않습니다. – Marcelo