Sharpzain120
Sharpzain120

Reputation: 375

Using Google map APi in html

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?

Upvotes: 0

Views: 161

Answers (2)

Pekka
Pekka

Reputation: 449425

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.

Upvotes: 3

Serhiy
Serhiy

Reputation: 4141

You have the full documentation of Google Maps + JavaScript Api here. It supports Reverse Geocoding(example), which is translating addresses to coordinates(including names like America)

Upvotes: 1

Related Questions