[OpenLayers-Users] [Idea] Declaratively defining an OL map

Erdal Karaca erdal.karaca.de at gmail.com
Wed Feb 27 13:05:04 PST 2013


Hi all,
I think most of the OL API could be used in a "declarative way".

Let us have a look at a simple example to understand what I mean:
http://openlayers.org/dev/examples/markers.html

That example uses JavaScript to code the map (adding layers, markers, etc.).
A declarative way of achieving the same result might look like this:

<Map id="map" zoomToMaxExtent="true">
	<center>
		<LonLat lon="0" lat="0" />
	</center>
	<layers>
		<WMS name="OpenLayers WMS"
url="http://vmap0.tiles.osgeo.org/wms/vmap0" layers="basic" />
		<Text name="text" location="./textfile.txt" />
		<Markers name="Markers">
			<Marker>
				<position>
					<LonLat lon="0" lat="0" />
				</position>
				<icon>
					<Icon id="reusableIcon" url="http://www.openlayers.org/dev/img/marker.png">
						<size>
							<Size w="21" h="25" />
						</size>
						<offset>
							<Pixel x="-10" y="-12" />
						</offset>
					</Icon>
				</icon>
			</Marker>
			<Marker>
				<position>
					<LonLat lon="0" lat="45" />
				</position>
				<icon reuseClone="reusableIcon" />
			</Marker>
			<Marker opacity="0.2">
				<position>
					<LonLat lon="90" lat="10" />
				</position>
				<icon reuseClone="reusableIcon" />
			</Marker>
		</Markers>
	<layers>
	<controls>
		<LayerSwitcher />
	</controls>
</Map>

Anyone else thought in that direction? Would that be a candidate
feature for OL3?

Best regards,
Erdal


More information about the Users mailing list