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); });
作者:Create Chen
出处:http://technology.cnblogs.com
说明:文章为作者平时里的思考和练习,可能有不当之处,请博客园的园友们多提宝贵意见。
本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。