Oct 5, 2009

Google Maps Continued . . .

Building on my last post on how to add a google map api to your website, I now want to show some of the many options you can use to configure the api to your personal preference. As shown below, this is the mininum code for your map to be created. To add an option to the map, you will need to use googles map classes and add a new line to your code. You can find all of the google map classes on the google maps api reference website.
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(42.240963,-83.618987), 13);

map.setCenter(new GLatLng(42.240963,-83.618987), 13);
This option sets the center location of the map and must be configured with the latitude and longitude of the location you want the map to default to. An easy to use website to get your desired coordinates is http://www.getlatlon.com/.

map.setUIToDefault();
This option sets the user interface to googles predefined settings. The clickable map types and the map navigator and zoom function comes standard with this option.


map.setMapType(map type );
Using this command will set the default map type to either map, satellite, hybrid, or terrain. To set the map type insert one of the following desired map types inside the parentheses.
G_NORMAL_MAP
G_SATELLITE_MAP
G_HYBRID_MAP
G_PHYSICAL MAP


map.enableGoogleBar()
Adding this option to your code will add a search bar to your machine. In my example I typed in Toledo, Oh and the map centered on my location with a google marker.

These are just a few of the configurable options when implementing a google map into your website. I highly recommend visiting the google map api reference documentation to familiarize yourself with all the options there are to offer

Enjoy!!

7 comments:

  1. Another excellent explanation of how to use Google Maps. Thank you for the information, I'm sure it will be very useful on my project(s)!

    ReplyDelete
  2. Josh, thanks for continuation of the google maps API. Your definately making alot easier for the class (and the of the readers) to utilize this great utility. One that alot of good API's and mashups are already using.

    ReplyDelete
  3. Thank you for these examples of the Maps-API. The API has that much options to work with Google Maps. I tried it by myself and its great!

    ReplyDelete
  4. Joshua,

    This is a super post. I haven't had a chance to dive into the api's so this was very helpful. Your blog makes it look easy. I hope it's as easy as it looks.

    Thanks!

    ReplyDelete
  5. The Google map API is easy because it inserts everything into the div for you. I am worried about the api's that return in xml or json format that you have to extract data out of.

    ReplyDelete
  6. This is a great post. It's very helpful for probably all the groups :)

    ReplyDelete
  7. I meant to send you this eariler in the semester, but thanks, your post really helped me out.

    ReplyDelete