当前位置: 动力学知识库 > 问答 > 编程问答 >

Get Near by places data with longitude lattitude using google map api 3 without loading the map

问题描述:

i want to use google map api. and want to get near by places data by specifying longitude latitude.

my question is that...

is it possible to get near by places data with longitude-latitude without loading the google map ?

i have checked " Retrieve predictions from the autocomplete service " but its not returning longitude-latitude related information.

网友答案:

You can create a map div and hide that div in your application. In the background, you can call google map and get near by places and do what ever you want.

<div class="row" id="map-canvas" width="100%" height="400" style="display:none;"></div>

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    map.places.search(search, function(results, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
          for(var i = 0; i < results.length; i++){

              console.log(results[i]);
          }


      } else {
          alert('unable to get the data from google map');
      }
    });

Adjust the functionality as per your requirement. to run this application you might need to make little modification. refer to google map place search api for batter understanding.

分享给朋友:
您可能感兴趣的文章:
随机阅读: