2013-11-25 3 views
0

내가 문자열자바 스크립트/구글 맵 : 문자열

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

위의 위치를 ​​가져옵니다으로 구글의 위치 API를 사용하는 다음과 같은 개체를 변환하는 방법을 찾기 위해 노력하고 있어요에 위치 개체를 변환합니다. 그러나, 나는 그것으로 작업 할 수 있도록 문자열로 무엇을 볼 수있는 방법을 알아낼 수 없습니다. 경고를하면 정의되지 않은 상태가되어 일반적인 의심스러운 속성을 시도했지만 표시되지 않습니다. 나는 그것이 무엇인지 알아 내야하므로 "Boston"또는 lat lon 또는 유사한 문자열을 입력으로받는 방향 서비스로 피드를 제공 할 수 있습니다.

답변

0
Please refer the below link. 

http://jsfiddle.net/y829C/1/

Here you can enter zip code and get the latitude and longitude. 

var geocoder = new google.maps.Geocoder(); 
     geocoder.geocode({ 'address': addresscity }, function (results, status) { 
       if (status == google.maps.GeocoderStatus.OK) { 
        latitude = results[0].geometry.location.lat(); 
        longitude = results[0].geometry.location.lng(); 
       var myLatlng = new google.maps.LatLng(latitude, longitude); 
        var mapOptions = { 
       center: new google.maps.LatLng(latitude, longitude), 
        zoom: 8, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 

    };