2013-09-25 2 views

답변

0

이 알고리즘은 다음과 같이 될 것입니다 :

  1. 는 기본 위치를 기반으로지도보기 (을 예를 들어이 당신의 도시와 적절한 줌 레벨)
  2. 형태와 텍스트 상자는 검색하고 "검색 버튼"지오 코딩하고 해당 주소를 위도, 경도를 얻을 수에 클릭에
  3. 이벤트를 해결하기 위해
  4. 자바 스크립트를 통해 지오 서비스 응답
  5. 에 따라지도의 중심을 다시 설정
  6. 지오 코딩 서비스에서 반환 된 위치에 마커를 추가합니다.

희망이

PD가 어떻게 지금 패널과지도를 쿼리하는 데 도움이? 여기

-1
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 
    <script> 

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 

    } 

    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); 

    } 

    }); 

} 


google.maps.event.addDomListener(window, 'load', initialize); 



    </script> 

<input id="address" type="textbox" value="New Delhi, India"> 

     <input type="button" value="Geocode" onclick="codeAddress()"> 
관련 문제