简体   繁体   English

在谷歌地图上无法通过纬度和经度获得地址

[英]not geting address with help of lat and long in google map

i am trying to get address using reverse geocoding . 我正在尝试使用reverse geocoding地址reverse geocoding来获取地址。
but there is some problem in geocoder.geocode({...}) line. 但是geocoder.geocode({...})行中存在一些问题。 even normal alert message also not display. 即使是正常的警报消息也不会显示。

 function initialize() { 
 var mapOptions = { 
    zoom: 11,
    center: new google.maps.LatLng(23.0171240, 72.5330533),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);

  google.maps.event.addListener(map, 'click', function(e) {
    placeMarker(e.latLng, map);
    var input=e.latLng;
    var lat = parseFloat(input.lat());
    var lng = parseFloat(input.lng());
    var latlng = new google.maps.LatLng(lat, lng);
    geocoder.geocode({'latLng': latlng}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
           alert(results[1].formatted_address);
        }
      });
    });
}

function placeMarker(position, map) {
  var marker = new google.maps.Marker({
    position: position,
    map: map
  });
  map.panTo(position);
}

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

在initialize()函数中添加以下行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何用lat格式的经纬度反向解析google map地址? - how to reverse paring google map address with lat,long in json format? 如何在Google Map API中使用地址代替纬度/经度 - How to use Address instead of Lat/Long in Google Map API Google Map Geocoding没有为有效的完整地址返回纬度/经度 - Google Map Geocoding not returning lat/long for a valid complete address 我怎样才能在谷歌地图上显示我的数据库地址而没有纬度和经度? - how i can i show my database address on google map with out lat and long? 从自动完成地址输入中获取经纬度,并使用Google Maps API在下面显示地图 - Get Lat and Long from autocomplete address input and show the map below with google maps API 正则表达式匹配谷歌地图纬度 - Regex to match google map lat long 谷歌地图地理编码器变长和拉特 - Google Map geocoder get long and lat Google Map和Google Map API提供不同的纬度和经度 - Google map and Google map api giving different different lat and long <script>Not Getting Lat and Long from the given map address jquery or javascript - <script>Not Getting Lat and Long from the given map address jquery or javascript 获取在 leaflet map 上使用 mapbox 搜索的地址的纬度/经度 - Getting the lat/long of the address searched with mapbox on the leaflet map
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM