4
<link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />
6
<script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script>
7
<script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script>
9
<script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script>
10
<script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script>
12
<script type="text/javascript">
13
// Because of a bug in Firefox 2 we need to specify the MapFish base path.
14
// See https://bugzilla.mozilla.org/show_bug.cgi?id=351282
15
var gMfLocation = "../../../../mapfish/";
17
<script type="text/javascript" src="../../../../mapfish/MapFish.js"></script>
19
<script type="text/javascript"><!--
20
function test_Map_initialize(t) {
23
var searcher, protocol;
25
protocol = new OpenLayers.Protocol();
28
searcher = new mapfish.Searcher.Map({
31
t.eq(searcher.mode, mapfish.Searcher.Map.CLICK,
32
"ctor sets mode to CLICK by default");
33
t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Click",
34
"ctor creates a click handler");
35
t.eq(searcher.protocol.CLASS_NAME, "OpenLayers.Protocol",
36
"ctor sets protocol");
39
searcher = new mapfish.Searcher.Map({
40
mode: mapfish.Searcher.Map.HOVER,
43
t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Hover",
44
"ctor creates a hover handler");
47
searcher = new mapfish.Searcher.Map({
48
mode: mapfish.Searcher.Map.BOX,
51
t.eq(searcher.handler.CLASS_NAME, "OpenLayers.Handler.Box",
52
"ctor creates a box handler");
55
searcher = new mapfish.Searcher.Map({
56
mode: mapfish.Searcher.Map.EXTENT,
59
t.eq(searcher.handler, null,
60
"ctor creates no handler");
63
function test_Map_getFilter(t) {
66
var protocol, extent, lonlat, res, searcher, filter;
68
protocol = new OpenLayers.Protocol();
69
extent = new OpenLayers.Bounds(1.0,2.0,3.0,4.0);
70
lonlat = new OpenLayers.LonLat(4.0, 5.0);
73
searcher = new mapfish.Searcher.Map({
76
getLonLatFromViewPortPx: function() {
79
getResolution: function() {
82
getExtent: function() {
89
searcher.position = new OpenLayers.Bounds(0, 0, 0, 0);
90
filter = searcher.getFilter();
91
t.eq(filter.CLASS_NAME, "OpenLayers.Filter.Spatial",
92
"getFilter returns a spatial filter");
95
searcher.position = new OpenLayers.Pixel(0, 0);
96
filter = searcher.getFilter();
97
t.eq(filter.lon, lonlat.lon,
98
"getFilter returns a object with expected lon property");
99
t.eq(filter.lat, lonlat.lat,
100
"getFilter returns a object with expected lat property");
101
t.eq(filter.tolerance, searcher.searchTolerance * res,
102
"getFilter returns a object with expected tolerance property");
105
searcher.mode = mapfish.Searcher.Map.EXTENT;
106
searcher.position = null;
107
filter = searcher.getFilter();
108
t.eq(filter.value.toBBOX(), extent.toBBOX(),
109
"getFilter computes position value if null and mode is EXTENT");