3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_initialize(t) {
9 control = new OpenLayers.Control.OverviewMap();
10 t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
11 t.eq( control.displayClass, "olControlOverviewMap", "displayClass is correct" );
13 function test_addControl (t) {
15 map = new OpenLayers.Map('map');
16 control = new OpenLayers.Control.OverviewMap();
17 t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
18 t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
19 map.addControl(control);
20 t.ok( control.map === map, "Control.map is set to the map object" );
21 t.ok( map.controls[4] === control, "map.controls contains control" );
22 t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Control div zIndexed properly" );
23 t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div" );
27 function test_control_events (t) {
29 var evt = {which: 1}; // control expects left-click
30 map = new OpenLayers.Map('map');
31 var layer = new OpenLayers.Layer.WMS("Test Layer",
32 "http://octo.metacarta.com/cgi-bin/mapserv?",
33 {map: "/mapdata/vmap_wms.map", layers: "basic"});
36 control = new OpenLayers.Control.OverviewMap();
37 map.addControl(control, new OpenLayers.Pixel(20,20));
39 var centerLL = new OpenLayers.LonLat(-71,42);
40 map.setCenter(centerLL, 11);
41 t.delay_call(1, function() {
42 var overviewCenter = control.ovmap.getCenter();
43 var overviewZoom = control.ovmap.getZoom();
44 t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
45 t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
46 t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
48 control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
50 var cent = map.getCenter();
51 t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
52 t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
54 control.handlers.drag = {
55 last: new OpenLayers.Pixel(5,5),
56 destroy: function() {}
58 control.rectDrag(new OpenLayers.Pixel(15, 15));
59 control.updateMapToRect();
61 var cent = map.getCenter();
62 t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
63 t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
65 map.setCenter(new OpenLayers.LonLat(0,0), 0);
66 var overviewCenter = control.ovmap.getCenter();
67 var overviewZoom = control.ovmap.getZoom();
68 t.eq(overviewCenter.lon, 0, "Overviewmap center lon correct -- second zoom");
69 t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom");
70 t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom");
78 <div id="map" style="width: 1024px; height: 512px;"/>