1 | var lon = 5; |
---|
2 | var lat = 40; |
---|
3 | var zoom = 5; |
---|
4 | var map, layer; |
---|
5 | |
---|
6 | function init() { |
---|
7 | map = new OpenLayers.Map( 'map', { controls: [] } ); |
---|
8 | layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", |
---|
9 | "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} ); |
---|
10 | map.addLayer(layer); |
---|
11 | |
---|
12 | vlayer = new OpenLayers.Layer.Vector( "Editable" ); |
---|
13 | map.addLayer(vlayer); |
---|
14 | |
---|
15 | zb = new OpenLayers.Control.ZoomBox({ |
---|
16 | title: "Zoom box: zoom clicking and dragging", |
---|
17 | text: "Zoom" |
---|
18 | }); |
---|
19 | |
---|
20 | var panel = new OpenLayers.Control.Panel({ |
---|
21 | defaultControl: zb, |
---|
22 | createControlMarkup: function(control) { |
---|
23 | var button = document.createElement('button'), |
---|
24 | iconSpan = document.createElement('span'), |
---|
25 | textSpan = document.createElement('span'); |
---|
26 | iconSpan.innerHTML = ' '; |
---|
27 | button.appendChild(iconSpan); |
---|
28 | if (control.text) { |
---|
29 | textSpan.innerHTML = control.text; |
---|
30 | } |
---|
31 | button.appendChild(textSpan); |
---|
32 | return button; |
---|
33 | } |
---|
34 | }); |
---|
35 | |
---|
36 | panel.addControls([ |
---|
37 | zb, |
---|
38 | new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path, |
---|
39 | {title:'Draw a feature', text: 'Draw'}), |
---|
40 | new OpenLayers.Control.ZoomToMaxExtent({ |
---|
41 | title:"Zoom to the max extent", |
---|
42 | text: "World" |
---|
43 | }) |
---|
44 | ]); |
---|
45 | |
---|
46 | nav = new OpenLayers.Control.NavigationHistory({ |
---|
47 | previousOptions: { |
---|
48 | title: "Go to previous map position", |
---|
49 | text: "Prev" |
---|
50 | }, |
---|
51 | nextOptions: { |
---|
52 | title: "Go to next map position", |
---|
53 | text: "Next" |
---|
54 | }, |
---|
55 | displayClass: "navHistory" |
---|
56 | }); |
---|
57 | // parent control must be added to the map |
---|
58 | map.addControl(nav); |
---|
59 | panel.addControls([nav.next, nav.previous]); |
---|
60 | |
---|
61 | map.addControl(panel); |
---|
62 | |
---|
63 | map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); |
---|
64 | } |
---|