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

geolocation - Is it possible to provide geo tagging for entire city?

问题描述:

I'm using geo tagging meta tags

  1. position - contains latitude and longitude
  2. Placename - contains city,state,country
  3. Region - contains the city name

Do this geo tagging applies only to the specified locations pointed using latitude and longitude?. How can i point the entire city say new york. Is there any way?

网友答案:

You could use the Google Places Autocomplete API to accomplish this. Here's an example

var autocomplete = new google.maps.places.Autocomplete(address);

google.maps.event.addListener(autocomplete, 'place_changed', function() {
  var latitude = autocomplete.getPlace().geometry.location.lat();
  var longitude = autocomplete.getPlace().geometry.location.lng();

  $("#lat").val(latitude).change();
  $("#lon").val(longitude).change();
});
input {
  width: 400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&dummy=.js"></script>
<form>
  <input type="text" id="address" placeholder="address">
  <br>
  <input type="text" id="lat" placeholder="latitude">
  <br>
  <input type="text" id="lon" placeholder="longitude">
</form>
分享给朋友:
您可能感兴趣的文章:
随机阅读: