0

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?

6
  • Have you looked at the Google Maps API examples? Commented Oct 15, 2011 at 15:41
  • Yes but i havent found any for HTML Commented Oct 15, 2011 at 15:43
  • Not sure what you mean. They are all for HTML, aren't they? Commented Oct 15, 2011 at 15:44
  • No i haven't found any library for html there..I had read the Javascript API 3 Commented Oct 15, 2011 at 15:47
  • 1
    Why 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. Commented Oct 15, 2011 at 15:48

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Nice answer. Minor issue: your text is about XML but your example URL and code is for JSON.
Oops...you've still got JSON in your example result rather than XML.
@John argh, where is my head these days. Now it is fixed. :)
1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.