1 |
<?php |
---|
2 |
/** |
---|
3 |
* Panmap Widget class |
---|
4 |
* |
---|
5 |
* @project CWC2 |
---|
6 |
* @revision $Id: PanMap.widget.php,v 1.11 2005/05/16 12:10:47 bartvde Exp $ |
---|
7 |
* @purpose Pan Map Widget class |
---|
8 |
* @author DM Solutions Group (assefa@dmsolutions.ca) |
---|
9 |
* @copyright |
---|
10 |
* <b>Copyright (c) 2002, DM Solutions Group Inc.</b> |
---|
11 |
* Permission is hereby granted, free of charge, to any person obtaining a |
---|
12 |
* copy of this software and associated documentation files (the "Software"), |
---|
13 |
* to deal in the Software without restriction, including without limitation |
---|
14 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
15 |
* and/or sell copies of the Software, and to permit persons to whom the |
---|
16 |
* Software is furnished to do so, subject to the following conditions: |
---|
17 |
* |
---|
18 |
* The above copyright notice and this permission notice shall be included |
---|
19 |
* in all copies or substantial portions of the Software. |
---|
20 |
* |
---|
21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
22 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
24 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
27 |
* DEALINGS IN THE SOFTWARE. |
---|
28 |
*/ |
---|
29 |
|
---|
30 |
|
---|
31 |
include_once(dirname(__FILE__)."/../NavTool.php"); |
---|
32 |
|
---|
33 |
/** |
---|
34 |
* PanMapWidget |
---|
35 |
* |
---|
36 |
* @desc PanMap widget. |
---|
37 |
*/ |
---|
38 |
class PanMap extends NavTool |
---|
39 |
{ |
---|
40 |
var $mszImagePath = "images/tool_pan.gif"; |
---|
41 |
var $mszImageSelectedPath = "images/tool_pan.gif"; |
---|
42 |
var $mszImageTip = "Pan"; |
---|
43 |
|
---|
44 |
/** |
---|
45 |
* PanMap |
---|
46 |
* |
---|
47 |
* Constructor. Set the default values. |
---|
48 |
*/ |
---|
49 |
function PanMap() |
---|
50 |
{ |
---|
51 |
// invoke constructor of parent |
---|
52 |
parent::NavTool(); |
---|
53 |
|
---|
54 |
$this->SetNavCommand("PAN_MAP"); |
---|
55 |
|
---|
56 |
// set the description for this widget |
---|
57 |
$this->szWidgetDescription = <<<EOT |
---|
58 |
The PanMap widget is a navigation tool that allows the user to drag the |
---|
59 |
map image to recenter it at a given location. |
---|
60 |
EOT; |
---|
61 |
$this->mnMaturityLevel = MATURITY_TECHNICALRELEASE; |
---|
62 |
$this->mbNavSubmit = false; |
---|
63 |
} |
---|
64 |
|
---|
65 |
|
---|
66 |
/** |
---|
67 |
* ParseURL |
---|
68 |
* |
---|
69 |
* Look for the PAN_MAP command and if found do the panning |
---|
70 |
* according to the other NAV paramaters. |
---|
71 |
*/ |
---|
72 |
function ParseURL() |
---|
73 |
{ |
---|
74 |
parent::ParseURL(); |
---|
75 |
|
---|
76 |
$szCmd = ""; |
---|
77 |
if ($this->isVarSet( "NAV_CMD" )) |
---|
78 |
$szCmd = $this->getVar( "NAV_CMD" ); |
---|
79 |
|
---|
80 |
if ($szCmd == "PAN_MAP" && $this->getVar( "NAV_INPUT_COORDINATES" )!="") |
---|
81 |
{ |
---|
82 |
$poMap = $this->moMapObject->oMap; |
---|
83 |
|
---|
84 |
$szInputCoords = $this->getVar( "NAV_INPUT_COORDINATES" ); |
---|
85 |
$aPixPos = explode(";", $szInputCoords); |
---|
86 |
$aPixFirst = explode(",", $aPixPos[0]); |
---|
87 |
$aPixLast = explode(",", $aPixPos[1]); |
---|
88 |
|
---|
89 |
$nShiftPixX = $aPixLast[0] - $aPixFirst[0]; |
---|
90 |
$nShiftPixY = $aPixFirst[1] - $aPixLast[1]; |
---|
91 |
|
---|
92 |
$dfShiftWidth = $nShiftPixX/$poMap->width; |
---|
93 |
$dfShiftHeight = $nShiftPixY/$poMap->height; |
---|
94 |
|
---|
95 |
//echo "firstpoint x =" . $aPixFirst[0] . " and last point x = ". $aPixLast[0]; |
---|
96 |
//echo "firstpoint y =" . $aPixFirst[1] . " and last point y = ". $aPixLast[1]; |
---|
97 |
//echo " delata pixx=$nShiftPixX and shift pixel x $dfShiftWidth <br>\n"; |
---|
98 |
|
---|
99 |
$dfDeltaGeoWidth = $poMap->extent->maxx - $poMap->extent->minx; |
---|
100 |
$dfDeltaGeoHeight = $poMap->extent->maxy - $poMap->extent->miny; |
---|
101 |
|
---|
102 |
$dfShiftGeoX = $dfShiftWidth * $dfDeltaGeoWidth; |
---|
103 |
$dfShiftGeoY = $dfShiftHeight * $dfDeltaGeoHeight; |
---|
104 |
$dfShiftGeoX = abs($dfShiftGeoX); |
---|
105 |
$dfShiftGeoY = abs($dfShiftGeoY); |
---|
106 |
//echo "shift geo x $dfShiftGeoX <br>\n"; |
---|
107 |
|
---|
108 |
$bInvalid = 0; |
---|
109 |
if ($aPixFirst[0] < $aPixLast[0]) |
---|
110 |
{ |
---|
111 |
//echo "first x < last x <br>"; |
---|
112 |
$dfGeoMinX = $poMap->extent->minx - $dfShiftGeoX; |
---|
113 |
$dfGeoMaxX = $poMap->extent->maxx - $dfShiftGeoX; |
---|
114 |
} |
---|
115 |
else if ($aPixFirst[0] > $aPixLast[0]) |
---|
116 |
{ |
---|
117 |
//echo "first x > last x <br>"; |
---|
118 |
|
---|
119 |
$dfGeoMinX = $poMap->extent->minx + $dfShiftGeoX; |
---|
120 |
$dfGeoMaxX = $poMap->extent->maxx + $dfShiftGeoX; |
---|
121 |
} |
---|
122 |
else |
---|
123 |
$bInvalid = 1; |
---|
124 |
|
---|
125 |
if ($aPixFirst[1] > $aPixLast[1]) |
---|
126 |
{ |
---|
127 |
//echo "first y > last y <br>"; |
---|
128 |
|
---|
129 |
$dfGeoMinY = $poMap->extent->miny - $dfShiftGeoY; |
---|
130 |
$dfGeoMaxY = $poMap->extent->maxy - $dfShiftGeoY; |
---|
131 |
} |
---|
132 |
else if ($aPixFirst[1] < $aPixLast[1]) |
---|
133 |
{ |
---|
134 |
//echo "first y < last y <br>"; |
---|
135 |
$dfGeoMinY = $poMap->extent->miny + $dfShiftGeoY; |
---|
136 |
$dfGeoMaxY = $poMap->extent->maxy + $dfShiftGeoY; |
---|
137 |
} |
---|
138 |
else |
---|
139 |
$bInvalid = 1; |
---|
140 |
|
---|
141 |
if (!$bInvalid) |
---|
142 |
{ |
---|
143 |
$poMap->setextent($dfGeoMinX, $dfGeoMinY, $dfGeoMaxX, $dfGeoMaxY); |
---|
144 |
/* -------------------------------------------------------------------- */ |
---|
145 |
/* Call the reporjectauto function in case the map projection */ |
---|
146 |
/* is set to AUTO:XXX. If it is not, the function will do */ |
---|
147 |
/* nothing. */ |
---|
148 |
/* -------------------------------------------------------------------- */ |
---|
149 |
$this->ReprojectAuto(); |
---|
150 |
} |
---|
151 |
/* -------------------------------------------------------------------- */ |
---|
152 |
/* If first and last points are the same, do nothing. The user */ |
---|
153 |
/* should alreay have been notfied (alert using js) when this */ |
---|
154 |
/* problem occured. So do not send an error message (Bug 2036). */ |
---|
155 |
/* -------------------------------------------------------------------- */ |
---|
156 |
//else |
---|
157 |
//$_SESSION['gErrorManager']->setError(ERR_WARNING, "When using the PanMap Widget, you should click, hold the mouse down and drag."); |
---|
158 |
} |
---|
159 |
return true; |
---|
160 |
|
---|
161 |
} |
---|
162 |
|
---|
163 |
/** |
---|
164 |
* GetJavascriptIncludeFunctions |
---|
165 |
* |
---|
166 |
*/ |
---|
167 |
function GetJavascriptIncludeFunctions() |
---|
168 |
{ |
---|
169 |
$aReturn = array(); |
---|
170 |
|
---|
171 |
$szJsIncludeName = $_SESSION["gszCoreWebPath"]."/widgets/js/dynlayer.js"; |
---|
172 |
$szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/dynlayer.js\" type=\"text/javascript\"></script>"; |
---|
173 |
$aReturn[$szJsIncludeName] = $szInclude; |
---|
174 |
|
---|
175 |
|
---|
176 |
$szJsIncludeName = $_SESSION["gszCoreWebPath"]."/widgets/js/drag.js"; |
---|
177 |
$szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/drag.js\" type=\"text/javascript\"></script>"; |
---|
178 |
$aReturn[$szJsIncludeName] = $szInclude; |
---|
179 |
|
---|
180 |
return $aReturn; |
---|
181 |
} |
---|
182 |
|
---|
183 |
/** |
---|
184 |
* GetJavascriptOnMouseMoveFunctions |
---|
185 |
* |
---|
186 |
* Returns functions to be called on mouse mouve event. |
---|
187 |
*/ |
---|
188 |
function GetJavascriptOnMouseMoveFunctions() |
---|
189 |
{ |
---|
190 |
$aReturn = array(); |
---|
191 |
$szJsFunctionName = "PanMapWMouseMove"; |
---|
192 |
$szFunction = "$szJsFunctionName(e);\n"; |
---|
193 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
194 |
|
---|
195 |
return $aReturn; |
---|
196 |
} |
---|
197 |
|
---|
198 |
|
---|
199 |
/** |
---|
200 |
* GetJavascriptOnMouseUpFunctions |
---|
201 |
* |
---|
202 |
*/ |
---|
203 |
function GetJavascriptOnMouseUpFunctions2() |
---|
204 |
{ |
---|
205 |
$aReturn = array(); |
---|
206 |
$szJsFunctionName = "PanMapWMouseUp"; |
---|
207 |
$szFunction = "$szJsFunctionName(e);\n"; |
---|
208 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
209 |
|
---|
210 |
return $aReturn; |
---|
211 |
} |
---|
212 |
|
---|
213 |
/** |
---|
214 |
* GetJavascriptOnMouseDownFunctions |
---|
215 |
* |
---|
216 |
*/ |
---|
217 |
function GetJavascriptOnMouseDownFunctions2() |
---|
218 |
{ |
---|
219 |
$aReturn = array(); |
---|
220 |
$szJsFunctionName = "PanMapWMouseDown"; |
---|
221 |
$szFunction = "$szJsFunctionName(e);\n"; |
---|
222 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
223 |
|
---|
224 |
return $aReturn; |
---|
225 |
} |
---|
226 |
|
---|
227 |
|
---|
228 |
/** |
---|
229 |
* GetJavascriptFunctions |
---|
230 |
* |
---|
231 |
* Return the JS function associated with the pan. |
---|
232 |
*/ |
---|
233 |
function GetJavascriptFunctions() |
---|
234 |
{ |
---|
235 |
$aReturn = array(); |
---|
236 |
$aReturn = parent::GetJavascriptFunctions(); |
---|
237 |
|
---|
238 |
$poMap = $this->moMapObject->oMap; |
---|
239 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
240 |
$bCWCJSAPI = 1; |
---|
241 |
else |
---|
242 |
$bCWCJSAPI = 0; |
---|
243 |
|
---|
244 |
$szJsFunctionName = "PanMapWInit"; |
---|
245 |
$szFunction = <<<EOT |
---|
246 |
/** |
---|
247 |
* {$szJsFunctionName} |
---|
248 |
* called to initialize the pan widget. |
---|
249 |
*/ |
---|
250 |
function {$szJsFunctionName}(e) |
---|
251 |
{ |
---|
252 |
//DynLayerInit(); |
---|
253 |
maplayer = new DynLayer("MapLayerDiv"); |
---|
254 |
drag.add(maplayer); |
---|
255 |
//alert(maplayer); |
---|
256 |
if (is.ie5) |
---|
257 |
maplayer.clipInit(0,{$poMap->width}, {$poMap->height},0); |
---|
258 |
|
---|
259 |
// for other browsers it's not necessary because the layer in this example |
---|
260 |
// is clipped to defaults so I don't have to pass clip values |
---|
261 |
else |
---|
262 |
maplayer.clipInit(); |
---|
263 |
|
---|
264 |
//initMouseEvents(); |
---|
265 |
|
---|
266 |
} |
---|
267 |
|
---|
268 |
EOT; |
---|
269 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
270 |
|
---|
271 |
$szJsFunctionName = "PanMapWMouseMove"; |
---|
272 |
$szFunction = <<<EOT |
---|
273 |
/** |
---|
274 |
* {$szJsFunctionName} |
---|
275 |
* called when the mouse moves for the PanMap widget. |
---|
276 |
*/ |
---|
277 |
function {$szJsFunctionName}(e) |
---|
278 |
{ |
---|
279 |
|
---|
280 |
//make sure that the forms varaibales are initialized. |
---|
281 |
//It seems like that in IE, the mouse move may be called before. |
---|
282 |
if({$this->mszHTMLForm} == null || |
---|
283 |
{$this->mszHTMLForm}.NAV_CMD == null || |
---|
284 |
{$this->mszHTMLForm}.NAV_CMD.value != "PAN_MAP") |
---|
285 |
return true; |
---|
286 |
|
---|
287 |
if (!MapWinsideMap() ) |
---|
288 |
{ |
---|
289 |
if (document.onmousedown == PanMapWMouseDown) |
---|
290 |
document.onmousedown = null; |
---|
291 |
if (document.onmouseup == PanMapWMouseUp) |
---|
292 |
document.onmouseup = null; |
---|
293 |
return true; |
---|
294 |
} |
---|
295 |
|
---|
296 |
|
---|
297 |
document.onmousedown = PanMapWMouseDown; |
---|
298 |
document.onmouseup = PanMapWMouseUp; |
---|
299 |
|
---|
300 |
var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft; |
---|
301 |
var y = (is.ns)? e.pageY : event.y+document.body.scrollTop; |
---|
302 |
if (is.ns && e.target!=document) |
---|
303 |
routeEvent(e); |
---|
304 |
|
---|
305 |
drag.mouseMove(x,y); |
---|
306 |
return true;; |
---|
307 |
|
---|
308 |
} |
---|
309 |
EOT; |
---|
310 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
311 |
|
---|
312 |
$szJsFunctionName = "PanMapWMouseUp"; |
---|
313 |
$szFunction = <<<EOT |
---|
314 |
/** |
---|
315 |
* {$szJsFunctionName} |
---|
316 |
* called when the mouse up for the PanMap widget. |
---|
317 |
*/ |
---|
318 |
function {$szJsFunctionName}(e) |
---|
319 |
{ |
---|
320 |
if({$this->mszHTMLForm}.NAV_CMD.value != "PAN_MAP") |
---|
321 |
return true; |
---|
322 |
|
---|
323 |
var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft; |
---|
324 |
var y = (is.ns)? e.pageY : event.y+document.body.scrollTop; |
---|
325 |
if (is.ns && e.target!=document) |
---|
326 |
routeEvent(e); |
---|
327 |
drag.mouseUp(x,y); |
---|
328 |
return true; |
---|
329 |
} |
---|
330 |
EOT; |
---|
331 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
332 |
|
---|
333 |
$szJsFunctionName = "PanMapWMouseDown"; |
---|
334 |
$szFunction = <<<EOT |
---|
335 |
/** |
---|
336 |
* {$szJsFunctionName} |
---|
337 |
* called when the mouse down for the PanMap widget. |
---|
338 |
*/ |
---|
339 |
function {$szJsFunctionName}(e) |
---|
340 |
{ |
---|
341 |
if({$this->mszHTMLForm}.NAV_CMD.value != "PAN_MAP") |
---|
342 |
return true; |
---|
343 |
|
---|
344 |
if ((is.ns && e.which!=1) || (is.ie && event.button!=1)) |
---|
345 |
return true; |
---|
346 |
var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft; |
---|
347 |
var y = (is.ns)? e.pageY : event.y+document.body.scrollTop; |
---|
348 |
if (is.ns && e.target!=document) |
---|
349 |
routeEvent(e); |
---|
350 |
drag.mouseDown(x,y); |
---|
351 |
return false; |
---|
352 |
|
---|
353 |
} |
---|
354 |
EOT; |
---|
355 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
356 |
|
---|
357 |
$szErrorMsg = $this->moMLT->get("0", "When using the PanMap Widget, you should click on the map, hold the mouse down and then drag."); |
---|
358 |
|
---|
359 |
$szJsFunctionName = "PanMapWDragEnd"; |
---|
360 |
$szFunction = <<<EOT |
---|
361 |
/** |
---|
362 |
* {$szJsFunctionName} |
---|
363 |
* called when the drag ends in PanMap widget. |
---|
364 |
*/ |
---|
365 |
function {$szJsFunctionName}(x,y) |
---|
366 |
{ |
---|
367 |
var nLastPointX = 0; |
---|
368 |
var nLastPointY = 0; |
---|
369 |
|
---|
370 |
if (x > (gMapWhspc + gMapWiWidth)) |
---|
371 |
nLastPoinX = gMapWiWidth; |
---|
372 |
else if (x < gMapWhspc) |
---|
373 |
nLastPointX = 0; |
---|
374 |
else |
---|
375 |
nLastPointX = gMapWmouseX; |
---|
376 |
|
---|
377 |
if (y > (gMapWvspc + gMapWiHeight)) |
---|
378 |
nLastPointY = gMapWiHeight; |
---|
379 |
else if (y < gMapWvspc) |
---|
380 |
nLastPointY = 0; |
---|
381 |
else |
---|
382 |
nLastPointY = gMapWmouseY; |
---|
383 |
|
---|
384 |
nFirstPointX = gnPanWFirstPointX; |
---|
385 |
nFirstPointY = gnPanWFirstPointY; |
---|
386 |
|
---|
387 |
|
---|
388 |
var szCoord = ""+ gnPanWFirstPointX + "," + gnPanWFirstPointY + ";" + nLastPointX + "," + nLastPointY; |
---|
389 |
//alert(szCoord); |
---|
390 |
{$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; |
---|
391 |
{$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "RECTANGLE"; |
---|
392 |
if ({$bCWCJSAPI}) |
---|
393 |
{ |
---|
394 |
goCWCJSAPI.NAV_INPUT_COORDINATES = szCoord; |
---|
395 |
goCWCJSAPI.NAV_INPUT_TYPE = "RECTANGLE"; |
---|
396 |
} |
---|
397 |
|
---|
398 |
if (gnPanWFirstPointX == nLastPointX && gnPanWFirstPointY == nLastPointY) |
---|
399 |
{ |
---|
400 |
//alert("{$szErrorMsg}"); |
---|
401 |
} |
---|
402 |
else |
---|
403 |
{ |
---|
404 |
if ({$bCWCJSAPI}) |
---|
405 |
goCWCJSAPI.UpdateNavTools(); |
---|
406 |
else |
---|
407 |
{$this->mszHTMLForm}.submit(); |
---|
408 |
} |
---|
409 |
} |
---|
410 |
EOT; |
---|
411 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
412 |
|
---|
413 |
|
---|
414 |
$szJsFunctionName = "PanMapWDragStart"; |
---|
415 |
$szFunction = <<<EOT |
---|
416 |
/** |
---|
417 |
* {$szJsFunctionName} |
---|
418 |
* called when the drag starts in PanMap widget. |
---|
419 |
*/ |
---|
420 |
function {$szJsFunctionName}(x,y) |
---|
421 |
{ |
---|
422 |
//if (gnPanWFirstPointX < 0 && gnPanWFirstPointY < 0) |
---|
423 |
//{ |
---|
424 |
gnPanWFirstPointX = gMapWmouseX; |
---|
425 |
gnPanWFirstPointY = gMapWmouseY; |
---|
426 |
//} |
---|
427 |
//alert(gnPanWFirstPointX); |
---|
428 |
|
---|
429 |
} |
---|
430 |
EOT; |
---|
431 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
432 |
|
---|
433 |
if ($bCWCJSAPI) |
---|
434 |
{ |
---|
435 |
$szJsFunctionName = "PanMapWRegisterForEvent"; |
---|
436 |
$szFunction = <<<EOT |
---|
437 |
/** |
---|
438 |
* {$szJsFunctionName} |
---|
439 |
* called to register and even when the map extents chnages (JSAPI) |
---|
440 |
*/ |
---|
441 |
function {$szJsFunctionName}() |
---|
442 |
{ |
---|
443 |
goCWCJSAPI.RegisterEvent(MAP_EXTENT_CHANGED, "PanMapWMapExtentsChanged"); |
---|
444 |
} |
---|
445 |
EOT; |
---|
446 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
447 |
|
---|
448 |
|
---|
449 |
$szJsFunctionName = "PanMapWMapExtentsChanged"; |
---|
450 |
$szFunction = <<<EOT |
---|
451 |
/** |
---|
452 |
* {$szJsFunctionName} |
---|
453 |
* called when the mapextents are changed to update the scalebar images(JSAPI) |
---|
454 |
*/ |
---|
455 |
function {$szJsFunctionName}() |
---|
456 |
{ |
---|
457 |
//maplayer = new DynLayer("MapLayerDiv"); |
---|
458 |
//drag.remove(maplayer); |
---|
459 |
//drag.add(maplayer); |
---|
460 |
//alert(maplayer); |
---|
461 |
if (is.ie5) |
---|
462 |
maplayer.clipInit(0,{$poMap->width}, {$poMap->height},0); |
---|
463 |
|
---|
464 |
// for other browsers it's not necessary because the layer in this example |
---|
465 |
// is clipped to defaults so I don't have to pass clip values |
---|
466 |
else |
---|
467 |
maplayer.clipInit(); |
---|
468 |
|
---|
469 |
maplayer.moveTo(gMapWhspc, gMapWvspc); |
---|
470 |
|
---|
471 |
maplayer.clipTo(0,gMapWiWidth,gMapWiHeight,0); |
---|
472 |
var layerminX = maplayer.x; |
---|
473 |
var layerminY = maplayer.y; |
---|
474 |
|
---|
475 |
|
---|
476 |
var layermaxX = layerminX + gMapWiWidth; |
---|
477 |
var layermaxY = layerminY + gMapWiHeight; |
---|
478 |
var clipval = 0; |
---|
479 |
|
---|
480 |
if (0) |
---|
481 |
{ |
---|
482 |
var ttt = "minx="+layerminX+" ,minY="+layerminY+", maxx="+layermaxX+", maxy="+layermaxY; |
---|
483 |
alert(ttt); |
---|
484 |
ttt = "gMapWhspc="+gMapWhspc+" ,gMapWvspc="+gMapWvspc; |
---|
485 |
alert(ttt); |
---|
486 |
} |
---|
487 |
//gttt++; |
---|
488 |
if (layerminX <= gMapWhspc) |
---|
489 |
{ |
---|
490 |
//alert("clip minx"); |
---|
491 |
clipval = gMapWhspc - layerminX; |
---|
492 |
maplayer.clipBy(0,0,0,clipval); |
---|
493 |
} |
---|
494 |
|
---|
495 |
if (layerminY <= gMapWvspc) |
---|
496 |
{ |
---|
497 |
//alert("clip miny"); |
---|
498 |
clipval = gMapWvspc - layerminY; |
---|
499 |
maplayer.clipBy(clipval, 0,0,0); |
---|
500 |
} |
---|
501 |
|
---|
502 |
if (layermaxX >= (gMapWhspc + gMapWiWidth) ) |
---|
503 |
{ |
---|
504 |
//alert("clip maxx"); |
---|
505 |
var clipval = (gMapWhspc + gMapWiWidth) - layermaxX; |
---|
506 |
maplayer.clipBy(0,clipval, 0, 0); |
---|
507 |
} |
---|
508 |
|
---|
509 |
if (layermaxY > (gMapWvspc + gMapWiHeight) ) |
---|
510 |
{ |
---|
511 |
//alert("clip maxy"); |
---|
512 |
var clipval = (gMapWvspc + gMapWiHeight) - layermaxY; |
---|
513 |
maplayer.clipBy(0,0,clipval, 0); |
---|
514 |
} |
---|
515 |
|
---|
516 |
//drag.obj.moveTo(gMapWhspc, gMapWvspc); |
---|
517 |
|
---|
518 |
|
---|
519 |
//MapWshowLayer("MapLayerDiv"); |
---|
520 |
|
---|
521 |
} |
---|
522 |
EOT; |
---|
523 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
524 |
|
---|
525 |
}//end of js api |
---|
526 |
|
---|
527 |
return $aReturn; |
---|
528 |
} |
---|
529 |
|
---|
530 |
|
---|
531 |
|
---|
532 |
/** |
---|
533 |
* GetJavascriptVariables. |
---|
534 |
* |
---|
535 |
*/ |
---|
536 |
function GetJavascriptVariables() |
---|
537 |
{ |
---|
538 |
$aReturn = array(); |
---|
539 |
|
---|
540 |
$aReturn = parent::GetJavascriptVariables(); |
---|
541 |
|
---|
542 |
$szVariable = "gnPanWFirstPointX"; |
---|
543 |
$szValue = " var $szVariable = -1;\n"; |
---|
544 |
$aReturn[$szVariable] = $szValue; |
---|
545 |
|
---|
546 |
$szVariable = "gnPanWFirstPointY"; |
---|
547 |
$szValue = " var $szVariable = -1;\n"; |
---|
548 |
$aReturn[$szVariable] = $szValue; |
---|
549 |
|
---|
550 |
return $aReturn; |
---|
551 |
} |
---|
552 |
|
---|
553 |
/** |
---|
554 |
* GetJavascriptOnLoadFunctions |
---|
555 |
* |
---|
556 |
* Should be redefined for Widgets returning Javascript code. |
---|
557 |
* |
---|
558 |
* @returns Empty string. |
---|
559 |
*/ |
---|
560 |
function GetJavascriptOnLoadFunctions() |
---|
561 |
{ |
---|
562 |
$aReturn = array(); |
---|
563 |
|
---|
564 |
$aReturn = parent::GetJavascriptOnLoadFunctions(); |
---|
565 |
|
---|
566 |
$szJsFunctionName = "PanMapWInit"; |
---|
567 |
$szFunction = "$szJsFunctionName();\n"; |
---|
568 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
569 |
|
---|
570 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
571 |
{ |
---|
572 |
$szJsFunctionName = "PanMapWRegisterForEvent"; |
---|
573 |
$szFunction = "$szJsFunctionName();\n"; |
---|
574 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
575 |
} |
---|
576 |
|
---|
577 |
return $aReturn; |
---|
578 |
} |
---|
579 |
|
---|
580 |
} |
---|
581 |
?> |
---|