Google Map API implements Address Resolution

Source: Internet
Author: User

The Address Resolution Service of Google map API is free of charge currently. You can convert the detailed address to the longitude and latitude.
The test HTML file is as follows:

 <!DOCTYPE html>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
}

function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
<body onload="initialize()">
<div>
<input id="address" type="textbox" value="Sydney, NSW">
<input type="button" value="Geocode" onclick="codeAddress()">
</div>
</body>

 

However, this relies on the support of Google's online service interfaces. If Google leaves the Chinese market one day or there are other reasons that it will no longer open these service interfaces, it will be impossible.

In addition, Google restricts the speed and quantity of the function. The following is a description on Google:

There are limits on the use of the Google Geocoding API, that is, 2,500 geographic location query requests per day. (Google Maps API Premier users can execute a maximum of 100,000 requests per day .) This restriction is enforced to prevent abuse and/or reuse of the Google Geocoding API. This restriction may be changed in the future without further notice. In addition, we have set a request rate limit to prevent misuse of this service. If you exceed the 24-hour limit or abuse this service, Google Geocoding API may suspend your service. If you ignore this restriction, your access to Google Geocoding API will be blocked.

I tried to extract the batch address information from the backend and use the for loop for batch resolution. I found that at most 11 addresses were parsed, but none of the other addresses were parsed. Therefore, it is no problem to parse a single address when using it. For batch parsing ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.