Application Development in Web Mapping 4., Web Mapping Client | Digitális Tankönyvtár

OpenLayers (OL) is a JavaScript web mapping library, similar to Google Maps API. OpenLayers is open source and free used in OpenStreetMap and Mapfish projects, for example. It was created by MetaCarta and released as open source in 2006. The library can be downloaded from OpenLayers homepage[9], it contains several examples. When you develop an application you have to put the library files in your application directory where the library is available from the application. In an OpenLayers client the OpenLayers.Map[10] object is the map viewer. It has several properties to store information about: layers, base layer, tile size, projection, units, resolutions, scales, extents, zoom levels and so on. It has functions to handle these properties, for example addLayer(). A layer is a data source object. OpenLayers.Layer[11] has subclasses for different datasources, for example: Layers have types, base layers and overlays. Base layer is a layer which is displayed in the viewer and determines the projection and zoom level. There is only one base layer in a given time. Base layers are typically raster layers. Overlay layers can be enabled or disabled at certain scale or resolution. Multiple overlay layers can be displayed at a time. Overlay layers display above thebase layer. OpenLayers.Control.EditingToolbar is to draw polygons, lines, points, or to navigate the map by panning. OpenLayers.Control.NavigationHistory creates previous and next controls to restore previous and next history states. OpenLayers.Control.LayerSwitcher displays a table of contents for the map. This allows the user interface to switch between BaseLayers and to show or hide Overlays OpenLayers supports styling vector features[13]. An OpenLayers.Style can be built from filters, symbolizers and rules. A symbolizer hash contains key/value pairs to set the display of features. Filter object selects a set of features. Rule object groups filters and symbolizers. OpenLayers.StyleMap object can contain more Style objects, allows to apply style in a certain context. For example the style of a feature can be different if it is selected or unselected. The map variable is a new Map object. Its parameter is the id of the <,div>, tag within the map will be displayed. The center of the map is given in WGS 84 coordinates therefore it should be transformed to Spherical Mercator projection. In <,body>, when the page is loaded into the browser the init() function is called and the map is displayed in <,div>, tag. A new vector layer was declared and added to map with addLayer() method in an array with the former map. Changing the default controls the formerly default PanZoom and the Editing Toolbar was added to the map. [10] OpenLayers.Map: http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Map-js.html [11] OpenLayers.Layer: http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Layer-js.html [12] OpenLayers.Control: http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Control-js.html [13] OpenGeo, Understanding style: http://workshops.opengeo.org/openlayers-intro/vector/style-intro.html Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 18, 2016 @ 10:12 am