Saturday, April 6, 2013

Google Maps

Here is my recent experience using Google Map API.

Using maps API, for any given longitude - latitude map could be loaded.

// include script along with API Key

// create LatLng object
var latlng = new google.maps.LatLng( 17.4155646, 78.47505330000001).val())


// Set Map Type and zoom level
var mapOptions = {
          center: latlng,
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP 
        };

// create map object using a placeholder div tag for loading the map.
map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);

// create a tag position on exact location of longitude and latitude
var tagPosition = new google.maps.Marker({
map:map,
position: latlng
});

As simple as that ! But it's just background work - how is this useful?

1) You may use GeoCoder service to translate a location address to Longitude and Latitude. Typical way maps are used. Provide a text box to enter location. GeoCoder Service provides required information to load the map for that address.

2) Or something cool - use longitude and latitude information on an image to point out where the picture was taken. Consider following screenshot,

You could showoff images on a map in a pretty cool manner!