1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| // marker是随着地图缩放级别,尺寸变化的 var marker = new BMap.Marker(new BMap.Point(116.404, 39.915)); // 创建点
// 折线 var polyline = new BMap.Polyline([ new BMap.Point(116.399, 39.910), new BMap.Point(116.405, 39.920), new BMap.Point(116.425, 39.900) ], {strokeColor: "blue", strokeWeight: 2, strokeOpacity: 0.5}); //创建折线
// 创建圆 var circle = new BMap.Circle( point, 1500, {strokeColor: "blue", fillColor: "#ccc", strokeWeight: 2, strokeOpacity: 0.5, fillOpacity: 0.7} );
// 多边形 var polygon = new BMap.Polygon([ new BMap.Point(116.387112, 39.920977), new BMap.Point(116.385243, 39.913063), new BMap.Point(116.394226, 39.917988), new BMap.Point(116.401772, 39.921364), new BMap.Point(116.41248, 39.927893) ], {strokeColor: "blue", strokeWeight: 2, strokeOpacity: 0.5});
//创建矩形 var pStart = new BMap.Point(116.392214, 39.918985); var pEnd = new BMap.Point(116.41478, 39.911901); var rectangle = new BMap.Polygon([ new BMap.Point(pStart.lng, pStart.lat), new BMap.Point(pEnd.lng, pStart.lat), new BMap.Point(pEnd.lng, pEnd.lat), new BMap.Point(pStart.lng, pEnd.lat) ], {strokeColor: "blue", strokeWeight: 2, strokeOpacity: 0.5});
// 开启(关闭)点线面的编辑(可以拖拽,移动点) polygon.enableEditing() polygon.disableEditing()
// 文字label var opts = { position : new BMap.Point(116.417854,39.921988), // 指定文本标注所在的地理位置 offset : new BMap.Size(30, -30) //设置文本偏移量 }
var label = new BMap.Label("欢迎使用百度地图,这是一个简单的文本标注哦~", opts); // 创建文本标注对象 label.setStyle({ color : "red", fontSize : "12px", height : "20px", lineHeight : "20px", fontFamily:"微软雅黑" });
// 覆盖物显示,隐藏 marker.show() marker.hide()
// 添加覆盖物 map.addOverlay(marker);
// 清除覆盖物 map.clearOverlays();
|