资源描述:
《OpenLayers Tutorial - Part 2 - Layers》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、OpenLayersTutorial-Part2-LayersPostedonTuesday,February022010in openlayersLayersare,basically,OpenLayer'swayofshowingdifferentmapservices.Thetermmayseemconfusingwhencombinedwithanindividualmapservice'slayerterm.ThebroadestexplanationIcanprovideforthemomentisthatan
2、 OpenLayerLayer isanobjectinsideOpenLayersthatcontainsasinglemapservice.Thisisgoingtobearatherindepthtutorial.Here'showit'ssetupPartA -URLCalls(EmphasisonWMS) PartB -LayerClassPartA-OpenLayersURLCallsInessence,OpenLayersbasicallyprovidesanicewaytoautomaticallycall
3、othermapservices,getbackalotofresults,andpiecethemtogethertoformamap.Now,foramapservicelikeGoogleMapsoravectorlayerthelogicisabitdifferent,butfortheWMSserviceandothermapservicesthatacceptaURLthisisthebasicprocess.Thismayseemabitabstract,solet'slookathowOpenLayersm
4、akesamapusingaWMSlayer.OpenLayersLayer-WMSProcessOpenLayersisbasicallycallingtheURLyouprovide,addingparameterstotheURLthatactasGETvariables(basedofftheparametersyoupassinwhenyoudefinethelayer),gettingbackanimage,andplacingalltheimagestogethercoherentlyastoformalar
5、gemapimage. Toclarify-Ifyouhaveamapdivthatis500pixelsx500pixelsbig,OpenLayerswouldmakefourseparatecallstotheURLyouprovidetogetbackfourdifferentimagesandplacethefourimagessidebysidetoformthe500x500map.(Youcouldalsojusttellittogetbackanimage500x500pixelsbig,alongwit
6、htellingittogetbackmoreimagesoutsidetheviewingareasothepanningaroundismoreseamless,etc.Wewillcoverthislater)So,withthatinmind,let'sstarttakingalookataWMSURL.http://labs.metacarta.com/wms/vmap0?request=getCapabilities&service=WMSThisistheurltogetanXMLthatcontainsde
7、tailedinformationabouttheWMSservice.Thefirstpartoftheurl, http://labs.metacarta.com/wms/vmap0 containstheactualURLyoupassintotheOpenLayersLayerurlparameter. Nextwehavea ? followedbyakey=valuepairofvariables.Ifyougototheurlwithoutpassing?request=getCapabilities&ser
8、vice=WMSyouwon'tseemuch.But,bypassingthea request of getCapabilities AND(&) a service variablewiththevalueWMS youwillgetanXMLfilewithabunchofusefulinfor