I had used Google MAP with android before but now I want to use it with in my webpage.My idea is that I have a webpage in which there is a textfield .When I will enter America in it then It must show me the Satellite view of America.I had not used any Google Map with HTML before.One idea is to use Php curl with it,Can anyone tell me how i can do this?
-
Have you looked at the Google Maps API examples?Pekka– Pekka2011-10-15 15:41:43 +00:00Commented Oct 15, 2011 at 15:41
-
Yes but i havent found any for HTMLSharpzain120– Sharpzain1202011-10-15 15:43:10 +00:00Commented Oct 15, 2011 at 15:43
-
Not sure what you mean. They are all for HTML, aren't they?Pekka– Pekka2011-10-15 15:44:08 +00:00Commented Oct 15, 2011 at 15:44
-
No i haven't found any library for html there..I had read the Javascript API 3Sharpzain120– Sharpzain1202011-10-15 15:47:49 +00:00Commented Oct 15, 2011 at 15:47
-
1Why can you not work with JavaScript? The end result is a HTML page nevertheless. If you want to work without JavaScript, you'll have to use static maps but they are much, much more limited than normal, JavaScript-driven Google Maps.Pekka– Pekka2011-10-15 15:48:35 +00:00Commented Oct 15, 2011 at 15:48
2 Answers
If you send a geocoding request to Google's Geocoder, for example for "USA":
http://maps.googleapis.com/maps/api/geocode/json?address=USA&sensor=false
you will get an JSON result. Part of that result will be the viewport:
"viewport" : {
"northeast" : {
"lat" : 64.73664149999999,
"lng" : -30.14648320
},
"southwest" : {
"lat" : -5.70344770,
"lng" : -161.27929880
}
}
also available as XML:
http://maps.googleapis.com/maps/api/geocode/json?address=USA&sensor=false
these are the boundaries of a rectangle that covers the entire area of the USA.
Using these coordinates, you can then proceed to the "normal" Google Maps API examples and have the map show exactly that bounding box.
Use the fitBounds parameter in the Map's constructor. fitBounds is an object of the type LatLngBounds that you need to construct out of the viewport's coordinates.
It's not entirely trivial to do, but definitely possible. You can use PHP to make the first XML request, then output the JavaScript to generate the map.