2014-10-22 4 views
0

phonegap에 안드로이드 응용 프로그램이 있습니다. Google지도입니다. 내 현재 위치를 보여 주며, 제 위치에 draggable 마커가 있고, 위도와 경도를 나타내는 infoWindow가 있습니다. 내 주소 대신 위도 내 정보창 내 경도를 표시 할주소 (역방향 지오 코딩) google maps

var map; 
var marker; 
var infowindowPhoto = new google.maps.InfoWindow(); 
var latPosition; 
var longPosition; 

function initialize() { 

var mapOptions = { 
    zoom: 8, 
    mapTypeId: google.maps.MapTypeId.ROADMAP, 
    center: new google.maps.LatLng(10,10) 
}; 

map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 

initializeMarker(); 
} 

function initializeMarker() { 

if (navigator.geolocation) { 

    navigator.geolocation.getCurrentPosition(function (position) { 

     var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 

     latPosition = position.coords.latitude; 
     longPosition = position.coords.longitude; 

     marker = new google.maps.Marker({ 
      position: pos, 
      draggable: true, 
      animation: google.maps.Animation.DROP, 
      map: map 
     }); 

     map.setCenter(pos); 
     updatePosition(); 

     google.maps.event.addListener(marker, 'click', function (event) { 
      updatePosition(); 
     }); 

     google.maps.event.addListener(marker, 'dragend', function (event) { 
      updatePosition(); 
     }); 
    }); 
} 
} 


function updatePosition() { 

latPosition = marker.getPosition().lat(); 
longPosition = marker.getPosition().lng(); 

contentString = '<div id="iwContent">Lat: <span id="latbox">' + latPosition + '</span><br />Lng: <span id="lngbox">' + longPosition + '</span></div>'; 

infowindowPhoto.setContent(contentString); 
infowindowPhoto.open(map, marker); 
} 

initialize(); 

http://jsfiddle.net/upsidown/d3toa81m/

내 문제. 이 튜토리얼은 https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse입니다. 내가이를 추가하지 않으려는이 튜토리얼에 내 문제 :

<input id="latlng" type="text" value="40.714224,-73.961452"> 
    <input type="button" value="Reverse Geocode" onclick="codeLatLng()"> 

내가 추가하지 않을 경우이 기능을 "codeLatLng()가"작동하지 않습니다. 내 정보 창에 내 주소를 표시하려면 어떻게해야합니까?

답변

0

Google지도에서 그리드 좌표를 얻고 있습니다. 그리드를 얻으면 컬을 사용하여 도시와 주에 대한 Google지도를 스크랩 했습니까? 나는 행운을 빈다.