Google Maps - Circle

<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>

<script>
var delhi=new google.maps.LatLng(28.6139,77.2090);
function initialize()
{
var mapProp = {
center:delhi,
zoom:7,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);

var myCity = new google.maps.Circle({
center:delhi,
radius:40000, // radius is in meters
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0.4
}); ...  Read More

Share This:


Google Maps - Polygon

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script>
var center = new google.maps.LatLng(31.1471,75.3412);
var delhi = new google.maps.LatLng(28.6139,77.2090);
var punjab = new google.maps.LatLng(31.1471,75.3412);
var gurgaon = new google.maps.LatLng(28.4595,77.0266);

function initialize()
{
var mapProp = {
center:center,
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myTrip = [delhi,punjab,gurgaon,delhi];
var trip_path=new google.maps.Polygon({
path:myTrip, //specifies several latitude/longitude coordinates for the line
strokeColor:"#0000FF", //specifies a hexadecimal color for the line
strokeOpacity:0.8, // specifies the opacity of the line
strokeWeight:2, // specifies the weight of the line's stroke in pixels
fillColor:"#0000FF",
fillOpacity:0.4
}); ...  Read More

Share This:


Google Maps - Polyline

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script>
var center = new google.maps.LatLng(31.1471,75.3412);
var delhi = new google.maps.LatLng(28.6139,77.2090);
var punjab = new google.maps.LatLng(31.1471,75.3412);
var gurgaon = new google.maps.LatLng(28.4595,77.0266);

function initialize()
{
var mapProp = {
center:center,
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myTrip = [delhi,punjab,gurgaon];
var trip_path=new google.maps.Polyline({
path:myTrip, //specifies several latitude/longitude coordinates for the line
strokeColor:"#0000FF", //specifies a hexadecimal color for the line
strokeOpacity:0.8, // specifies the opacity of the line
strokeWeight:2, // specifies the weight of the line's stroke in pixels
editable: true // false if don't allow user to edit the poly line
}); ...  Read More

Share This:


Google Maps - Icon Instead of Marker

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script>
var myCenter=new google.maps.LatLng(28.4595,77.0266);

function initialize()
{
var mapProp = {
center:myCenter,
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
position:myCenter,
icon:'mapicon.png'
});

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head> ...  Read More

Share This:


Google Maps - Animate the Marker

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script>
var myCenter=new google.maps.LatLng(28.4595,77.0266);

function initialize()
{
var mapProp = {
center:myCenter,
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
position:myCenter,
animation:google.maps.Animation.BOUNCE
});

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head> ...  Read More

Share This:


Google Maps - Add a Marker

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script>
var myCenter=new google.maps.LatLng(28.4595,77.0266);

function initialize()
{
var mapProp = {
center:myCenter,
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
position:myCenter,
});

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head> ...  Read More

Share This:


Google Maps - Overlays

Overlays are objects on the map that are bound to latitude/longitude coordinates.

Google Maps has several types of overlays:

  • Marker - Single locations on a map. Markers can also display custom icon images
  • Polyline - Series of straight lines on a map
  • Polygon - Series of straight lines on a map, and the shape is "closed"
  • Circle and Rectangle
  • Info Windows - Displays content within a popup balloon on top of a map
  • Custom overlays

Share This:


Creating basic google map

<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize()
{
var map_properties = {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom: 5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),map_properties);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="googleMap" style="width:500px;height:380px;"></div>

* initialize() method sets map properties.
* map_properties is an object which defines parameter ...  Read More

Share This: