创建图标
map.js
$(document).ready(function()
{
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(36.94,106.08),4);
//创建小图标
var icon = new GIcon();
//图标图片
icon.image = "png/mm_20_red.png";
//图标阴影图片
icon.shadow = "png/mm_20_shadow.png";
//图标大小
icon.iconSize = new GSize(12, 20);
//阴影大小
icon.shadowSize = new GSize(22, 20);
//图标锚点
icon.iconAnchor = new GPoint(6, 20);
//信息浮窗锚点
icon.infoWindowAnchor = new GPoint(5, 1);
//随机的添加10个标记
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(point, icon));
}
$(window).unload(function (){
$('.').unbind();
GUnload();
});
}else
{
alert('你使用的浏览器不支持 Google Map!');
}
});