Home arrow Web Authoring arrow Page 2 - Introducing the Google Maps API
WEB AUTHORING

Introducing the Google Maps API


Maps are becoming ubiquitous in web applications. They are being used as an effective and non-intrusive way of gathering geo-specific data from the user or to present geo-specific information to the user -- for example, for tracking reports of shipments. However even two years ago, embedding a map within an application was a specialized area that required a good understanding of Geographical Information Systems (GIS). This changed with the arrival of Google Maps and its corresponding set of APIs, known as the Google Maps API.

Author Info:
By: A.P.Rajshekhar
Rating: 5 stars5 stars5 stars5 stars5 stars / 14
June 06, 2007
TABLE OF CONTENTS:
  1. · Introducing the Google Maps API
  2. · More Google Maps API Functions
  3. · Using the Google Maps API, Step By Step
  4. · The Google Maps API in the Real World

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Introducing the Google Maps API - More Google Maps API Functions
(Page 2 of 4 )

Map Types

Google Maps provides three types of map: a simple map that provides an outline-based map, a satellite map that streams the satellite-imaged maps and a hybrid map which combines both of the aforementioned maps. The map types provided by Google Maps are controlled by the following methods:

  • setMapType(type) sets the type of map to be displayed.
  • removeMapType(type) removes a map type that has already been set.

The type parameter is specified using the constants provided by the GMapType class. It can be G_NORMAL_MAP, G_SATELLITE_MAP, or G_HYBRID_MAP corresponding to maps of the simple, satellite image-based or hybrid types. 

Map State

The methods that provide information about the state of the map come under this heading. The information provided by map state methods include whether the map is loaded or not, the current focus point or center of the map, and more. The commonly used methods are:

  • isLoaded() tells whether or not the map is loaded onto the client browser.
  • getCenter() provides the latitude and longitude of the center of the current view port of the map.

Overlays

By definition "A map overlay refers to a point or polyline that is added on top of the Google Map." In essence an overlay means a point or line that is placed on the map to distinguish it from the rest of the map. The most used methods in this category are:

  • addOverlay(overlay) adds an overlay presented by the overlay object passed as a parameter.
  • removeOverlay(overlay) removes an overlay already added and represented by the overlay object passed as a parameter.

The overlay object can be of the GPoint or GPolyline types.

Information Window

When an overlay is clicked, a window containing detailed information can be displayed. It is called the information window or info window in short. The following are the main methods used to control an info window:

  • openInfoWindow(latlng,dom,[opts]) opens an information window at the point specified by latlang and with the data specified as dom which is a DOM node.
  • showMapBlowup(latlng,[opts]) opens an info window at the specified latlng containing the close-up view of the latlng specified as a parameter.

The parameter latlng is of the GLatLng type.

Map Navigation

The navigation of the map can be controlled using the methods provided under this category. The commonly used methods are:

  • setCenter(center,[zoom],[type]) loads the map focused on the point specified by center with an optional level of zoom and type of map. 
  • panTo(center) navigates to the point on the map specified by center.
  • setZoom(level) zooms into or magnifies the current center to the level specified with the parameter level.

Events

The Google Maps API provides methods to intercept any event taking placing on the map. The common events supported by the Google Maps API are:

  • click is generated when the user clicks on any point within the boundaries of the map.
  • move is fired when the map is moving or panning. During panning it may be fired many times.
  • moveend is fired when the panning is completed.

That brings us to the end of the first part of our discussion. In the next section I will detail the steps required to work with the Google Maps API.


blog comments powered by Disqus
WEB AUTHORING ARTICLES

- Top WordPress Plugins for Social Media
- How to Install WordPress on WAMPP
- More of the Best Wordpress Plugins for Comme...
- Top Wordpress Plugins to Fight Spam
- More of the top Drupal modules for SEO
- Top Drupal Modules for SEO
- More Top Wordpress Plugins for SEO
- Website Optimization Tips
- Backup and Restore a Drupal Website and Data...
- 5 Best Web Font Services
- Web Font Embedding Services
- Joomla Site Administration
- Create PHP Pages that Use WordPress Templates
- Top Joomla Extensions for Social Networking
- Drupal Modules for Site Navigation

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials