Google Maps Application Developing —— Marker

Quick Start

        It is quite easy to put a marker on your map with the default look. to create a marker , you need to use the google.maps.Marker object. It only takes one parameter , which is an object of type google.maps.MarkerOptions.

        MarkerOptions has several properties that you can use to make the marker look and behave in different ways. Position and map are must:

var marker = new google.maps.Marker({
	position: new google.maps.LatLng(37.09,-95.71),
	map: map
	});

Other Properties of MarkerOptions

        title is using to add a tooltip

        icon is using to change the icon

        Google has a collection of standard icons that you can use on your map. Most of them use a similar URL that looks like this:

http://gmaps-samples.googlecode.com/svn/trunk/markers/color/markerx.png

        where color is one of the following values:

• blue
• green
• orange
• pink
• red

and x is a number between 1 and 99. If you want a marker with no number, use the filename blank.png.

Adding an InfoWindow

var infoWindow = new google.maps.InfoWindow({
	content: '<div style="width:250px">InfoWindow</div>'
	});
	
google.maps.event.addListener(marker, 'click', function(){
	infoWindow.open(map, marker);
	});
posted @ 2012-01-28 17:11  Create Chen  阅读(1099)  评论(0编辑  收藏  举报