google.maps.Marker
1.创建方法
var marker = new google.maps.Marker({
position:pointGGPos,//谷歌地图经纬度
map:map,//当前地图对象
draggable: true,//是否可拖拽
icon:imageRed,//icon 对象
title:"imageRed"//标题
});
2.参数分析
- position:pointGGPos/谷歌经纬度
//pointGGPos:new google.maps.LatLng(纬度,经度);
var pointGGPos = new google.maps.LatLng(30.005,104.255);
- map:map,//当前地图对象
//pointGGPos:new google.maps.LatLng(纬度,经度);
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
- icon:imageBlue,//icon 对象
google.maps.Icon是接口,没有构造参数,不能直接生成,但是可以直接构造一个对象,该对象的属性有接口属性构成(可不完全包括)
var imageRed = {
url:"../redMark.png",
scaledSize: new google.maps.Size(20,28),
size: new google.maps.Size(20,28)
};
//可将imageRed当做icon对象
3.方法
- 设置图片:底部中心为当前经纬度
marker.setIcon(imageRed);
2.设置标注:位于marker中心
marker.setLabel("AAAAA");