2010-07-29 9 views
13

Google지도 API를 사용하여 사이드 바 또는 검색 창이없는 전체 화면지도를 표시하려면 어떻게해야합니까? 모바일 앱에서 특정 위치를 표시하기 만하면 사용자가 검색 할 필요가 없습니다. 이것이 가능한가?전체 화면 Google지도

또한 주소를 입력하면 어떻게 푸시 핀을 그 위치에 놓을 수 있습니까?

답변

25

당신이 v3 API를 사용할 계획 가정하면, 문서의 다음 섹션을 확인 할 수 있습니다 :

두 번째 질문에 관해서는, 당신은 Geocoding를 사용할 수 있습니다.

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps Geocoding Demo</title> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" 
      type="text/javascript"></script> 
    <style type="text/css"> 
    html { height: 100% } 
    body { height: 100%; margin: 0px; padding: 0px } 
    #map { height: 100% } 
    </style> 
</head> 
<body> 
    <div id="map"></div> 

    <script type="text/javascript"> 

    var address = 'Oxford Street, London, UK'; 

    var map = new google.maps.Map(document.getElementById('map'), { 
     mapTypeId: google.maps.MapTypeId.TERRAIN, 
     zoom: 12 
    }); 

    var geocoder = new google.maps.Geocoder(); 

    geocoder.geocode({ 
     'address': address 
    }, 
    function(results, status) { 
     if(status == google.maps.GeocoderStatus.OK) { 
     new google.maps.Marker({ 
      position: results[0].geometry.location, 
      map: map 
     }); 
     map.setCenter(results[0].geometry.location); 
     } 
     else { 
     // Google couldn't geocode this request. Handle appropriately. 
     } 
    }); 

    </script> 
</body> 
</html> 

스크린 샷 :

Full Screen Google Map

다음과 같은 간단한 예제를 생각해