开发者

full address resolve to google map

geocode, only allow enter of specify location example like 'building name' , 'city' .开发者_开发技巧.etc . anyway to allow user to enter "full address (included block number, postal code, street name)" and it auto resolve to google map location?


This is how you can get the co-ordinates
http://maps.googleapis.com/maps/api/geocode/json?address=154+Metro+Central+Heights+London+UK&sensor=true
I have set up a demo here. In my case the address being 154 Metro Central Heights London UK, google returns the following co-ordinates.

"geometry": {
      "location": {
        "lat": 51.5001524,
        "lng": -0.1262362
      }

The co-ordinates obtained from the JSON can be used to create a marker on the map in the following way

var myOptions = {
    zoom: 14,
    center: new google.maps.LatLng(lat, lng),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
map = new google.maps.Map(document.getElementById("map_canvas"),
                       myOptions);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜