002 | < div id = "simpleMap" style = "height: 450px; width: 700px;" ></ div >< br > |
003 | < script type = "text/javascript" > |
004 | var map, drawControls; |
006 | //构造地图对象实例,并添加到id为simpleMap的div容器中 |
007 | map = new Geo.View2D.Map("simpleMap"); |
010 | transitionEffect: "resize", |
013 | maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90) |
016 | var pointLayer = new OpenLayers.Layer.Vector("Point Layer"); |
018 | var lineLayer = new OpenLayers.Layer.Vector("Line Layer"); |
020 | var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); |
023 | map.addLayers([layer, pointLayer, lineLayer, polygonLayer]); |
027 | point: new OpenLayers.Control.DrawFeature(pointLayer, |
028 | OpenLayers.Handler.Point), |
030 | line: new OpenLayers.Control.DrawFeature(lineLayer, |
031 | OpenLayers.Handler.Path), |
033 | polygon: new OpenLayers.Control.DrawFeature(polygonLayer, |
034 | OpenLayers.Handler.Polygon), |
036 | circle: new OpenLayers.Control.DrawFeature(polygonLayer, |
037 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 40}}), |
039 | triangle: new OpenLayers.Control.DrawFeature(polygonLayer, |
040 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 3}}), |
042 | square: new OpenLayers.Control.DrawFeature(polygonLayer, |
043 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 4}}), |
045 | pentagon: new OpenLayers.Control.DrawFeature(polygonLayer, |
046 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 5}}), |
048 | hexagon: new OpenLayers.Control.DrawFeature(polygonLayer, |
049 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 6}}), |
051 | irregularCircle: new OpenLayers.Control.DrawFeature(polygonLayer, |
052 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 40,irregular: true}}), |
054 | irregularTriangle: new OpenLayers.Control.DrawFeature(polygonLayer, |
055 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 3,irregular: true}}), |
057 | irregularSquare: new OpenLayers.Control.DrawFeature(polygonLayer, |
058 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 4,irregular: true}}), |
060 | irregularPentagon: new OpenLayers.Control.DrawFeature(polygonLayer, |
061 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 5,irregular: true}}), |
063 | irregularHexagon: new OpenLayers.Control.DrawFeature(polygonLayer, |
064 | OpenLayers.Handler.RegularPolygon,{handlerOptions: {sides: 6,irregular: true}}) |
067 | for(var key in drawControls) { |
068 | map.addControl(drawControls[key]); |
072 | map.setCenter(new OpenLayers.LonLat(104, 37), 2); |
073 | document.getElementById('noneToggle').checked = true; |
076 | function toggleControl(element) { |
077 | for(key in drawControls) { |
078 | var control = drawControls[key]; |
079 | if(element.value == key && element.checked) { |
083 | control.deactivate(); |
088 | < ul id = "controlToggle" > |
090 | < input name = "type" value = "none" id = "noneToggle" onclick = "toggleControl(this);" checked = "checked" type = "radio" > |
091 | < label for = "noneToggle" >导航操作</ label > |
094 | < input name = "type" value = "point" id = "pointToggle" onclick = "toggleControl(this);" type = "radio" > |
095 | < label for = "pointToggle" >画点</ label > |
096 | < input name = "type" value = "line" id = "lineToggle" onclick = "toggleControl(this);" type = "radio" > |
097 | < label for = "lineToggle" >画线</ label > |
098 | < input name = "type" value = "polygon" id = "polygonToggle" onclick = "toggleControl(this);" type = "radio" > |
099 | < label for = "polygonToggle" >画多边形</ label > |
102 | < input name = "type" value = "circle" id = "circleToggle" onclick = "toggleControl(this);" type = "radio" > |
103 | < label for = "circleToggle" >画圆</ label > |
104 | < input name = "type" value = "triangle" id = "triangleToggle" onclick = "toggleControl(this);" type = "radio" > |
105 | < label for = "triangleToggle" >画规则三角形</ label > |
106 | < input name = "type" value = "square" id = "squareToggle" onclick = "toggleControl(this);" type = "radio" > |
107 | < label for = "squareToggle" >画规则四边形</ label > |
108 | < input name = "type" value = "pentagon" id = "pentagonToggle" onclick = "toggleControl(this);" type = "radio" > |
109 | < label for = "pentagonToggle" >画规则五边形</ label > |
110 | < input name = "type" value = "hexagon" id = "hexagonToggle" onclick = "toggleControl(this);" type = "radio" > |
111 | < label for = "hexagonToggle" >画规则六边形</ label > |
114 | < input name = "type" value = "irregularCircle" id = "irregularCircleToggle" onclick = "toggleControl(this);" type = "radio" > |
115 | < label for = "irregularCircleToggle" >画椭圆</ label > |
116 | < input name = "type" value = "irregularTriangle" id = "irregularTriangleToggle" onclick = "toggleControl(this);" type = "radio" > |
117 | < label for = "irregularTriangleToggle" >画不规则三角形</ label > |
118 | < input name = "type" value = "irregularSquare" id = "irregularSquareToggle" onclick = "toggleControl(this);" type = "radio" > |
119 | < label for = "irregularSquareToggle" >画不规则四边形</ label > |
120 | < input name = "type" value = "irregularPentagon" id = "irregularPentagonToggle" onclick = "toggleControl(this);" type = "radio" > |
121 | < label for = "irregularPentagonToggle" >画不规则五边形</ label > |
122 | < input name = "type" value = "irregularHexagon" id = "irregularHexagonToggle" onclick = "toggleControl(this);" type = "radio" > |
123 | < label for = "irregularHexagonToggle" >画不规则六边形</ label > |
128 | < p >1、在地图上点击鼠标左键就可以画一个点</ p > |
129 | < p >2、在地图上点击鼠标左键开始画线的起点,继续单击左键是画转折点,双击左键则是完成画线操作</ p > |
130 | < p >3、在地图上点击鼠标左键开始画面的起点,继续单击左键是画转折点,双击左键则是完成画面操作</ p > |
131 | < p >4、按住shift键是开启自由画图模式,在画线和画面时按住shift键,同时一直按着鼠标左键在地图上移动,将绘制出鼠标移动的细节图形</ p >< p > |
http://hsjian042.blog.163.com/blog/static/176983377201161525834982/