i've read that you can use either javascript or php with google maps api. so what are the pros and cons for each of them?
and if i got the geocodes stored in a database. should i get them with ajax and process them with javascript or should i use php?
it says in the FAQ that 15000 requests are allowed per day per ip. does this mean that EACH user has to run 15000 requests a day if im using javascript? sounds a lot. but if im using php instead, is it from the server's ip only, and thus 15000 for ALL u开发者_StackOverflowsers?
would be great if someone could shed a light on this topic.
The Google Maps API is a JavaScript library. However Google offers its Geocoding Services through a client-side API in JavaScript and though a server-side web service.
This is an example on how to use the JavaScript geocoder:
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
geocoder = new GClientGeocoder();
geocoder.getLatLng(
"London, UK",
function(point) {
if (point) {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
);
}
}
The following is an example showing how to get the latitude and longitude of an address on the server-side using php:
$url = 'http://maps.google.com/maps/geo?q=London,+UK&output=csv&sensor=false';
$data = @file_get_contents($url);
$result = explode(",", $data);
echo $result[0]; // status code
echo $result[1]; // accuracy
echo $result[2]; // latitude
echo $result[3]; // longitude
You understood the free geocoding quota correctly. Server-side geocoding is limited to 15k requests per day per server, while client-side geocoding is limited to 15k requests per day per client. You would need the Google Maps API Premier to increase these limits.
I think you are confused. The only part of the API that you can use PHP with is the geocoding api - http://code.google.com/apis/maps/documentation/geocoding/index.html
Assuming you are asking whether you should do your geocoding with javascript or a server side language like PHP, best practice is to cache whatever geocoding you can into some sort of persistance layaer (xml/db/whatever) and minimise the number of client side geocode requests (because of the delay it will introduce)
精彩评论