資源描述:
《OpenLayers地圖重點(diǎn)屬性摘錄》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、一:OpenLayers1.OpenLayers:常量version_number標(biāo)識(shí)版本二:BaseTypes2.BaseTypes(基本類(lèi)型):這里定制了Openlayers中用到的string、number、function、array3.Bounds(邊界):屬性left、bottom、right、top、centerLonLat方法extend用于擴(kuò)展邊界,toBBox用于綁定bounds=newOpenLayers.Bounds();bounds.extend(newOpenLayers.LonLat(4,5));bounds.extend(newOpe
2、nLayers.LonLat(5,6));bounds.toBBOX();//returns4,5,5,64.LonLat(經(jīng)緯度):屬性lon經(jīng)度、lat緯度注意:如果地圖不是地理投影,那么調(diào)用的LonLat表示的是地圖上的x、y軸坐標(biāo),為(0,0)表示坐標(biāo)軸原點(diǎn)例子:map.setCenter(newOpenLayers.LonLat(116.3876,39.8983),13);最后一個(gè)參數(shù)表示Zoom:放大倍數(shù)5.Pixel(像素):屬性x、y表示x和y坐標(biāo)6.Size:屬性w、h表示寬和高三:Console7.Console:用于調(diào)試和把錯(cuò)誤等輸出到“控制臺(tái)
3、”上,需要結(jié)合使用firebug四:Control8.Control(控件):使用方法:方法一:varmap=newOpenLayers.Map('map',{controls:[]});map.addControl(newOpenLayers.Control.PanZoomBar());方法二:varmap=newOpenLayers.Map('map',{controls:[newOpenLayers.Control.PanZoomBar(),newOpenLayers.Control.Navigation()]});9.Button(按鈕):方法trigger
4、()點(diǎn)擊按鈕的時(shí)候會(huì)調(diào)用使用方法:varbutton=newOpenLayers.Control.Button({??displayClass:"MyButton",trigger:myFunction});panel.addControls([button]);1.DragPan(鼠標(biāo)拖動(dòng)地圖)2.DrawFeature(在矢量圖上畫(huà)點(diǎn)、線、面)varlines=newOpenLayers.Layer.Vector("Lines",{styleMap:newOpenLayers.StyleMap({pointRadius:3,strokeColor:"#ff330
5、0",strokeWidth:3,fillOpacity:0})});varpanel=newOpenLayers.Control.Panel({displayClass:"olControlEditingToolbar"});vardraw=newOpenLayers.Control.DrawFeature(lines,OpenLayers.Handler.Path,{displayClass:"olControlDrawFeaturePath",title:"DrawLines"});panel.addControls([newOpenLayers.Contro
6、l.Navigation({title:"Navigate"}),draw]);map.addControl(panel);3.EditingToolbar(編輯工具條)EditingToolbar包含4個(gè)控件:drawpoint、drawlines、drawpolygon、pannavigation構(gòu)造函數(shù)參數(shù):layer(Openlayer.Layer.Vector)、options例子:varvector=newOpenLayers.Layer.Vector("EditableVectors");map.addLayers([vector]);map.addC
7、ontrol(newOpenLayers.Control.EditingToolbar(vector));4.Geolocate(地理定位)把w3cgeolocationAPI包裝成控件,與地圖綁定,位置發(fā)生變化時(shí)觸發(fā)事件5.GetFeature6.Graticule(格子線)在地圖上以grid顯示經(jīng)緯線7.KeyboardDefaults:增加了用鍵盤(pán)實(shí)現(xiàn)平移縮放功能map.addControl(newOpenLayers.Control.KeyboardDefaults());8.LayerSwitcher(圖層切換功能)map.addControl(new