Compare commits

..

65 Commits

Author SHA1 Message Date
crschmidt 98759ba74d Tag RC2.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.1-rc2@1482 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-18 18:49:23 +00:00
crschmidt 5f8dc06823 Pullup fixes to mouse controls since 2.1-rc1, along with a fix for
zooming. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1481 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-18 18:48:29 +00:00
crschmidt 130e527702 Branch for 2.1
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1452 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:33:48 +00:00
crschmidt f9fdb04f8c Timeout bumped to 4 seconds instead of 2.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1451 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:31:53 +00:00
crschmidt e295aee763 Test another way complains if there's no plan.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1450 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:31:42 +00:00
crschmidt 760e1ca014 Commit changes for tests to pass in IE.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1449 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:28:24 +00:00
Schuyler Erle c0fc945824 In Map.setCenter, only call Layer.moveTo if Layer.getVisibility returns true.
In Layer.setVisibility, call Layer.moveTo with zoomChanged = true, so that the
grid tiles are reloaded. In an ideal world, the grid tiles would only be loaded
if they haven't been loaded yet. This would spare us the split second wait
while the browser reloads those images from the cache, but we want to release
today, so it'll have to wait.



git-svn-id: http://svn.openlayers.org/trunk/openlayers@1448 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:16:50 +00:00
Schuyler Erle 24381c2f37 Remove MouseDefaults.zoomBox directly, rather than attempting to remove it by DOM ID. Fixes #199 in IE.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1447 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 15:47:22 +00:00
Schuyler Erle cea09f7fdb The name of the BaseLayers example should match the other examples, part 2.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1446 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 15:35:33 +00:00
Schuyler Erle 25b539d8bb The name of the BaseLayers example should match the other examples.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1445 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 15:35:25 +00:00
crschmidt c76dc1c211 Sort resolutions from largest units/pixel to lowest units/pixel. This makes
sure that you always zoom in, rather than out :)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1443 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 15:03:20 +00:00
crschmidt c5afbacc93 Add scoping term. Thanks to tschaub, closes #261 .
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1441 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 11:39:32 +00:00
euzuro a210e16479 final update to r1438 -- forgot to test on ie. turns out the 'safe' part means not setting that returnValue property.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1440 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-13 08:27:24 +00:00
euzuro 9cf595df01 did not mean to commit modifications to examples in r1438. Have set them back to how they were but for one small change to the popups.html example, which I give a hyperlink inside it to show off the new functionality
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1439 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-13 08:25:40 +00:00
euzuro 7ce7f2484b update default behaviour of popups. now you can click and drag inside a popup without the events dropping through to the map, yet if you are dragging a zoombox over a popup, it still responds. this is all thanks to a new function i am adding to Util.js which is called OpenLayers.Util.safeStopPropagaition(). Turns out the default Event.stop() from prototype.js is also calling a function called preventDefault() which disallows things like selecting text or clicking a hyperlink. all tests pass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1438 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-13 08:20:02 +00:00
euzuro 6793507a34 for case with no buffer, check lower bounds
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1437 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-13 05:28:53 +00:00
crschmidt c8e7d93f95 Windows svn under cygwin, apparently, believes it is a unix app. But windows
*python* under cygwin believes it is a non-windows app. Altogether, we get 
a big ole mess. However, this should clear it up.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1436 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-12 23:55:28 +00:00
crschmidt 84a677f910 Let's try to fix this again... still having problems with Windows building.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1435 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-12 23:44:10 +00:00
crschmidt 9d0c94d915 Erik says that building the single file version on Windows no longer works
with the propset on these, so we'll try undoing them and see if that fixes
it.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1434 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-12 23:36:13 +00:00
crschmidt 4a65590d3e Tile opacity patch from tschaub: Fix for #235. Also includes tests to ensure
that code works.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1433 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-11 14:30:25 +00:00
crschmidt 720c8507f7 If isBaseLayer hasn't been set at all, it's undefined, not null.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1428 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-10 03:43:16 +00:00
crschmidt 28bff61128 Fix all cases where we have Windows line endings, and set eol-style="native"
on all files. Hopefully, this makes it easier for people to write patches
and do other neat things. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1424 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-09 15:46:17 +00:00
euzuro 8305808bee only prevent event from falling through if there are actually listeners registered. this fixes #247
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1423 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 21:31:42 +00:00
euzuro 83f26a9336 fix bug introduced with r1421 -- mousedefaults doesnt create a div
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1422 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 21:31:02 +00:00
euzuro e1878d3f65 use inheritance for draw()
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1421 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 20:43:12 +00:00
euzuro 244e9543cd update popup id
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1420 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 16:53:55 +00:00
euzuro b157687eb2 update broken feature test-- new id
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1419 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 16:51:12 +00:00
euzuro cab72e3299 oops. update test for r1417 mod
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1418 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 05:24:49 +00:00
euzuro 861335f356 more standardizing ids
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1417 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 05:23:28 +00:00
euzuro 899101ef0b step toward standardization of id policy... for popups
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1416 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-08 04:51:32 +00:00
euzuro 31692f51fe cosmetic changes -- remove spacing, add spacing. coding standards
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1415 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-07 18:37:33 +00:00
euzuro e906982443 only set baselayer status based on transparency if *not* set in options. fix for #237 -- thanks tschaub
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1414 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-07 18:32:07 +00:00
euzuro 9b355b76dc update all base types to deal with any kind of input. a continuation of r1412 and a resolution for #245.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1413 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-07 18:18:06 +00:00
euzuro 00e354511e make sure passed in values are floats... if they are strings, parse them. just in case. add test for this
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1412 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-07 02:31:37 +00:00
euzuro 74f5b814eb update id system -- now control and layer divs take their classname and add a random number
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1411 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-06 20:44:55 +00:00
euzuro 6fd2302450 remove old unused line of code
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1410 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-06 20:25:33 +00:00
euzuro dd3dcef4ed oops. we forgot to add the projection to the parameters. not good.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1409 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-06 05:24:07 +00:00
Schuyler Erle e8bd5086df If Events finds a listener on a DOM element, call Event.stop so we don't fall through to other DOMelements.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1408 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-06 04:36:38 +00:00
euzuro e1a1b94582 udpate id's of control divs. This is for #226
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1398 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-31 15:27:10 +00:00
euzuro 4b0d947f3e change of heart. revert r1396
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1397 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-31 14:56:29 +00:00
euzuro 51c86b7b3c create div on initialize
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1396 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-31 14:54:31 +00:00
euzuro ae704e5158 remove superfluous example
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1395 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-31 14:53:33 +00:00
crschmidt 33499f59e9 Remove test.html. This file was originally used for debugging the new
LayerSwitcher, which turned out to be a problem with IE not understanding
'.checked' before an element is added to the DOM.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1394 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-31 10:50:34 +00:00
crschmidt 7a1ae31fc4 Fix for Ticket #201, reported by Steve Pomeroy. Thanks Steve!
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1393 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-29 11:25:54 +00:00
crschmidt d1ac37984e Fix for #198, from Sean Gillies. Thanks, Sean!
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1392 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-29 11:19:00 +00:00
crschmidt a2ded73387 Change GMaps key to be for OpenLayers.org.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1390 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-28 05:28:19 +00:00
crschmidt ef00010111 Multimap now conforms to other EventPane subclasses in expected behavior for
some functions, and has tests available, so when I break it at some point, 
hopefully I'll know :)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1389 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-27 01:46:09 +00:00
crschmidt 0c1caaf717 Redo Yahoo class to work under EventPane.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1387 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 20:37:00 +00:00
crschmidt 8be2cfbc71 Make image load error color configurable. Document it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1386 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 16:05:25 +00:00
crschmidt ecdb77fa9c getMousePosition did not take into account page scrolling. This closes #211 .
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1385 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 15:55:41 +00:00
crschmidt 954d0b351a Better documentation of need to set controls: [] on constructor to turn off MouseDefaults.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1384 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 15:26:10 +00:00
euzuro 57161a94be part two of #204 -- all that remains is to write some test functions
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1383 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 10:36:18 +00:00
euzuro 693eab5cc9 added getZoomForResolution() to map & layer. partial fix for #204 -- need to make a getZoomForResolution() for OpenLayers.Layer.FixedZoomLevels
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1382 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 10:26:12 +00:00
euzuro d486e1964b fix for #210
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1381 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 10:14:41 +00:00
euzuro b9c6293b2c Forgot to add one comment from r1379:
- Added Layer/FixedZoomLevels.js, which is a new pseudo-layer that all layers 
   which have fixed zoom levels will need to extend. It provides alternative 
   methods to initResolutions(), getResolution(), and getExtent() which depend
   on the fixed zoomlevel layer implementing getLonLatFromViewPortPx(), 
   getViewPortPxFromLonLat() and getZoomForExtent(). For documentation of how
   this works, see the comments in the class header.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1380 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 02:55:14 +00:00
euzuro f582775d11 - Removed unnecessary accessors from OpenLayers.Layer: getProjection(),
getMaxExtent(), getMaxResolution(), and getNumZoomLevels(). They were just 
   wrapping around the properties. better to just access the property directly. 
   Needed to update for these removals in many different files. 

- Improved initResolutions() functionality. It is now I believe both thorough
   and complete. The only exception is that we should maybe allow a way for 
   the user to set up resolutions[] array using only minResolution and 
   numZoomLevels instead of only maxResolution and numZoomLevels... but I'm not
   really sure anyone would ever really want to use that. And at any rate, I
   don't know the math for how to do it. I'm sure schuyler or Dr. 5 would.
   Oh. for a summary of how initResolutions works, see:
   http://trac.openlayers.org/wiki/SettingZoomLevels

- Move getResolution(), initResolutions() out of HTTPRequest and into Layer. On 
   thinking this through (and trying to write documentation), I realized that 
   the real, true, GENERIC case for a layer will be using this awesome 
   resolutions[] array that allows for setting number of zoom levels, default 
   max resolutions, special scale arrays, etc. 

- Updated code for getZoomForExtent() to work with resolutions[] array, instead 
   of using the the log 2 equation. 

- Move standard getZoomForExtent() and getExtent() out of Grid and into 
   Layer. Like above, there is no reason for these methods to be found so far
   down in the food chain. They are part of the generic calculations for 
   generic layers, so they belong in Layer. 



git-svn-id: http://svn.openlayers.org/trunk/openlayers@1379 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 02:51:38 +00:00
euzuro a8891101d6 no reason to redefine these here -- isBaseLayer is defined in OpenLayers.Layer now.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1378 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-26 00:11:01 +00:00
crschmidt b6200568d4 IE breaks on this -- probably because document.write () delays the onload, but
appending script elements doesn't. (Hooray for IE.) rolling this back and 
reopening the ticket until I can work out the best workaround for this.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1377 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:51:01 +00:00
crschmidt 84d4e70fa5 More cleanups. These are unneccesary.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1376 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:44:23 +00:00
crschmidt e9331479dc Right. 2.0 and trunk are not the same. svn switch is my friend.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1375 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:38:20 +00:00
crschmidt 7ed62ba639 Commit canvas work to trunk. Note that the Canvas layer is *not production
ready* -- it is a memory hog, and slow as heck when dragging. However, 
including it doesn't harm OpenLayers.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1371 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:20:20 +00:00
crschmidt 9233d5446d Merge multimap sandbox to trunk.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1370 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:18:26 +00:00
crschmidt 104e509eb9 Merge 2.0 branch to trunk.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1369 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-25 18:17:06 +00:00
Schuyler Erle 282d9d6047 Added red box to drag rectangle buttons.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1345 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 22:06:52 +00:00
Schuyler Erle 2871b2c38c Removed apparently unnecessary call to map.event.attachToElement().
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1337 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 19:53:20 +00:00
71 changed files with 3413 additions and 1714 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
rm ../doc/reference.html rm ../doc/reference.html
CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MouseToolbar Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds" CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MouseToolbar Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util"
echo "<html> echo "<html>
<head> <head>
<title>OpenLayers Class Reference Documentation</title> <title>OpenLayers Class Reference Documentation</title>
+1 -1
View File
@@ -1,6 +1,6 @@
OpenLayers.Control.MouseToolbar OpenLayers.Control.MouseToolbar
Control to set up mouse handling. This includes clicks, double clicks, scrollwheel events, and mouse movement. There are a number of functions which act as the default handlers for these events: if you wish to create your own mouse control which behaves differently, you should create a subclass of MouseToolbar, replacing the functions whose behavior you wish to change. Additionally, a toolbar of images can be clicked to start events, as well as using the keyboard shortcuts. Control to set up mouse handling. This includes clicks, double clicks, scrollwheel events, and mouse movement. There are a number of functions which act as the default handlers for these events: if you wish to create your own mouse control which behaves differently, you should create a subclass of MouseToolbar, replacing the functions whose behavior you wish to change. Additionally, a toolbar of images can be clicked to start events, as well as using the keyboard shortcuts. Note that if you wish to use the MouseToolbar, you *must* add a 'controls' option to the map constructor, otherwise you will have both MouseDefaults and MouseToolbar on the map, which will not work.
* Constructor * Constructor
OpenLayers.Control.MouseToolbar({OpenLayers.Pixel|position}, {String|direction}) -- Creates a new control. The direction of the control can be either "vertical" or "horizontal". The default is vertical. OpenLayers.Control.MouseToolbar({OpenLayers.Pixel|position}, {String|direction}) -- Creates a new control. The direction of the control can be either "vertical" or "horizontal". The default is vertical.
+1 -1
View File
@@ -1,6 +1,6 @@
OpenLayers.Control.Permalink OpenLayers.Control.Permalink
A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map, A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map. This control must be added to the map after a baselayer has been set.
* Constructor * Constructor
OpenLayers.Control.Scale({DOMElement|element}?, {String|base}) -- Creates a new permalink control. The DOMElement is used, if passed, as the element on which the 'href' is set. If you prefer to put this link on an element outside of the map, set this element to an anchor element to have its href updated when the map moves. If you wish to make the link go to some other URL (for example, an editing interface rather than the current URL), the 'base' property can be used, to which the ?lat=&lon=&zoom= will be appended after the map has moved. OpenLayers.Control.Scale({DOMElement|element}?, {String|base}) -- Creates a new permalink control. The DOMElement is used, if passed, as the element on which the 'href' is set. If you prefer to put this link on an element outside of the map, set this element to an anchor element to have its href updated when the map moves. If you wish to make the link go to some other URL (for example, an editing interface rather than the current URL), the 'base' property can be used, to which the ?lat=&lon=&zoom= will be appended after the map has moved.
-1
View File
@@ -12,7 +12,6 @@ of different layers.
clone() -- {OpenLayers.Layer} -- create a clone of the layer. clone() -- {OpenLayers.Layer} -- create a clone of the layer.
setName({String|name}) -- none -- Set the name of the layer to something different. setName({String|name}) -- none -- Set the name of the layer to something different.
moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location. moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location.
reproject() -- none -- Subclassed by vector layers to redraw vectors when base layer changes.
setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map. setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map.
getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer. getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer.
setVisibility({Boolean|visible}) -- none -- Set the layer visibility, and trigger the appropriate events. setVisibility({Boolean|visible}) -- none -- Set the layer visibility, and trigger the appropriate events.
+7
View File
@@ -0,0 +1,7 @@
OpenLayers.Util
Utility class. Stores a bunch of methods and settings that don't fit anywhere else.
* Options
OpenLayers.Util.onImageLoadErrorColor -- A string to set img.style.backgroundColor to if the onerror event fires for the image (useful for 500 errors from WMS, for example).
-68
View File
@@ -1,68 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<!-- gmaps api key for http://openlayers.org/~euzuro -->
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghQELW4Ku31wWCtlZquTlkHLCFh9LBTYvc_eIShlmo0YZwSitw0fQ1ZyXA'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer, glayer;
OpenLayers.ProxyHost = "/proxy/?url=";
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
glayer = new OpenLayers.Layer.Google("goog");
map.addLayer(glayer);
layer = new OpenLayers.Layer.WFS( "wfs",
"http://labs.metacarta.com/search/WFS?",
{maxfeatures: 1},
{ featureClass: OpenLayers.Feature.WFS});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
}
function add() {
markers2 = new OpenLayers.Layer.Markers("markers2");
map.addLayer(markers2);
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',new OpenLayers.Size(10,17));
marker = new OpenLayers.Marker(new OpenLayers.LonLat(2, 41), icon);
markers.addMarker(marker);
}
function remove() {
markers.removeMarker(marker);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
<div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
</body>
</html>
+613
View File
@@ -0,0 +1,613 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 512px;
border: 1px solid black;
}
</style>
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, canvas;
var click;
function init(){
map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var g = new OpenLayers.Layer.Google("Google");
canvas = new OpenLayers.Layer.Canvas("Canvas Layer");
map.addLayers([ol_wms, g,canvas]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.zoomToMaxExtent();
canvas.drawLine(new OpenLayers.LonLat(-71,42), new OpenLayers.LonLat(0,0));
canvas.setStrokeColor("red");
canvas.setStrokeWidth(5);
canvas.setAlpha(.5);
map.events.register("click", map, function(e) {
if (click) {
canvas.drawLine(click, this.getLonLatFromPixel(e.xy));
click = null;
$('status').innerHTML = "";
}
else {
click = this.getLonLatFromPixel(e.xy);
$('status').innerHTML = "Point 1 stored: "+click+". <a href='#' onclick='click=null;return false'>Reset</a>";
}
});
}
function drawIt() {
canvas.drawLine(
new OpenLayers.LonLat(parseFloat($('lon1').value), parseFloat($('lat1').value)),
new OpenLayers.LonLat(parseFloat($('lon2').value), parseFloat($('lat2').value))
);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Example</h1>
<div style="float:right">
<br />
Start Lon: <input type="text" id="lon1" />
Start Lat: <input type="text" id="lat1" /><br />
End Lon: <input type="text" id="lon2" />
End Lat: <input type="text" id="lat2" /><br />
<input type="submit" value="Add line" onclick="drawIt()" />
<div id="status"></div>
<center>
<table border="1" cellpadding="0" cellspacing="1">
<tbody>
<tr>
<td bgcolor="#000000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#000000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#000033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#000033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#000066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#000066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#000099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#000099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0000cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0000CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0000ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0000FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#330000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#330000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#330033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#330033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#330066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#330066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#330099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#330099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3300cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3300CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3300ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3300FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#660000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#660000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#660033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#660033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#660066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#660066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#660099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#660099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6600cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6600CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6600ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6600FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#990000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#990000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#990033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#990033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#990066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#990066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#990099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#990099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#9900cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#9900CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#9900ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#9900FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc0000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC0000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc0033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC0033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc0066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC0066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc0099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC0099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc00cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC00CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc00ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC00FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff0000">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF0000');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff0033">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF0033');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff0066">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF0066');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff0099">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF0099');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff00cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF00CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff00ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF00FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#003300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#003300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#003333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#003333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#003366">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#003366');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#003399">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#003399');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0033cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0033CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0033ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0033FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#333300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#333300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#333333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#333333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#333366">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#333366');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#333399">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#333399');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3333cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3333CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3333ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3333FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#663300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#663300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#663333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#663333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#663366">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#663366');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#663399">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#663399');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6633cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6633CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6633ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6633FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#993300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#993300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#993333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#993333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#993366">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#993366');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#993399">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#993399');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#9933cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#9933CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#9933ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#9933FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc3300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC3300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc3333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC3333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc33cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC33CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc33ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC33FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff3300">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF3300');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff3333">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF3333');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff3366">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF3366');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff3399">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF3399');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff33cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF33CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff33ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF33FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#006600">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#006600');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#006633">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#006633');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#006666">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#006666');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#006699">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#006699');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0066cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0066CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#336699">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#336699');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3366cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3366CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3366ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3366FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#666600">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#666600');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#666633">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#666633');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#666666">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#666666');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#666699">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#666699');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6666cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6666CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#6666ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#6666FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#996600">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#996600');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#996633">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#996633');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#9966ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#9966FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc6600">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC6600');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc6633">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC6633');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc6666">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC6666');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc6699">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC6699');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc66cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC66CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#cc66ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#CC66FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff6600">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF6600');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#ff6633">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#FF6633');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
<tr>
<td bgcolor="#009900">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#009900');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#009933">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#009933');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#009966">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#009966');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#009999">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#009999');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0099cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0099CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#0099ff">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#0099FF');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#339900">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#339900');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#339933">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#339933');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#339966">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#339966');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#339999">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#339999');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
<td bgcolor="#3399cc">
<font size="-3">
<a href="#" onclick="canvas.setStrokeColor('#3399CC');return false">&nbsp;&nbsp;&nbsp;</a>
</font>
</td>
</tr>
</table>
</div>
<div id="map"></div>
</body>
</html>
+1 -1
View File
@@ -18,7 +18,7 @@
{layers: 'basic'} ); {layers: 'basic'} );
var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite", var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite",
"/world/index.php", {g: "satellite", map: "world"}); "http://www.openlayers.org/world/index.php", {g: "satellite", map: "world"});
var dm_wms = new OpenLayers.Layer.WMS( "Canada", var dm_wms = new OpenLayers.Layer.WMS( "Canada",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap", "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," + {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
+58
View File
@@ -0,0 +1,58 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css">
#map {
width: 100%;
height: 512px;
border: 1px solid black;
}
</style>
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, mmlayer, layer;
function init(){
map = new OpenLayers.Map( $('map') ,
{controls:[new OpenLayers.Control.MouseDefaults()]});
mmlayer = new OpenLayers.Layer.MultiMap( "MultiMap");
map.addLayer(mmlayer);
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
}
function add() {
marker = new OpenLayers.Marker(new OpenLayers.LonLat(2, 41));
markers.addMarker(marker);
}
function remove() {
markers.removeMarker(marker);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers MultiMap Example</h1>
<div id="map"></div>
<div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
</body>
</html>
+2 -1
View File
@@ -22,6 +22,7 @@
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent(); map.zoomToMaxExtent();
} }
function changer() { function changer() {
@@ -70,9 +71,9 @@
function mousedown(evt) { function mousedown(evt) {
if (popup == null) { if (popup == null) {
popup = feature.createPopup(); popup = feature.createPopup();
popup.setContentHTML("<a href='http://www.somethingconstructive.net' target='_blank'>click me</a>");
popup.setBackgroundColor("yellow"); popup.setBackgroundColor("yellow");
popup.setOpacity(0.7); popup.setOpacity(0.7);
popup.events.register("mousedown", popup, onPopupMouseDown);
markers.map.addPopup(popup); markers.map.addPopup(popup);
} else { } else {
markers.map.removePopup(popup); markers.map.removePopup(popup);
-90
View File
@@ -1,90 +0,0 @@
<html>
<script src="../lib/Prototype.js"></script>
<script type="text/javascript">
var one, two, div, msg;
function init() {
one = $("one");
two = $("two");
div = $("div");
msg = $("msg");
Event.observe(div, "click", bar);
one.checked = true;
two.checked = false;
Event.observe(one, "change", oneClick);
Event.observe(two, "change", twoClick);
}
function bar(e) {
message("clicked div");
Event.stop(e);
var status = "one: ";
status += (one.checked) ? "checked" : "unchecked";
status += " two: ";
status += (two.checked) ? "checked" : "unchecked";
message(status);
}
function oneClick(e) {
message("clicked one");
}
function twoClick(e) {
message("clicked two");
}
function message(txt) {
msg.innerHTML += " ** " + txt;
}
</script>
<body onload="init()" onclick="message('clicked body')" onmouseup="message('<br>')">
<div> The idea here is to simulate the layerswitcher radiobuttons UI
without all the overhead of openlayers.
<br>
<br>
There are event handlers attached to the following elements:
<br>
* Body - Prints message "clicked body" to message area
<br>
* Blue Div - Prints message "clicked div" to message area, stops
the event propagation, prints a message with the
status of the two radiobuttons
<br>
* Radio One - Prints message "clicked one" to message area
<br>
* Radio Two - Prints message "clicked two" to message area
<br>
<br>
<b>
The problem, as you will see if you click the radio buttons
themselves, is that their "checked" status seems to update, but
their visual UI bit does not. Can we fix this!?!
</b>
</div>
<div id="div" style="background-color:blue; margin:50px">
<input id="one" type="radio" name="foo"/>
<span> one </span>
<br>
<input id="two" type="radio" name="foo"/>
<span> two </span>
</div>
<div id="msg" style="background-color:pink; margin-top:200px">
Events:
</div>
</body>
</html>
+8 -2
View File
@@ -1,8 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="width:100%"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<script src="../lib/OpenLayers.js"></script> <title>XHTML Example</title>
<script src="../lib/OpenLayers.js" type="text/javascript"></script>
</head> </head>
<body style="width:100%"> <body style="width:100%">
<div style="width:100%; height:500px" id="map"></div> <div style="width:100%; height:500px" id="map"></div>
@@ -13,5 +14,10 @@
map.addLayer(wms); map.addLayer(wms);
map.zoomToMaxExtent(); map.zoomToMaxExtent();
</script> </script>
<p>
<a href="http://validator.w3.org/check/referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
</p>
</body> </body>
</html> </html>
+1
View File
@@ -8,6 +8,7 @@
border: 1px solid black; border: 1px solid black;
} }
</style> </style>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

+4 -1
View File
@@ -67,12 +67,14 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Tile/Image.js", "OpenLayers/Tile/Image.js",
"OpenLayers/Tile/WFS.js", "OpenLayers/Tile/WFS.js",
"OpenLayers/Layer/EventPane.js", "OpenLayers/Layer/EventPane.js",
"OpenLayers/Layer/FixedZoomLevels.js",
"OpenLayers/Layer/Google.js", "OpenLayers/Layer/Google.js",
"OpenLayers/Layer/VirtualEarth.js", "OpenLayers/Layer/VirtualEarth.js",
// "OpenLayers/Layer/Yahoo.js", "OpenLayers/Layer/Yahoo.js",
"OpenLayers/Layer/HTTPRequest.js", "OpenLayers/Layer/HTTPRequest.js",
"OpenLayers/Layer/Grid.js", "OpenLayers/Layer/Grid.js",
"OpenLayers/Layer/KaMap.js", "OpenLayers/Layer/KaMap.js",
"OpenLayers/Layer/MultiMap.js",
"OpenLayers/Layer/Markers.js", "OpenLayers/Layer/Markers.js",
"OpenLayers/Layer/Text.js", "OpenLayers/Layer/Text.js",
"OpenLayers/Layer/WorldWind.js", "OpenLayers/Layer/WorldWind.js",
@@ -81,6 +83,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Layer/WMS/Untiled.js", "OpenLayers/Layer/WMS/Untiled.js",
"OpenLayers/Layer/GeoRSS.js", "OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/Canvas.js",
"OpenLayers/Popup/Anchored.js", "OpenLayers/Popup/Anchored.js",
"OpenLayers/Popup/AnchoredBubble.js", "OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Control.js", "OpenLayers/Control.js",
+10 -10
View File
@@ -31,8 +31,8 @@ OpenLayers.Pixel.prototype = {
* @param {float} y * @param {float} y
*/ */
initialize: function(x, y) { initialize: function(x, y) {
this.x = x; this.x = parseFloat(x);
this.y = y; this.y = parseFloat(y);
}, },
/** /**
@@ -123,8 +123,8 @@ OpenLayers.Size.prototype = {
* @param {float} h * @param {float} h
*/ */
initialize: function(w, h) { initialize: function(w, h) {
this.w = w; this.w = parseFloat(w);
this.h = h; this.h = parseFloat(h);
}, },
/** /**
@@ -193,8 +193,8 @@ OpenLayers.LonLat.prototype = {
* @param {float} lat * @param {float} lat
*/ */
initialize: function(lon, lat) { initialize: function(lon, lat) {
this.lon = lon; this.lon = parseFloat(lon);
this.lat = lat; this.lat = parseFloat(lat);
}, },
/** /**
@@ -315,10 +315,10 @@ OpenLayers.Bounds.prototype = {
* *
*/ */
initialize: function(left, bottom, right, top) { initialize: function(left, bottom, right, top) {
this.left = left; this.left = parseFloat(left);
this.bottom = bottom; this.bottom = parseFloat(bottom);
this.right = right; this.right = parseFloat(right);
this.top = top; this.top = parseFloat(top);
}, },
/** /**
+6
View File
@@ -8,6 +8,9 @@
OpenLayers.Control = Class.create(); OpenLayers.Control = Class.create();
OpenLayers.Control.prototype = { OpenLayers.Control.prototype = {
/** @type String */
id: null,
/** this gets set in the addControl() function in OpenLayers.Map /** this gets set in the addControl() function in OpenLayers.Map
* @type OpenLayers.Map */ * @type OpenLayers.Map */
map: null, map: null,
@@ -28,6 +31,8 @@ OpenLayers.Control.prototype = {
*/ */
initialize: function (options) { initialize: function (options) {
Object.extend(this, options); Object.extend(this, options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
}, },
/** /**
@@ -57,6 +62,7 @@ OpenLayers.Control.prototype = {
draw: function (px) { draw: function (px) {
if (this.div == null) { if (this.div == null) {
this.div = OpenLayers.Util.createDiv(); this.div = OpenLayers.Util.createDiv();
this.div.id = this.id;
} }
if (px != null) { if (px != null) {
this.position = px.clone(); this.position = px.clone();
+1 -1
View File
@@ -128,7 +128,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
// create span // create span
var labelSpan = document.createElement("span"); var labelSpan = document.createElement("span");
labelSpan.innerHTML = layer.name; labelSpan.innerHTML = layer.name;
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "auto"; labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline";
Event.observe(labelSpan, "click", Event.observe(labelSpan, "click",
this.onInputClick.bindAsEventListener(inputElem)); this.onInputClick.bindAsEventListener(inputElem));
// create line break // create line break
+50 -20
View File
@@ -60,6 +60,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1); this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt); Event.stop(evt);
return false;
}, },
/** /**
@@ -80,6 +81,7 @@ OpenLayers.Control.MouseDefaults.prototype =
this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50"; this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
} }
@@ -95,8 +97,8 @@ OpenLayers.Control.MouseDefaults.prototype =
if (this.zoomBox) { if (this.zoomBox) {
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = deltaX+"px"; this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = deltaY+"px"; this.zoomBox.style.height = Math.max(1, deltaY) + "px";
if (evt.xy.x < this.mouseDragStart.x) { if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px"; this.zoomBox.style.left = evt.xy.x+"px";
} }
@@ -124,20 +126,7 @@ OpenLayers.Control.MouseDefaults.prototype =
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
if (this.zoomBox) { if (this.zoomBox) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); this.zoomBoxEnd(evt);
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
} else { } else {
if (this.performedDrag) { if (this.performedDrag) {
this.map.setCenter(this.map.center); this.map.setCenter(this.map.center);
@@ -152,9 +141,12 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseOut: function (evt) { defaultMouseOut: function (evt) {
if (this.mouseDragStart != null if (this.mouseDragStart != null &&
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) { OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt); if (this.zoomBox) {
this.removeZoomBox();
}
this.mouseDragStart = null;
} }
}, },
@@ -173,6 +165,44 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.zoomOut(); this.map.zoomOut();
}, },
/** Zoombox function.
*
*/
zoomBoxEnd: function(evt) {
if (this.mouseDragStart != null) {
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
} else {
var end = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(new OpenLayers.LonLat(
(end.lon),
(end.lat)
), this.map.getZoom() + 1);
}
this.removeZoomBox();
}
},
/**
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null;
},
/** /**
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
@@ -189,7 +219,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var inMap = false; var inMap = false;
var elem = Event.element(e); var elem = Event.element(e);
while(elem != null) { while(elem != null) {
if (elem == this.map.div) { if (this.map && elem == this.map.div) {
inMap = true; inMap = true;
break; break;
} }
+66 -36
View File
@@ -6,12 +6,14 @@
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
* @requires OpenLayers/Control/MouseDefaults.js
*/ */
OpenLayers.Control.MouseToolbar = Class.create(); OpenLayers.Control.MouseToolbar = Class.create();
OpenLayers.Control.MouseToolbar.X = 6; OpenLayers.Control.MouseToolbar.X = 6;
OpenLayers.Control.MouseToolbar.Y = 300; OpenLayers.Control.MouseToolbar.Y = 300;
OpenLayers.Control.MouseToolbar.prototype = OpenLayers.Control.MouseToolbar.prototype =
Object.extend( new OpenLayers.Control(), { Object.extend( new OpenLayers.Control(),
Object.extend( new OpenLayers.Control.MouseDefaults(), {
mode: null, mode: null,
@@ -19,6 +21,9 @@ OpenLayers.Control.MouseToolbar.prototype =
direction: "vertical", direction: "vertical",
/** @type String */
buttonClicked: null,
initialize: function(position, direction) { initialize: function(position, direction) {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X, this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,
@@ -34,22 +39,15 @@ OpenLayers.Control.MouseToolbar.prototype =
draw: function() { draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments); OpenLayers.Control.prototype.draw.apply(this, arguments);
OpenLayers.Control.MouseDefaults.prototype.draw.apply(this, arguments);
this.buttons = new Object(); this.buttons = new Object();
this.map.events.register( "click", this, this.defaultClick );
this.map.events.register( "dblclick", this, this.defaultDblClick );
this.map.events.register( "mousedown", this, this.defaultMouseDown );
this.map.events.register( "mouseup", this, this.defaultMouseUp );
this.map.events.register( "mousemove", this, this.defaultMouseMove );
this.map.events.register( "mouseout", this, this.defaultMouseOut );
var sz = new OpenLayers.Size(28,28); var sz = new OpenLayers.Size(28,28);
var centered = this.position; var centered = this.position;
this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area"); this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area");
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan."); this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
this.switchModeTo("pan"); this.switchModeTo("pan");
this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
return this.div; return this.div;
}, },
@@ -67,10 +65,10 @@ OpenLayers.Control.MouseToolbar.prototype =
btn.imgLocation = imgLocation; btn.imgLocation = imgLocation;
btn.activeImgLocation = activeImgLocation; btn.activeImgLocation = activeImgLocation;
btn.events = new OpenLayers.Events(this, btn); btn.events = new OpenLayers.Events(this, btn, null, true);
btn.events.register("mousedown", this, this.buttonClick); btn.events.register("mousedown", this, this.buttonDown);
btn.events.register("mouseup", this, Event.stop); btn.events.register("mouseup", this, this.buttonUp);
btn.events.register("click", this, Event.stop); btn.events.register("dblclick", this, Event.stop);
btn.action = id; btn.action = id;
btn.title = title; btn.title = title;
btn.alt = title; btn.alt = title;
@@ -81,12 +79,29 @@ OpenLayers.Control.MouseToolbar.prototype =
return btn; return btn;
}, },
buttonClick: function(evt) { /**
* @param {Event} evt
*/
buttonDown: function(evt) {
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
this.switchModeTo(evt.element.action); this.buttonClicked = evt.element.action;
Event.stop(evt); Event.stop(evt);
}, },
/**
* @param {Event} evt
*/
buttonUp: function(evt) {
if (!Event.isLeftClick(evt)) return;
if (this.buttonClicked != null) {
if (this.buttonClicked == evt.element.action) {
this.switchModeTo(evt.element.action);
}
Event.stop(evt);
this.buttonClicked = null;
}
},
/** /**
* @param {Event} evt * @param {Event} evt
*/ */
@@ -94,7 +109,9 @@ OpenLayers.Control.MouseToolbar.prototype =
this.switchModeTo("pan"); this.switchModeTo("pan");
this.performedDrag = false; this.performedDrag = false;
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2); this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt);
return false;
}, },
/** /**
@@ -104,8 +121,10 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
this.performedDrag = false; this.performedDrag = false;
this.startViaKeyboard = false;
if (evt.shiftKey && this.mode !="zoombox") { if (evt.shiftKey && this.mode !="zoombox") {
this.switchModeTo("zoombox"); this.switchModeTo("zoombox");
this.startViaKeyboard = true;
} else if (evt.altKey && this.mode !="measure") { } else if (evt.altKey && this.mode !="measure") {
this.switchModeTo("measure"); this.switchModeTo("measure");
} else if (!this.mode) { } else if (!this.mode) {
@@ -124,8 +143,10 @@ OpenLayers.Control.MouseToolbar.prototype =
this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50"; this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
this.performedDrag = true;
break; break;
case "measure": case "measure":
var distance = ""; var distance = "";
@@ -178,7 +199,9 @@ OpenLayers.Control.MouseToolbar.prototype =
switchModeTo: function(mode) { switchModeTo: function(mode) {
if (mode != this.mode) { if (mode != this.mode) {
if (this.mode) {
if (this.mode && this.buttons[this.mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
} }
if (this.mode == "measure" && mode != "measure") { if (this.mode == "measure" && mode != "measure") {
@@ -191,8 +214,19 @@ OpenLayers.Control.MouseToolbar.prototype =
this.measureStart = null; this.measureStart = null;
} }
this.mode = mode; this.mode = mode;
if (this.buttons[mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
} }
switch (this.mode) {
case "zoombox":
this.map.div.style.cursor = "crosshair";
break;
default:
this.map.div.style.cursor = "default";
break;
}
}
}, },
leaveMode: function() { leaveMode: function() {
@@ -208,8 +242,8 @@ OpenLayers.Control.MouseToolbar.prototype =
case "zoombox": case "zoombox":
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = deltaX+"px"; this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = deltaY+"px"; this.zoomBox.style.height = Math.max(1, deltaY) + "px";
if (evt.xy.x < this.mouseDragStart.x) { if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px"; this.zoomBox.style.left = evt.xy.x+"px";
} }
@@ -238,21 +272,8 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
switch (this.mode) { switch (this.mode) {
case "zoombox": case "zoombox":
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); this.zoomBoxEnd(evt);
var end = this.map.getLonLatFromViewPortPx( evt.xy ); if (this.startViaKeyboard) this.leaveMode();
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
this.leaveMode();
break; break;
case "pan": case "pan":
if (this.performedDrag) { if (this.performedDrag) {
@@ -264,17 +285,26 @@ OpenLayers.Control.MouseToolbar.prototype =
this.map.div.style.cursor = "default"; this.map.div.style.cursor = "default";
}, },
/**
* @param {Event} evt
*/
defaultMouseOut: function (evt) { defaultMouseOut: function (evt) {
if (this.mouseDragStart != null if (this.mouseDragStart != null
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) { && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt); if (this.zoomBox) {
this.removeZoomBox();
if (this.startViaKeyboard) this.leaveMode();
}
this.mouseDragStart = null;
this.map.div.style.cursor = "default";
} }
}, },
defaultClick: function (evt) { defaultClick: function (evt) {
if (this.performedDrag) { if (this.performedDrag) {
this.performedDrag = false; this.performedDrag = false;
return false; return false;
} }
} }
}); }));
-1
View File
@@ -76,7 +76,6 @@ OpenLayers.Control.PanZoom.prototype =
*/ */
_addButton:function(id, img, xy, sz) { _addButton:function(id, img, xy, sz) {
var imgLocation = OpenLayers.Util.getImagesLocation() + img; var imgLocation = OpenLayers.Util.getImagesLocation() + img;
// var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);
var btn = OpenLayers.Util.createAlphaImageDiv( var btn = OpenLayers.Util.createAlphaImageDiv(
"OpenLayers_Control_PanZoom_" + id, "OpenLayers_Control_PanZoom_" + id,
xy, sz, imgLocation, "absolute"); xy, sz, imgLocation, "absolute");
+4 -3
View File
@@ -12,6 +12,7 @@ OpenLayers.Control.PanZoomBar.X = 4;
OpenLayers.Control.PanZoomBar.Y = 4; OpenLayers.Control.PanZoomBar.Y = 4;
OpenLayers.Control.PanZoomBar.prototype = OpenLayers.Control.PanZoomBar.prototype =
Object.extend( new OpenLayers.Control.PanZoom(), { Object.extend( new OpenLayers.Control.PanZoom(), {
/** @type Array(...) */ /** @type Array(...) */
buttons: null, buttons: null,
@@ -85,7 +86,7 @@ OpenLayers.Control.PanZoomBar.prototype =
"absolute"); "absolute");
this.slider = slider; this.slider = slider;
this.sliderEvents = new OpenLayers.Events(this, slider); this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
this.sliderEvents.register("mousedown", this, this.zoomBarDown); this.sliderEvents.register("mousedown", this, this.zoomBarDown);
this.sliderEvents.register("mousemove", this, this.zoomBarDrag); this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
this.sliderEvents.register("mouseup", this, this.zoomBarUp); this.sliderEvents.register("mouseup", this, this.zoomBarUp);
@@ -115,7 +116,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.zoombarDiv = div; this.zoombarDiv = div;
this.divEvents = new OpenLayers.Events(this, div); this.divEvents = new OpenLayers.Events(this, div, null, true);
this.divEvents.register("mousedown", this, this.divClick); this.divEvents.register("mousedown", this, this.divClick);
this.divEvents.register("mousemove", this, this.passEventToSlider); this.divEvents.register("mousemove", this, this.passEventToSlider);
this.divEvents.register("dblclick", this, this.doubleClick); this.divEvents.register("dblclick", this, this.doubleClick);
@@ -184,8 +185,8 @@ OpenLayers.Control.PanZoomBar.prototype =
this.slider.style.top = newTop+"px"; this.slider.style.top = newTop+"px";
} }
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
}
Event.stop(evt); Event.stop(evt);
}
}, },
/* /*
+12 -5
View File
@@ -37,11 +37,14 @@ OpenLayers.Events.prototype = {
* is being added * is being added
* @param {DOMElement} element A dom element to respond to browser events * @param {DOMElement} element A dom element to respond to browser events
* @param {Array} eventTypes Array of custom application events * @param {Array} eventTypes Array of custom application events
* @param {Boolean} fallThrough Allow events to fall through after these
* have been handled?
*/ */
initialize: function (object, element, eventTypes) { initialize: function (object, element, eventTypes, fallThrough) {
this.object = object; this.object = object;
this.element = element; this.element = element;
this.eventTypes = eventTypes; this.eventTypes = eventTypes;
this.fallThrough = fallThrough;
this.listeners = new Object(); this.listeners = new Object();
// if eventTypes is specified, create a listeners list for each // if eventTypes is specified, create a listeners list for each
@@ -159,8 +162,7 @@ OpenLayers.Events.prototype = {
// execute all callbacks registered for specified type // execute all callbacks registered for specified type
var listeners = this.listeners[type]; var listeners = this.listeners[type];
if (listeners != null) { if ((listeners != null) && (listeners.length > 0)) {
for (var i = 0; i < listeners.length; i++) { for (var i = 0; i < listeners.length; i++) {
var callback = listeners[i]; var callback = listeners[i];
var continueChain; var continueChain;
@@ -176,6 +178,10 @@ OpenLayers.Events.prototype = {
break; break;
} }
} }
// don't fall through to other DOM elements
if (!this.fallThrough) {
Event.stop(evt);
}
} }
}, },
@@ -205,8 +211,9 @@ OpenLayers.Events.prototype = {
this.element.offsets = Position.page(this.element); this.element.offsets = Position.page(this.element);
} }
return new OpenLayers.Pixel( return new OpenLayers.Pixel(
evt.clientX - this.element.offsets[0], (evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) - this.element.offsets[0],
evt.clientY - this.element.offsets[1]); (evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) - this.element.offsets[1]
);
}, },
/** @final @type String */ /** @final @type String */
+1 -1
View File
@@ -42,7 +42,7 @@ OpenLayers.Feature.prototype= {
this.layer = layer; this.layer = layer;
this.lonlat = lonlat; this.lonlat = lonlat;
this.data = (data != null) ? data : new Object(); this.data = (data != null) ? data : new Object();
this.id = OpenLayers.Util.createUniqueID('Feature_'); this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
}, },
/** /**
+158 -71
View File
@@ -44,12 +44,27 @@ OpenLayers.Layer.prototype = {
/** @type String */ /** @type String */
projection: null, projection: null,
/** @type String */
units: null,
/** @type Array */
scales: null,
/** @type Array */
resolutions: null,
/** @type OpenLayers.Bounds */ /** @type OpenLayers.Bounds */
maxExtent: null, maxExtent: null,
/** @type OpenLayers.Bounds */
minExtent: null,
/** @type float */ /** @type float */
maxResolution: null, maxResolution: null,
/** @type float */
minResolution: null,
/** @type int */ /** @type int */
numZoomLevels: null, numZoomLevels: null,
@@ -59,8 +74,6 @@ OpenLayers.Layer.prototype = {
/** @type float */ /** @type float */
maxScale: null, maxScale: null,
/** @type String */
units: null,
/** /**
* @constructor * @constructor
@@ -79,13 +92,13 @@ OpenLayers.Layer.prototype = {
this.name = name; this.name = name;
//generate unique id based on name this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
this.id = OpenLayers.Util.createUniqueID("Layer_");
if (this.div == null) { if (this.div == null) {
this.div = OpenLayers.Util.createDiv(); this.div = OpenLayers.Util.createDiv();
this.div.style.width = "100%"; this.div.style.width = "100%";
this.div.style.height = "100%"; this.div.style.height = "100%";
this.div.id = this.id;
} }
} }
}, },
@@ -182,11 +195,17 @@ OpenLayers.Layer.prototype = {
'minExtent', 'maxExtent', 'minExtent', 'maxExtent',
'numZoomLevels' 'numZoomLevels'
); );
if (this.map.maxZoomLevel && !this.numZoomLevels) {
this.numZoomLevels = this.map.maxZoomLevel + 1;
}
for(var i=0; i < properties.length; i++) { for(var i=0; i < properties.length; i++) {
if (this[properties[i]] == null) { if (this[properties[i]] == null) {
this[properties[i]] = this.map[properties[i]]; this[properties[i]] = this.map[properties[i]];
} }
} }
if (this.isBaseLayer) {
this.initResolutions();
}
}, },
/** /**
@@ -207,7 +226,7 @@ OpenLayers.Layer.prototype = {
if ((visible) && (this.map != null)) { if ((visible) && (this.map != null)) {
var extent = this.map.getExtent(); var extent = this.map.getExtent();
if (extent != null) { if (extent != null) {
this.moveTo(this.map.getExtent()); this.moveTo(this.map.getExtent(), true);
} }
} }
if ((this.map != null) && if ((this.map != null) &&
@@ -217,15 +236,6 @@ OpenLayers.Layer.prototype = {
} }
}, },
/********************************************************/
/* */
/* Layer Options */
/* */
/* Accessor functions to Layer Options parameters */
/* */
/********************************************************/
/** /**
* @param {Boolean} isBaseLayer * @param {Boolean} isBaseLayer
*/ */
@@ -236,84 +246,160 @@ OpenLayers.Layer.prototype = {
} }
}, },
/**
* @type String
*/
getProjection: function() {
return this.projection;
},
/**
* @type OpenLayers.Bounds
*/
getMaxExtent: function() {
return this.maxExtent;
},
/**
* @type float
*/
getMaxResolution: function() {
return this.maxResolution;
},
/**
* @returns The total number of zoom levels this layer can reach
* @type int
*/
getNumZoomLevels: function() {
return this.numZoomLevels;
},
/********************************************************/ /********************************************************/
/* */ /* */
/* Baselayer Functions */ /* Baselayer Functions */
/* */ /* */
/* The following functions must all be implemented */
/* by all base layers */
/* */
/********************************************************/ /********************************************************/
/** This method's responsibility is to set up the 'resolutions' array
* for the layer -- this array is what the layer will use to interface
* between the zoom levels of the map and the resolution display of the
* layer.
*
* The user has several options that determine how the array is set up.
*
* For a detailed explanation, see the following wiki from the
* openlayers.org homepage:
*
* http://trac.openlayers.org/wiki/SettingZoomLevels
*
* @private
*/
initResolutions: function() {
if ((this.scales != null) || (this.resolutions != null)) {
//preset levels
if (this.scales != null) {
this.resolutions = new Array();
for(var i = 0; i < this.scales.length; i++) {
this.resolutions[i] =
OpenLayers.Util.getResolutionFromScale(this.scales[i],
this.units);
}
}
this.numZoomLevels = this.resolutions.length;
} else {
//maxResolution and numZoomLevels
this.resolutions = new Array();
// determine maxResolution
if (this.minScale) {
this.maxResolution =
OpenLayers.Util.getResolutionFromScale(this.minScale,
this.units);
} else if (this.maxResolution == "auto") {
var viewSize = this.map.getSize();
var wRes = this.maxExtent.getWidth() / viewSize.w;
var hRes = this.maxExtent.getHeight()/ viewSize.h;
this.maxResolution = Math.max(wRes, hRes);
}
// determine minResolution
if (this.maxScale != null) {
this.minResolution =
OpenLayers.Util.getResolutionFromScale(this.maxScale);
} else if ((this.minResolution == "auto") &&
(this.minExtent != null)){
var viewSize = this.map.getSize();
var wRes = this.minExtent.getWidth() / viewSize.w;
var hRes = this.minExtent.getHeight()/ viewSize.h;
this.minResolution = Math.max(wRes, hRes);
}
// determine numZoomLevels
if (this.minResolution != null) {
var ratio = this.maxResolution / this.minResolution;
this.numZoomLevels =
Math.floor(Math.log(ratio) / Math.log(2)) + 1;
}
// now we have numZoomLevels and maxResolution,
// we can populate the resolutions array
for (var i=0; i < this.numZoomLevels; i++) {
this.resolutions.push(this.maxResolution / Math.pow(2, i));
}
}
},
/** /**
* @returns Degrees per Pixel * @returns The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level.
* @type float * @type float
*/ */
getResolution: function() { getResolution: function() {
var viewSize = this.map.getSize(); var zoom = this.map.getZoom();
var extent = this.getExtent(); return this.resolutions[zoom];
return Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
}, },
/** Calculates using px-> lonlat translation functions on tl and br /** Calculates based on resolution, center, and mapsize
* corners of viewport
* *
* @param {float} resolution Specific resolution to get an extent for.
* If null, this.getResolution() is called
* @returns A Bounds object which represents the lon/lat bounds of the * @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort. * current viewPort.
* @type OpenLayers.Bounds * @type OpenLayers.Bounds
*/ */
getExtent: function () { getExtent: function(resolution) {
var extent = null; var extent = null;
var center = this.map.getCenter();
if (center != null) {
if (resolution == null) {
resolution = this.getResolution();
}
var size = this.map.getSize(); var size = this.map.getSize();
var w_deg = size.w * resolution;
var h_deg = size.h * resolution;
var tlPx = new OpenLayers.Pixel(0,0); extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
var tlLL = this.getLonLatFromViewPortPx(tlPx); center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
var brPx = new OpenLayers.Pixel(size.w, size.h);
var brLL = this.getLonLatFromViewPortPx(brPx);
if ((tlLL != null) && (brLL != null)) {
extent = new OpenLayers.Bounds(tlLL.lon,
brLL.lat,
brLL.lon,
tlLL.lat);
} }
return extent; return extent;
}, },
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns The index of the zoomLevel (entry in the resolutions array)
* that still contains the passed-in extent. We do this by
* calculating the ideal resolution for the given exteng (based
* on the map size) and then find the smallest resolution that
* is greater than this ideal resolution.
* @type int
*/
getZoomForExtent: function(extent) {
var viewSize = this.map.getSize();
var idealResolution = Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
return this.getZoomForResolution(idealResolution);
},
/**
* @param {float} resolution
*
* @returns The index of the zoomLevel (entry in the resolutions array)
* that is the smallest resolution that is greater than the
* passed-in resolution.
* @type int
*/
getZoomForResolution: function(resolution) {
for(var i=1; i <= this.resolutions.length; i++) {
if ( this.resolutions[i] < resolution) {
break;
}
}
return (i - 1);
},
/** /**
* @param {OpenLayers.Pixel} viewPortPx * @param {OpenLayers.Pixel} viewPortPx
@@ -351,16 +437,17 @@ OpenLayers.Layer.prototype = {
}, },
/** /**
* @param {OpenLayers.Bounds} bounds * Sets the opacity for the entire layer (all images)
* * @param {Float} opacity
* @return {int}
*/ */
getZoomForExtent: function (bounds) { setOpacity: function(opacity) {
// this should be implemented by subclasses this.opacity = opacity;
for(var i=0; i<this.div.childNodes.length; ++i) {
var element = this.div.childNodes[i];
OpenLayers.Util.setOpacity(element, opacity);
}
}, },
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer" CLASS_NAME: "OpenLayers.Layer"
}; };
+117
View File
@@ -0,0 +1,117 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer.js
*/
OpenLayers.Layer.Canvas = Class.create();
OpenLayers.Layer.Canvas.prototype =
Object.extend( new OpenLayers.Layer(), {
/** Canvas layer is never a base layer.
*
* @type Boolean
*/
isBaseLayer: false,
isFixed: true,
/** internal marker list
* @type Array(OpenLayers.Marker) */
canvas: null,
lines: new Array(),
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
},
/**
*
*/
destroy: function() {
// xxx actually destroy the canvas to scavenge ram?
canvas = null;
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} minor
*/
moveTo:function(bounds, zoomChanged, minor) {
this.redraw();
},
setStrokeColor: function(color) {
var ctx = this.canvas.getContext("2d");
ctx.strokeStyle = color;
},
setStrokeWidth: function(width) {
var ctx = this.canvas.getContext("2d");
ctx.lineWidth = width;
},
setAlpha: function(alpha) {
var ctx = this.canvas.getContext("2d");
ctx.globalAlpha = alpha;
},
/**
*
*/
clearCanvas: function() {
if(this.canvas != null) {
this.canvas.getContext("2d").clearRect(0,0,this.map.getSize().w, this.map.getSize().h);
// xxx use real width and height
}
},
drawLine: function(start, end) {
var ctx = this.canvas.getContext("2d");
this.addLine(start, end);
this.lines.push(new Array(start,end, ctx.strokeStyle, ctx.lineWidth, ctx.globalAlpha));
},
addLine: function(start, end) {
var ctx = this.canvas.getContext("2d");
var startpx = this.map.getPixelFromLonLat(start);
var endpx = this.map.getPixelFromLonLat(end);
ctx.beginPath();
ctx.moveTo(startpx.x, startpx.y);
ctx.lineTo(endpx.x, endpx.y);
ctx.closePath();
ctx.stroke();
},
/** clear all the marker div's from the layer and then redraw all of them.
* Use the map to recalculate new placement of markers.
*/
redraw: function() {
// xxx rebuild the canvas if smaller than the view
// xxx may wish to overside the canvas with overflow=hidden by default
if(!this.canvas) {
this.canvas = document.createElement("CANVAS");
this.canvas.setAttribute("width",this.map.getSize().w);
this.canvas.setAttribute("height",this.map.getSize().h);
this.div.appendChild(this.canvas);
} else {
this.clearCanvas();
}
for(var i=0; i < this.lines.length; i++) {
this.setStrokeColor(this.lines[i][2]);
this.setStrokeWidth(this.lines[i][3]);
this.setAlpha(this.lines[i][4]);
this.addLine(this.lines[i][0], this.lines[i][1]);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Canvas"
});
-1
View File
@@ -63,7 +63,6 @@ OpenLayers.Layer.EventPane.prototype =
} else { } else {
this.map.layerContainerDiv.appendChild(this.pane); this.map.layerContainerDiv.appendChild(this.pane);
} }
this.map.events.attachToElement(this.pane);
}, },
/** /**
+133
View File
@@ -0,0 +1,133 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* Some Layers will already have established zoom levels (like google
* or ve). Instead of trying to determine them and populate a resolutions[]
* Array with those values, we will hijack the resolution functionality
* here.
*
* When you subclass FixedZoomLevels:
*
* The initResolutions() call gets nullified, meaning no resolutions[] array
* is set up. Which would be a big problem getResolution() in Layer, since
* it merely takes map.zoom and indexes into resolutions[]... but....
*
* The getResolution() call is also overridden. Instead of using the
* resolutions[] array, we simply calculate the current resolution based
* on the current extent and the current map size. But how will we be able
* to calculate the current extent without knowing the resolution...?
*
* The getExtent() function is also overridden. Instead of calculating extent
* based on the center point and the current resolution, we instead
* calculate the extent by getting the lonlats at the top-left and
* bottom-right by using the getLonLatFromViewPortPx() translation function,
* taken from the pixel locations (0,0) and the size of the map. But how
* will we be able to do lonlat-px translation without resolution....?
*
* The getZoomForResolution() method is overridden. Instead of indexing into
* the resolutions[] array, we call OpenLayers.Layer.getExent(), passing in
* the desired resolution. With this extent, we then call getZoomForExtent()
*
*
* Whenever you implement a layer using OpenLayers.Layer.FixedZoomLevels,
* it is your responsibility to provide the following three functions:
*
* - getLonLatFromViewPortPx()
* - getViewPortPxFromLonLat()
* - getZoomForExtent()
*
* ...those three functions should generally be provided by any reasonable
* API that you might be working from.
*
* @class
*/
OpenLayers.Layer.FixedZoomLevels = Class.create();
OpenLayers.Layer.FixedZoomLevels.prototype = {
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/* The following functions must all be implemented */
/* by all base layers */
/* */
/********************************************************/
/**
* @constructor
*/
initialize: function() {
//this class is only just to add the following functions...
// nothing to actually do here... but it is probably a good
// idea to have layers that use these functions call this
// inititalize() anyways, in case at some point we decide we
// do want to put some functionality or state in here.
},
initResolutions: function() {
// resolutions are set automatically in the black-box. this is the
// definition of a fixed-zoom-levels layer
},
/**
* @returns Degrees per Pixel
* @type float
*/
getResolution: function() {
var viewSize = this.map.getSize();
var extent = this.getExtent();
return Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
},
/** Calculates using px-> lonlat translation functions on tl and br
* corners of viewport
*
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
var extent = null;
var size = this.map.getSize();
var tlPx = new OpenLayers.Pixel(0,0);
var tlLL = this.getLonLatFromViewPortPx(tlPx);
var brPx = new OpenLayers.Pixel(size.w, size.h);
var brLL = this.getLonLatFromViewPortPx(brPx);
if ((tlLL != null) && (brLL != null)) {
extent = new OpenLayers.Bounds(tlLL.lon,
brLL.lat,
brLL.lon,
tlLL.lat);
}
return extent;
},
/**
* @param {float} resolution
*
* @returns A suitable zoom level for the specified resolution.
* If no baselayer is set, returns null.
* @type int
*/
getZoomForResolution: function(resolution) {
var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
[resolution]);
return this.getZoomForExtent(extent);
},
/** @final @type String */
CLASS_NAME: "FixedZoomLevels.js"
};
+16 -2
View File
@@ -70,8 +70,22 @@ OpenLayers.Layer.GeoRSS.prototype =
continue; continue;
} }
location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0])); location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0]));
var title = OpenLayers.Util.getNodes(itemlist[i], "title")[0].firstChild.nodeValue;
var description = OpenLayers.Util.getNodes(itemlist[i], "description")[0].firstChild.nodeValue; /* Provide defaults for title and description */
var title = "No title";
try {
title = OpenLayers.Util.getNodes(itemlist[i],
"title")[0].firstChild.nodeValue;
}
catch (e) { alert(e); }
var description = "No description";
try {
description = OpenLayers.Util.getNodes(itemlist[i],
"description")[0].firstChild.nodeValue;
}
catch (e) { alert(e); }
try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { } try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }
data.icon = OpenLayers.Marker.defaultIcon(); data.icon = OpenLayers.Marker.defaultIcon();
data.popupSize = new OpenLayers.Size(250, 100); data.popupSize = new OpenLayers.Size(250, 100);
+5 -3
View File
@@ -12,7 +12,8 @@
*/ */
OpenLayers.Layer.Google = Class.create(); OpenLayers.Layer.Google = Class.create();
OpenLayers.Layer.Google.prototype = OpenLayers.Layer.Google.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), { Object.extend( new OpenLayers.Layer.EventPane(),
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), {
/** @type Boolean */ /** @type Boolean */
isFixed: true, isFixed: true,
@@ -39,6 +40,8 @@ OpenLayers.Layer.Google.prototype =
*/ */
initialize: function(name, options) { initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments); OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if (this.maxExtent == null) { if (this.maxExtent == null) {
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
} }
@@ -250,7 +253,6 @@ OpenLayers.Layer.Google.prototype =
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel), var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
this.maxZoomLevel); this.maxZoomLevel);
zoom = this.getOLZoomFromGZoom(gZoom); zoom = this.getOLZoomFromGZoom(gZoom);
} }
return zoom; return zoom;
@@ -438,4 +440,4 @@ OpenLayers.Layer.Google.prototype =
}, },
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google" CLASS_NAME: "OpenLayers.Layer.Google"
}); }));
+2 -61
View File
@@ -267,8 +267,8 @@ OpenLayers.Layer.Grid.prototype =
// if the test grid coordinates are within the bounds of the // if the test grid coordinates are within the bounds of the
// grid, get a reference to the tile. // grid, get a reference to the tile.
var tile = null; var tile = null;
if ((testRow < this.grid.length) && if ((testRow < this.grid.length) && (testRow >= 0) &&
(testCell < this.grid[0].length)) { (testCell < this.grid[0].length) && (testCell >= 0)) {
tile = this.grid[testRow][testCell]; tile = this.grid[testRow][testCell];
} }
@@ -393,65 +393,6 @@ OpenLayers.Layer.Grid.prototype =
} }
}, },
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/** Calculates based on resolution, center, and mapsize
*
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
var extent = null;
var center = this.map.getCenter();
if (center != null) {
var res = this.map.getResolution();
var size = this.map.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
}
return extent;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @return {int}
*/
getZoomForExtent: function (bounds) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
//make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, 0),
this.getNumZoomLevels() - 1);
return zoom;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Grid" CLASS_NAME: "OpenLayers.Layer.Grid"
}); });
-94
View File
@@ -36,17 +36,6 @@ OpenLayers.Layer.HTTPRequest.prototype =
this.params = Object.extend( new Object(), params); this.params = Object.extend( new Object(), params);
}, },
/** When the layer is added to the map, once it has taken all the
* relevant properties from the map (in Layer.setMap()), we will
* make the call to initialize the layer's resolutions array.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
this.initResolutions();
},
/** /**
* *
*/ */
@@ -138,89 +127,6 @@ OpenLayers.Layer.HTTPRequest.prototype =
return requestString; return requestString;
}, },
/** This method's responsibility is to set up the 'resolutions' array
* for the layer -- this array is what the layer will use to interface
* between the zoom levels of the map and the resolution display of the
* layer.
*
* The user has several options that determine how the array is set up.
*
* For a detailed explanation, see the following wiki from the
* openlayers.org homepage:
*
* http://trac.openlayers.org/wiki/SettingZoomLevels
*
* @private
*/
initResolutions: function() {
if ((this.scales != null) || (this.resolutions != null)) {
//preset levels
if (this.scales != null) {
this.resolutions = new Array();
for(var i = 0; i < this.scales.length; i++) {
this.resolutions[i] =
OpenLayers.Util.getResolutionFromScale(this.scales[i],
this.units);
}
}
this.numZoomLevels = this.resolutions.length;
} else {
//maxResolution and numZoomLevels
this.resolutions = new Array();
// determine maxResolution
if (this.minScale) {
this.maxResolution =
OpenLayers.Util.getResolutionFromScale(this.minScale,
this.units);
} else if (this.maxResolution == "auto") {
var viewSize = this.map.getSize();
var wRes = this.maxExtent.getWidth() / viewSize.w;
var hRes = this.maxExtent.getHeight()/ viewSize.h;
this.maxResolution = Math.max(wRes, hRes);
}
// determine minResolution
if (this.maxScale != null) {
this.minResolution =
OpenLayers.Util.getResolutionFromScale(this.maxScale);
} else if ((this.minResolution == "auto") &&
(this.minExtent != null)){
var viewSize = this.map.getSize();
var wRes = this.minExtent.getWidth() / viewSize.w;
var hRes = this.minExtent.getHeight()/ viewSize.h;
this.minResolution = Math.max(wRes, hRes);
}
// determine numZoomLevels
if (this.minResolution != null) {
var ratio = this.maxResolution / this.minResolution;
this.numZoomLevels =
Math.floor(Math.log(ratio) / Math.log(2)) + 1;
}
// now we have numZoomLevels and maxResolution,
// we can populate the resolutions array
for (var i=0; i < this.numZoomLevels; i++) {
this.resolutions.push(this.maxResolution / Math.pow(2, i));
}
}
},
/**
* @returns The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level.
* @type float
*/
getResolution: function() {
var zoom = this.map.getZoom();
return this.resolutions[zoom];
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.HTTPRequest" CLASS_NAME: "OpenLayers.Layer.HTTPRequest"
}); });
+1 -1
View File
@@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype =
*/ */
getURL: function (bounds) { getURL: function (bounds) {
var mapRes = this.map.getResolution(); var mapRes = this.map.getResolution();
var scale = this.map.getScale(); var scale = Math.round((this.map.getScale() * 10000)) / 10000;
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h); var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w); var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h); var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);
+338
View File
@@ -0,0 +1,338 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer/EventPane.js
*/
OpenLayers.Layer.MultiMap = Class.create();
OpenLayers.Layer.MultiMap.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), {
/** @type MMMap */
multimap: null,
/** @type int */
minZoomLevel: 1,
/** @type int */
maxZoomLevel: 17,
/**
* @constructor
*
* @param {String} name
*/
initialize:function(name) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
},
/**
* @param {OpenLayers.Map} map
*/
setMap:function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
// once our layer has been added to the map, we can load the multimap
this.loadMMMap();
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} minor
*/
moveTo:function(bounds, zoomChanged, minor) {
if (this.multimap != null) {
var olCenter = this.map.getCenter();
var mmCenter = this.getMMLatLongFromOLLonLat(olCenter);
if (zoomChanged) {
var olZoom = this.map.getZoom();
var mmZoom = this.getMMZoomFromOLZoom(olZoom);
this.multimap.goToPosition(mmCenter, mmZoom);
} else {
this.multimap.goToPosition(mmCenter);
}
}
},
/**
*
*/
loadMMMap:function() {
try {
// create MMMap, hide nav controls
this.multimap = new MultimapViewer(this.div);
} catch (e) {
// do nothing this is to keep from crashing
// if the MM library was not loaded.
}
if (this.multimap == null) {
this.loadWarningMessage();
}
},
/** If we can't load the multimap, then display an error message to the
* user and tell them where to go for help.
*
* @private
*
*/
loadWarningMessage:function() {
this.div.style.backgroundColor = "darkblue";
var html = "";
html += "The MM Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the MM Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the MM library";
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Demmlopers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/MultiMapLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
var viewSize = this.map.getSize();
msgW = Math.min(viewSize.w, 300);
msgH = Math.min(viewSize.h, 200);
var size = new OpenLayers.Size(msgW, msgH);
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
var topLeft = centerPx.add(-size.w/2, -size.h/2);
var div = OpenLayers.Util.createDiv("mmWarning",
topLeft,
size,
null,
null,
null,
"auto");
div.style.padding = "7px";
div.style.backgroundColor = "yellow";
div.innerHTML = html;
this.div.appendChild(div);
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by MM
* If multimap is not loaded, returns null.
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if (this.multimap != null) {
var pixel = this.getPixelFromOLPixel(viewPortPx);
var zoom = this.multimap.getZoomFactor();
pixel.x = pixel.x - (this.map.getSize().w/2);
pixel.y = pixel.y - (this.map.getSize().h/2);
var mmLatLong = this.multimap.getMapPositionAt(pixel);
lonlat = this.getOLLonLatFromMMLatLong(mmLatLong);
}
return lonlat;
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY MM
* If multimap is not loaded, returns null.
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null;
if (this.multimap != null) {
var mmLatLong = this.getMMLatLongFromOLLonLat(lonlat);
var pixel = this.multimap.geoPosToContainerPixels(mmLatLong);
viewPortPx = this.getOLPixelFromPixel(pixel);
}
return viewPortPx;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom lemml for a specified Bounds.
* If multimap is not loaded, returns null.
* @type int
*/
getZoomForExtent: function (bounds) {
var zoom = null;
if (this.multimap != null) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var mmZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
//make sure zoom is within bounds
var mmZoom = Math.min(Math.max(mmZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromMMZoom(mmZoom);
}
return zoom;
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
/**
* @param {int} mmZoom
*
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromMMZoom: function(mmZoom) {
if (mmZoom) return mmZoom - 1;
return null;
},
/**
* @param {int} olZoom
*
* @returns A MMZoom lemml, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getMMZoomFromOLZoom: function(olZoom) {
if (olZoom) return olZoom + 1;
return null;
},
//
// TRANSLATION: MMLatLong <-> LonLat
//
/**
* @param {MMLatLong} mmLatLong
*
* @returns An OpenLayers.LonLat, translated from the passed in MMLatLong
* Returns null if null value is passed in
* @type OpenLayers.LonLat
*/
getOLLonLatFromMMLatLong: function(mmLatLong) {
var olLonLat = null;
if (mmLatLong != null) {
olLonLat = new OpenLayers.LonLat(mmLatLong.lon,
mmLatLong.lat);
}
return olLonLat;
},
/**
* @param {OpenLayers.LonLat} olLonLat
*
* @returns A MMLatLong, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type MMLatLong
*/
getMMLatLongFromOLLonLat: function(olLonLat) {
var mmLatLong = null;
if (olLonLat != null) {
mmLatLong = new MMLatLon(olLonLat.lat, olLonLat.lon);
}
return mmLatLong;
},
//
// TRANSLATION: Pixel <-> OpenLayers.Pixel
//
/**
* @param {Pixel} pixel
*
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
* Returns null if null value is passed in
* @type OpenLayers.Pixel
*/
getOLPixelFromPixel: function(pixel) {
var olPixel = null;
if (pixel != null) {
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
* Returns null if null value is passed in
*
* As it turns out, the only specifications we can see for the
* MM-compatible Pixel is an x & y property, which emmry
* OpenLayers.Pixel has by default. So just leamm it as-is.
*
* @type Pixel
*/
getPixelFromOLPixel: function(olPixel) {
var pixel = null;
if (olPixel != null) {
pixel = new MMPoint(olPixel.x, olPixel.y);
}
return pixel;
},
destroy: function() {
this.multimap = null;
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MultiMap"
});
+5 -2
View File
@@ -9,7 +9,8 @@
*/ */
OpenLayers.Layer.VirtualEarth = Class.create(); OpenLayers.Layer.VirtualEarth = Class.create();
OpenLayers.Layer.VirtualEarth.prototype = OpenLayers.Layer.VirtualEarth.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), { Object.extend( new OpenLayers.Layer.EventPane(),
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), {
/** @type VEMap */ /** @type VEMap */
vemap: null, vemap: null,
@@ -27,6 +28,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
*/ */
initialize:function(name) { initialize:function(name) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments); OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
}, },
@@ -352,4 +355,4 @@ OpenLayers.Layer.VirtualEarth.prototype =
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.VirtualEarth" CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
}); }));
+1 -1
View File
@@ -173,7 +173,7 @@ OpenLayers.Layer.WFS.prototype =
/** combine the layer's url with its params and these newParams. /** combine the layer's url with its params and these newParams.
* *
* Add the SRS parameter from getProjection() -- this is probably * Add the SRS parameter from 'projection' -- this is probably
* more eloquently done via a setProjection() method, but this * more eloquently done via a setProjection() method, but this
* works for now and always. * works for now and always.
* *
+5 -5
View File
@@ -21,9 +21,6 @@ OpenLayers.Layer.WMS.prototype =
format: "image/jpeg" format: "image/jpeg"
}, },
/** @type Boolean */
isBaseLayer: null,
/** /**
* @constructor * @constructor
* *
@@ -48,9 +45,12 @@ OpenLayers.Layer.WMS.prototype =
); );
} }
// if the layer is transparent, it will be an overlay // unless explicitly set in options, if the layer is transparent,
// it will be an overlay
if ((options == null) || !(options.isBaseLayer)) {
this.isBaseLayer = ((this.params.TRANSPARENT != "true") && this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
(this.params.TRANSPARENT != true)); (this.params.TRANSPARENT != true));
}
}, },
/** /**
@@ -136,7 +136,7 @@ OpenLayers.Layer.WMS.prototype =
/** combine the layer's url with its params and these newParams. /** combine the layer's url with its params and these newParams.
* *
* Add the SRS parameter from getProjection() -- this is probably * Add the SRS parameter from projection -- this is probably
* more eloquently done via a setProjection() method, but this * more eloquently done via a setProjection() method, but this
* works for now and always. * works for now and always.
* *
+24 -8
View File
@@ -22,10 +22,6 @@ OpenLayers.Layer.WMS.Untiled.prototype =
format: "image/jpeg" format: "image/jpeg"
}, },
/** @type Boolean */
isBaseLayer: null,
/** @type DOMElement */ /** @type DOMElement */
imgDiv: null, imgDiv: null,
@@ -37,12 +33,12 @@ OpenLayers.Layer.WMS.Untiled.prototype =
* @param {String} url * @param {String} url
* @param {Object} params * @param {Object} params
*/ */
initialize: function(name, url, params) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { if (arguments.length > 0) {
//uppercase params //uppercase params
params = OpenLayers.Util.upperCaseObject(params); params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params); newArguments.push(name, url, params, options);
} }
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this, OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
newArguments); newArguments);
@@ -54,10 +50,12 @@ OpenLayers.Layer.WMS.Untiled.prototype =
); );
} }
// if the layer is transparent, it will be an overlay // unless explicitly set in options, if the layer is transparent,
// it will be an overlay
if ((options == null) || (options.isBaseLayer == null)) {
this.isBaseLayer = ((this.params.TRANSPARENT != "true") && this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
(this.params.TRANSPARENT != true)); (this.params.TRANSPARENT != true));
}
}, },
/** /**
@@ -185,6 +183,24 @@ OpenLayers.Layer.WMS.Untiled.prototype =
this.moveTo(); this.moveTo();
}, },
/** combine the layer's url with its params and these newParams.
*
* Add the SRS parameter from 'projection' -- this is probably
* more eloquently done via a setProjection() method, but this
* works for now and always.
*
* @param {Object} newParams
*
* @type String
*/
getFullRequestString:function(newParams) {
var projection = this.map.getProjection();
this.params.SRS = (projection == "none") ? null : projection;
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
this, arguments);
},
/** This function first removes the previous image div, then adds a new /** This function first removes the previous image div, then adds a new
* one according to the transparency property. * one according to the transparency property.
* *
+249 -80
View File
@@ -2,31 +2,23 @@
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */ * text of the license. */
// load Yahoo map control script
document.write("<script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>");
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer/EventPane.js
*/ */
OpenLayers.Layer.Yahoo = Class.create(); OpenLayers.Layer.Yahoo = Class.create();
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), { OpenLayers.Layer.Yahoo.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), {
/** Yahoo layer is always a base layer. /** @type YMap */
* yahoomap: null,
* @type Boolean
*/
isBaseLayer: true,
/** @type Boolean */ /** @type int */
isFixed: true, minZoomLevel: 0,
/** @type GMap2 gmap stores the Google Map element */ /** @type int */
ymap:null, maxZoomLevel: 15,
/** @type Boolean */
dragging:false,
/** /**
* @constructor * @constructor
@@ -34,17 +26,19 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
* @param {String} name * @param {String} name
*/ */
initialize:function(name) { initialize:function(name) {
OpenLayers.Layer.prototype.initialize.apply(this, [name]); OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
}, },
/** /**
* @param {OpenLayers.Map} map * @param {OpenLayers.Map} map
*/ */
setMap:function(map) { setMap:function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments); OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
// once our layer has been added to the map, we can create the vemap // once our layer has been added to the map, we can load the yahoomap
this.map.events.register("addlayer", this, this.loadYMap); this.loadYMap();
}, },
/** /**
@@ -54,97 +48,272 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, minor) {
if ((this.ymap != null) && (!this.dragging)) { if (this.yahoomap != null) {
var olCenter = this.map.getCenter(); var olCenter = this.map.getCenter();
var yCenter = this.getYMapCenter(); var mmCenter = this.getYLatLongFromOLLonLat(olCenter);
if (zoomChanged) {
var olZoom = this.map.getZoom(); var olZoom = this.map.getZoom();
var yZoom = this.ymap.getZoomLevel(); var mmZoom = this.getYZoomFromOLZoom(olZoom);
this.yahoomap.setZoomLevel(mmZoom);
if ((!olCenter.equals(yCenter)) || (( 16 - olZoom) != yZoom)) {
this.ymap.drawZoomAndCenter(new YGeoPoint(olCenter.lat, olCenter.lon),
16 - olZoom);
} }
this.yahoomap.drawZoomAndCenter(mmCenter, mmZoom);
} }
}, },
/** /**
* *
*/ */
loadYMap:function() { loadYMap:function() {
// create div and set to same size as map this.yahoomap = new YMap(this.div);
var yDiv = OpenLayers.Util.createDiv(this.name);
var sz = this.map.getSize();
yDiv.style.width = sz.w;
yDiv.style.height = sz.h;
this.div.appendChild(yDiv);
// create GMap, hide nav controls
this.ymap = new YMap(this.div);
// catch pans and zooms from GMap
YEvent.Capture(this.ymap,
EventsList.endPan,
this.catchPanZoom,
this);
// catch pans and zooms from GMap
YEvent.Capture(this.ymap,
EventsList.endAutoPan,
this.catchPanZoom,
this);
// attach to the drag start and end and we´ll set a flag so that if (this.yahoomap == null) {
// we dont get recursivity. this is because the events fall through this.loadWarningMessage();
// the gmaps div and into the main layer div }
YEvent.Capture(this.ymap,
EventsList.startPan,
this.dragStart,
this);
}, },
/** /** If we can't load the yahoomap, then display an error message to the
* @private * user and tell them where to go for help.
*/ *
dragStart: function() {
this.dragging = true;
},
/**
* @private * @private
* *
* @param {Event} e
*/ */
catchPanZoom: function(e) { loadWarningMessage:function() {
this.dragging = false;
var olCenter = this.getYMapCenter(); this.div.style.backgroundColor = "darkblue";
var yZoom = this.ymap.getZoomLevel();
this.map.setCenter(olCenter, 16 - yZoom); var html = "";
html += "The Y Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the Y Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Y library";
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Demmlopers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/YahooLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
var viewSize = this.map.getSize();
msgW = Math.min(viewSize.w, 300);
msgH = Math.min(viewSize.h, 200);
var size = new OpenLayers.Size(msgW, msgH);
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
var topLeft = centerPx.add(-size.w/2, -size.h/2);
var div = OpenLayers.Util.createDiv("mmWarning",
topLeft,
size,
null,
null,
null,
"auto");
div.style.padding = "7px";
div.style.backgroundColor = "yellow";
div.innerHTML = html;
this.div.appendChild(div);
}, },
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/** /**
* @private * @param {OpenLayers.Pixel} viewPortPx
* *
* @returns An OpenLayers.LonLat with the center of the ymap, or null if * @returns An OpenLayers.LonLat which is the passed-in view port
* the YMap has not been centered yet * OpenLayers.Pixel, translated into lon/lat by Y
* If yahoomap is not loaded, returns null.
* @type OpenLayers.LonLat * @type OpenLayers.LonLat
*/ */
getYMapCenter:function() { getLonLatFromViewPortPx: function (viewPortPx) {
var olCenter = null; var lonlat = null;
var yCenter = this.ymap.getCenterLatLon(); if (this.yahoomap != null) {
if (yCenter != null) { var pixel = this.getPixelFromOLPixel(viewPortPx);
olCenter = new OpenLayers.LonLat(yCenter.Lon, yCenter.Lat); var mmLatLong = this.yahoomap.convertXYLatLon(pixel);
lonlat = this.getOLLonLatFromYLatLong(mmLatLong);
} }
return olCenter; return lonlat;
}, },
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY Y
* If yahoomap is not loaded, returns null.
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null;
if (this.yahoomap != null) {
var mmLatLong = this.getYLatLongFromOLLonLat(lonlat);
var pixel = this.yahoomap.convertLatLonXY(mmLatLong);
viewPortPx = this.getOLPixelFromPixel(pixel);
}
return viewPortPx;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom lemml for a specified Bounds.
* If yahoomap is not loaded, returns null.
* @type int
*/
getZoomForExtent: function (bounds) {
var zoom = null;
if (this.yahoomap != null) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var mmZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
//make sure zoom is within bounds
var mmZoom = Math.min(Math.max(mmZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromYZoom(mmZoom);
}
return zoom;
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
/**
* @param {int} mmZoom
*
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromYZoom: function(mmZoom) {
return 18 - mmZoom;
},
/**
* @param {int} olZoom
*
* @returns A YZoom lemml, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getYZoomFromOLZoom: function(olZoom) {
return 18 - olZoom;
},
//
// TRANSLATION: YLatLong <-> LonLat
//
/**
* @param {YLatLong} mmLatLong
*
* @returns An OpenLayers.LonLat, translated from the passed in YLatLong
* Returns null if null value is passed in
* @type OpenLayers.LonLat
*/
getOLLonLatFromYLatLong: function(mmLatLong) {
var olLonLat = null;
if (mmLatLong != null) {
olLonLat = new OpenLayers.LonLat(mmLatLong.Lon,
mmLatLong.Lat);
}
return olLonLat;
},
/**
* @param {OpenLayers.LonLat} olLonLat
*
* @returns A YLatLong, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type YLatLong
*/
getYLatLongFromOLLonLat: function(olLonLat) {
var mmLatLong = null;
if (olLonLat != null) {
mmLatLong = new YGeoPoint(olLonLat.lat, olLonLat.lon);
}
return mmLatLong;
},
//
// TRANSLATION: Pixel <-> OpenLayers.Pixel
//
/**
* @param {Pixel} pixel
*
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
* Returns null if null value is passed in
* @type OpenLayers.Pixel
*/
getOLPixelFromPixel: function(pixel) {
var olPixel = null;
if (pixel != null) {
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
* Returns null if null value is passed in
*
* As it turns out, the only specifications we can see for the
* Y-compatible Pixel is an x & y property, which emmry
* OpenLayers.Pixel has by default. So just leamm it as-is.
*
* @type Pixel
*/
getPixelFromOLPixel: function(olPixel) {
var pixel = null;
if (olPixel != null) {
pixel = new YCoordPoint(olPixel.x, olPixel.y);
}
return pixel;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Yahoo" CLASS_NAME: "OpenLayers.Layer.Yahoo"
}); });
+25 -8
View File
@@ -371,9 +371,12 @@ OpenLayers.Map.prototype = {
if (center != null) { if (center != null) {
var zoom = this.getZoom(); var zoom = this.getZoom();
this.zoom = null; this.zoom = null;
this.setCenter(center, zoom); if (zoom > this.baseLayer.numZoomLevels - 1) {
zoom = this.baseLayer.numZoomLevels - 1;
} }
this.setCenter(center, zoom);
}
if ((noEvent == null) || (noEvent == false)) { if ((noEvent == null) || (noEvent == false)) {
this.events.triggerEvent("changebaselayer"); this.events.triggerEvent("changebaselayer");
} }
@@ -562,7 +565,6 @@ OpenLayers.Map.prototype = {
* trigger movestart/end events * trigger movestart/end events
*/ */
setCenter: function (lonlat, zoom, minor) { setCenter: function (lonlat, zoom, minor) {
var zoomChanged = (this.isValidZoomLevel(zoom)) && var zoomChanged = (this.isValidZoomLevel(zoom)) &&
(zoom != this.getZoom()); (zoom != this.getZoom());
@@ -604,7 +606,7 @@ OpenLayers.Map.prototype = {
var bounds = this.getExtent(); var bounds = this.getExtent();
for (var i = 0; i < this.layers.length; i++) { for (var i = 0; i < this.layers.length; i++) {
var layer = this.layers[i]; var layer = this.layers[i];
if ((layer == this.baseLayer) || !layer.isBaseLayer) { if (layer.getVisibility()) {
layer.moveTo(bounds, zoomChanged, minor); layer.moveTo(bounds, zoomChanged, minor);
} }
} }
@@ -682,7 +684,7 @@ OpenLayers.Map.prototype = {
getProjection: function() { getProjection: function() {
var projection = null; var projection = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
projection = this.baseLayer.getProjection(); projection = this.baseLayer.projection;
} }
return projection; return projection;
}, },
@@ -694,7 +696,7 @@ OpenLayers.Map.prototype = {
getMaxResolution: function() { getMaxResolution: function() {
var maxResolution = null; var maxResolution = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
maxResolution = this.baseLayer.getMaxResolution(); maxResolution = this.baseLayer.maxResolution;
} }
return maxResolution; return maxResolution;
}, },
@@ -705,7 +707,7 @@ OpenLayers.Map.prototype = {
getMaxExtent: function () { getMaxExtent: function () {
var maxExtent = null; var maxExtent = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
maxExtent = this.baseLayer.getMaxExtent(); maxExtent = this.baseLayer.maxExtent;
} }
return maxExtent; return maxExtent;
}, },
@@ -718,7 +720,7 @@ OpenLayers.Map.prototype = {
getNumZoomLevels: function() { getNumZoomLevels: function() {
var numZoomLevels = null; var numZoomLevels = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
numZoomLevels = this.baseLayer.getNumZoomLevels(); numZoomLevels = this.baseLayer.numZoomLevels;
} }
return numZoomLevels; return numZoomLevels;
}, },
@@ -786,13 +788,28 @@ OpenLayers.Map.prototype = {
* @type int * @type int
*/ */
getZoomForExtent: function (bounds) { getZoomForExtent: function (bounds) {
zoom = null; var zoom = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
zoom = this.baseLayer.getZoomForExtent(bounds); zoom = this.baseLayer.getZoomForExtent(bounds);
} }
return zoom; return zoom;
}, },
/**
* @param {float} resolution
*
* @returns A suitable zoom level for the specified resolution.
* If no baselayer is set, returns null.
* @type int
*/
getZoomForResolution: function(resolution) {
var zoom = null;
if (this.baseLayer != null) {
zoom = this.baseLayer.getZoomForResolution(resolution);
}
return zoom;
},
/********************************************************/ /********************************************************/
/* */ /* */
/* Zooming Functions */ /* Zooming Functions */
+86 -5
View File
@@ -7,7 +7,6 @@
*/ */
OpenLayers.Popup = Class.create(); OpenLayers.Popup = Class.create();
OpenLayers.Popup.count = 0;
OpenLayers.Popup.WIDTH = 200; OpenLayers.Popup.WIDTH = 200;
OpenLayers.Popup.HEIGHT = 200; OpenLayers.Popup.HEIGHT = 200;
OpenLayers.Popup.COLOR = "white"; OpenLayers.Popup.COLOR = "white";
@@ -56,8 +55,11 @@ OpenLayers.Popup.prototype = {
* @param {String} contentHTML * @param {String} contentHTML
*/ */
initialize:function(id, lonlat, size, contentHTML) { initialize:function(id, lonlat, size, contentHTML) {
OpenLayers.Popup.count += 1; if (id == null) {
this.id = (id != null) ? id : "Popup" + OpenLayers.Popup.count; id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
}
this.id = id;
this.lonlat = lonlat; this.lonlat = lonlat;
this.size = (size != null) ? size this.size = (size != null) ? size
: new OpenLayers.Size( : new OpenLayers.Size(
@@ -70,10 +72,10 @@ OpenLayers.Popup.prototype = {
this.opacity = OpenLayers.Popup.OPACITY; this.opacity = OpenLayers.Popup.OPACITY;
this.border = OpenLayers.Popup.BORDER; this.border = OpenLayers.Popup.BORDER;
this.div = OpenLayers.Util.createDiv(this.id + "_div", null, null, this.div = OpenLayers.Util.createDiv(this.id, null, null,
null, null, null, "hidden"); null, null, null, "hidden");
this.events = new OpenLayers.Events(this, this.div, null); this.registerEvents();
}, },
/** /**
@@ -229,5 +231,84 @@ OpenLayers.Popup.prototype = {
} }
}, },
/** Do this in a separate function so that subclasses can
* choose to override it if they wish to deal differently
* with mouse events
*
* Note in the following handler functions that some special
* care is needed to deal correctly with mousing and popups.
*
* Because the user might select the zoom-rectangle option and
* then drag it over a popup, we need a safe way to allow the
* mousemove and mouseup events to pass through the popup when
* they are initiated from outside.
*
* Otherwise, we want to essentially kill the event propagation
* for all other events, though we have to do so carefully,
* without disabling basic html functionality, like clicking on
* hyperlinks or drag-selecting text.
*/
registerEvents:function() {
this.events = new OpenLayers.Events(this, this.div, null, true);
this.events.register("mousedown", this, this.onmousedown);
this.events.register("mousemove", this, this.onmousemove);
this.events.register("mouseup", this, this.onmouseup);
this.events.register("click", this,
OpenLayers.Util.safeStopPropagation);
this.events.register("mouseout", this, this.onmouseout);
this.events.register("dblclick", this,
OpenLayers.Util.safeStopPropagation);
},
/** When mouse goes down within the popup, make a note of
* it locally, and then do not propagate the mousedown
* (but do so safely so that user can select text inside)
*
* @param {Event} evt
*/
onmousedown: function (evt) {
this.mousedown = true;
OpenLayers.Util.safeStopPropagation(evt);
},
/** If the drag was started within the popup, then
* do not propagate the mousemove (but do so safely
* so that user can select text inside)
*
* @param {Event} evt
*/
onmousemove: function (evt) {
if (this.mousedown) {
OpenLayers.Util.safeStopPropagation(evt);
}
},
/** When mouse comes up within the popup, after going down
* in it, reset the flag, and then (once again) do not
* propagate the event, but do so safely so that user can
* select text inside
*
* @param {Event} evt
*/
onmouseup: function (evt) {
if (this.mousedown) {
this.mousedown = false;
OpenLayers.Util.safeStopPropagation(evt);
}
},
/** When mouse goes out of the popup set the flag to false so that
* if they let go and then drag back in, we won't be confused.
*
* @param {Event} evt
*
* @type Boolean
*/
onmouseout: function (evt) {
this.mousedown = false;
},
CLASS_NAME: "OpenLayers.Popup" CLASS_NAME: "OpenLayers.Popup"
}; };
+1 -1
View File
@@ -49,7 +49,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
var contentSize = this.size.clone(); var contentSize = this.size.clone();
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
var id = this.div.id + "-contentDiv"; var id = this.div.id + "_contentDiv";
this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize,
null, "relative", null, null, "relative", null,
"hidden"); "hidden");
+3
View File
@@ -102,6 +102,9 @@ OpenLayers.Tile.Image.prototype =
true); true);
} }
this.layer.div.appendChild(this.imgDiv); this.layer.div.appendChild(this.imgDiv);
if(this.layer.opacity != null) {
OpenLayers.Util.setOpacity(this.imgDiv, this.layer.opacity);
}
}, },
/** @final @type String */ /** @final @type String */
+28 -1
View File
@@ -125,14 +125,29 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
return image; return image;
}; };
/**
* Set the opacity of a DOM Element
* Note that for this function to work in IE, elements must "have layout"
* according to:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/haslayout.asp
*
* @param {DOMElement} element Set the opacity on this DOM element
* @param {Float} opacity Opacity value (0.0 - 1.0)
*/
OpenLayers.Util.setOpacity = function(element, opacity) {
element.style.opacity = opacity;
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
}
OpenLayers.Util.onImageLoad = function() { OpenLayers.Util.onImageLoad = function() {
this.style.backgroundColor = null; this.style.backgroundColor = null;
this.style.display = ""; this.style.display = "";
}; };
OpenLayers.Util.onImageLoadErrorColor = "pink";
OpenLayers.Util.onImageLoadError = function() { OpenLayers.Util.onImageLoadError = function() {
this.style.backgroundColor = "pink"; this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
}; };
@@ -501,3 +516,15 @@ OpenLayers.Util.getResolutionFromScale = function (scale, units) {
* OpenLayers.DOTS_PER_INCH); * OpenLayers.DOTS_PER_INCH);
return resolution; return resolution;
}; };
/** Safely stop the propagation of an event *without* preventing
* the default browser action from occurring.
*
* @param {Event} evt
*/
OpenLayers.Util.safeStopPropagation = function(evt) {
if (evt.stopPropagation) {
evt.stopPropagation();
}
evt.cancelBubble = true;
};
+2
View File
@@ -19,9 +19,11 @@
<li>test_Layer_KaMap.html</li> <li>test_Layer_KaMap.html</li>
<li>test_Layer_WMS.html</li> <li>test_Layer_WMS.html</li>
<li>test_Layer_Google.html</li> <li>test_Layer_Google.html</li>
<li>test_Layer_MultiMap.html</li>
<li>test_Tile.html</li> <li>test_Tile.html</li>
<li>test_Tile_Image.html</li> <li>test_Tile_Image.html</li>
<li>test_Control.html</li> <li>test_Control.html</li>
<li>test_Control_MouseToolbar.html</li>
<li>test_Control_LayerSwitcher.html</li> <li>test_Control_LayerSwitcher.html</li>
<li>test_Control_PanZoom.html</li> <li>test_Control_PanZoom.html</li>
<li>test_Control_PanZoomBar.html</li> <li>test_Control_PanZoomBar.html</li>
+2 -2
View File
@@ -663,7 +663,7 @@ Test.AnotherWay._test_object_t.prototype.delay_call=function()
Test.AnotherWay._test_object_t.prototype.open_window=function( url, fn, timeout_seconds ) Test.AnotherWay._test_object_t.prototype.open_window=function( url, fn, timeout_seconds )
{ {
if( timeout_seconds==null ) { if( timeout_seconds==null ) {
timeout_seconds=2; timeout_seconds=4;
} }
var no_close=document.getElementById( "dont_close_test_windows" ); var no_close=document.getElementById( "dont_close_test_windows" );
var action={ action_kind: "window", wnd_url: url.toString(), wnd_wnd: null, wnd_fn: fn, wnd_timeout_milliseconds: timeout_seconds*1000, wnd_no_close: no_close.checked }; var action={ action_kind: "window", wnd_url: url.toString(), wnd_wnd: null, wnd_fn: fn, wnd_timeout_milliseconds: timeout_seconds*1000, wnd_no_close: no_close.checked };
@@ -785,7 +785,7 @@ Test.AnotherWay._set_iframe_location=function( iframe, loc, outside_path_correct
Test.AnotherWay._start_loading_page=function() Test.AnotherWay._start_loading_page=function()
{ {
var test_page=Test.AnotherWay._g_tests_queue[0]; var test_page=Test.AnotherWay._g_tests_queue[0];
test_page.loading_timeout_milliseconds=2000; test_page.loading_timeout_milliseconds=4000;
test_page.timeout_id=setTimeout( Test.AnotherWay._loading_timeout, Test.AnotherWay._g_timeout_granularity ); test_page.timeout_id=setTimeout( Test.AnotherWay._loading_timeout, Test.AnotherWay._g_timeout_granularity );
test_page.wait_msg=Test.AnotherWay._print_counter_result( test_page.url, "loading...", test_page.loading_timeout_milliseconds, "loading" ); test_page.wait_msg=Test.AnotherWay._print_counter_result( test_page.url, "loading...", test_page.loading_timeout_milliseconds, "loading" );
if( test_page.convention=="jsan" ) { if( test_page.convention=="jsan" ) {
+12
View File
@@ -28,6 +28,18 @@
t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" ); t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
} }
function test_01a_Bounds_constructorFromStrings(t) {
t.plan( 6 );
bounds = new OpenLayers.Bounds("0","2","10","4");
t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
t.eq( bounds.left, 0, "bounds.left is set correctly" );
t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
t.eq( bounds.right, 10, "bounds.right is set correctly" );
t.eq( bounds.top, 4, "bounds.top is set correctly" );
}
function test_02_Bounds_toBBOX(t) { function test_02_Bounds_toBBOX(t) {
t.plan( 1 ); t.plan( 1 );
bounds = new OpenLayers.Bounds(1,2,3,4); bounds = new OpenLayers.Bounds(1,2,3,4);
+58
View File
@@ -0,0 +1,58 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var map;
function test_01_Control_MouseToolbar_constructor (t) {
t.plan( 1 );
control = new OpenLayers.Control.MouseToolbar();
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
}
function test_02_Control_MouseToolbar_addControl (t) {
t.plan( 7 );
map = new OpenLayers.Map('map');
control = new OpenLayers.Control.MouseToolbar();
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
map.addControl(control);
t.ok( control.map === map, "Control.map is set to the map object" );
t.ok( map.controls[2] === control, "map.controls contains control" );
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Control div zIndexed properly" );
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Viewport div contains control div" );
t.eq( control.div.style.top, "6px", "Control div top located correctly by default");
}
function test_03_Control_MouseToolbar_control_events (t) {
t.plan( 1 );
if ((navigator.userAgent.indexOf("compatible") == -1)) {
var evt = {which: 1}; // control expects left-click
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(layer);
control = new OpenLayers.Control.MouseToolbar();
map.addControl(control);
var centerLL = new OpenLayers.LonLat(0,0);
map.setCenter(centerLL, 5);
evt.shiftKey = true;
evt.xy = new OpenLayers.Size(5,5);
control.defaultMouseDown(evt);
evt.xy = new OpenLayers.Size(15,15);
control.defaultMouseUp(evt);
t.eq(map.getZoom(), 6, "Map zoom set correctly after zoombox");
} else {
t.ok(true, "IE does not run this test.")
}
}
// -->
</script>
</head>
<body>
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>
+1 -1
View File
@@ -21,7 +21,7 @@
t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" ); t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
t.eq( feature.layer, layer, "feature.layer set correctly" ); t.eq( feature.layer, layer, "feature.layer set correctly" );
t.ok( feature.id.startsWith("Feature_"), "feature.id set correctly" ); t.ok( feature.id.startsWith("OpenLayers.Feature_"), "feature.id set correctly" );
t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" ); t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" );
t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" ); t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" );
t.ok( feature.data.iconSize.equals(iconSize), "feature.data.iconSize set correctly" ); t.ok( feature.data.iconSize.equals(iconSize), "feature.data.iconSize set correctly" );
+5 -6
View File
@@ -5,7 +5,7 @@
var layer; var layer;
function test_01_Layer_constructor (t) { function test_01_Layer_constructor (t) {
t.plan( 14 ); t.plan( 13 );
var options = { chicken: 151, foo: "bar", projection: "none" }; var options = { chicken: 151, foo: "bar", projection: "none" };
var layer = new OpenLayers.Layer('Test Layer', options); var layer = new OpenLayers.Layer('Test Layer', options);
@@ -15,7 +15,6 @@
t.eq( layer.name, "Test Layer", "layer.name is correct" ); t.eq( layer.name, "Test Layer", "layer.name is correct" );
t.ok( layer.id != null, "Layer is given an id"); t.ok( layer.id != null, "Layer is given an id");
t.ok( layer.id.startsWith("Layer_"), "layer id starts correctly");
t.ok( layer.projection, "none", "default layer projection correctly set"); t.ok( layer.projection, "none", "default layer projection correctly set");
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" ); t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" ); t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
@@ -104,10 +103,10 @@
var layer = new OpenLayers.Layer('Test Layer', options); var layer = new OpenLayers.Layer('Test Layer', options);
t.eq(layer.getProjection(), projection, "getProjection() works"); t.eq(layer.projection, projection, "projection set correctly");
t.ok(layer.getMaxExtent().equals(maxExtent), "getMaxExtent() works"); t.ok(layer.maxExtent.equals(maxExtent), "maxExtent set correctly");
t.eq(layer.getMaxResolution(), maxResolution, "getMaxResolution() works"); t.eq(layer.maxResolution, maxResolution, "maxResolution set correctly");
t.eq(layer.getNumZoomLevels(), numZoomLevels, "getNumZoomLevels() works"); t.eq(layer.numZoomLevels, numZoomLevels, "numZoomLevels set correctly");
} }
function test_05_Layer_visibility(t) { function test_05_Layer_visibility(t) {
+1 -1
View File
@@ -57,7 +57,7 @@
// t.plan( 2 ); // t.plan( 2 );
if (document.createEventObject) { if (document.createEventObject) {
t.plan(3); t.plan(2);
} else { } else {
t.plan(1); t.plan(1);
} }
+1 -1
View File
@@ -104,7 +104,7 @@
bounds = new OpenLayers.Bounds(10,10,100,100); bounds = new OpenLayers.Bounds(10,10,100,100);
zoom = layer.getZoomForExtent(bounds); zoom = layer.getZoomForExtent(bounds);
t.eq( zoom, 3, "getZoomForExtent() returns correct value"); t.eq( zoom, 2, "getZoomForExtent() returns correct value");
} }
+1 -1
View File
@@ -97,7 +97,7 @@
bounds = new OpenLayers.Bounds(10,10,100,100); bounds = new OpenLayers.Bounds(10,10,100,100);
zoom = layer.getZoomForExtent(bounds); zoom = layer.getZoomForExtent(bounds);
t.eq( zoom, 3, "getZoomForExtent() returns correct value"); t.eq( zoom, 2, "getZoomForExtent() returns correct value");
} }
+128
View File
@@ -0,0 +1,128 @@
<html>
<head>
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var layer;
function test_01_Layer_MultiMap_constructor (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
map.addLayer(layer);
t.ok( layer instanceof OpenLayers.Layer.MultiMap, "new OpenLayers.Layer.MultiMap returns object" );
t.eq( layer.CLASS_NAME, "OpenLayers.Layer.MultiMap", "CLASS_NAME variable set correctly");
t.eq( layer.name, "Goog Layer", "layer.name is correct" );
t.ok ( layer.multimap != null, "MultiMap Object correctly loaded");
}
function test_02_Layer_MultiMap_isBaseLayer (t) {
t.plan(1);
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
}
function test_03_Layer_MultiMap_Translation_zoom (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
map.addLayer(layer);
// these two lines specify an appropriate translation.
// the code afterwards works by itself to test that translation
// works correctly both ways.
var gZoom = 5;
var correspondingOLZoom = 4;
olZoom = layer.getOLZoomFromMMZoom(gZoom);
t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
t.eq(layer.getMMZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
t.ok( layer.getMMZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
t.ok( layer.getOLZoomFromMMZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
}
function test_04_Layer_MultiMap_Translation_lonlat (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
map.addLayer(layer);
// these two lines specify an appropriate translation.
// the code afterwards works by itself to test that translation
// works correctly both ways.
var gLatLng = new MMLatLon(50,100);
var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
olLonLat = layer.getOLLonLatFromMMLatLong(gLatLng);
t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
var transGLatLng = layer.getMMLatLongFromOLLonLat(olLonLat);
t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
t.ok( layer.getMMLatLongFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
t.ok( layer.getOLLonLatFromMMLatLong(null) == null, "getOLLonLatFromGLatLng(null) returns null");
}
function test_05_Layer_MultiMap_Translation_pixel (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
map.addLayer(layer);
// these two lines specify an appropriate translation.
// the code afterwards works by itself to test that translation
// works correctly both ways.
var gPoint = new MMPoint(50,100);
var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
olPixel = layer.getOLPixelFromPixel(gPoint);
t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
var transGPoint = layer.getPixelFromOLPixel(olPixel);
t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
t.ok( layer.getPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
t.ok( layer.getOLPixelFromPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
}
function test_99_Layer_destroy (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.MultiMap('Test Layer');
map.addLayer(layer);
layer.destroy();
t.eq( layer.name, null, "layer.name is null after destroy" );
t.eq( layer.div, null, "layer.div is null after destroy" );
t.eq( layer.map, null, "layer.map is null after destroy" );
t.eq( layer.options, null, "layer.options is null after destroy" );
t.eq( layer.multimap, null, "layer.gmap is null after destroy" );
}
// -->
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
+25
View File
@@ -150,6 +150,31 @@
} }
function test_08_Layer_WMS_setOpacity (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(tLayer.div.firstChild.style.opacity, "0.5", "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(tLayer.div.firstChild.style.opacity, "0.6", "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(tile.imgDiv.style.opacity, "0.6", "Tile opacity is set correctly");
}
function test_99_Layer_WMS_destroy (t) { function test_99_Layer_WMS_destroy (t) {
t.plan( 1 ); t.plan( 1 );
+9
View File
@@ -14,6 +14,15 @@
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly"); t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
} }
function test_01a_LonLat_constructorFromStrings (t) {
t.plan( 4 );
lonlat = new OpenLayers.LonLat("6", "5");
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
}
function test_02_LonLat_toString(t) { function test_02_LonLat_toString(t) {
t.plan( 1 ); t.plan( 1 );
lonlat = new OpenLayers.LonLat(5,6); lonlat = new OpenLayers.LonLat(5,6);
+9
View File
@@ -13,6 +13,15 @@
t.eq( pixel.y, 6, "pixel.y is set correctly"); t.eq( pixel.y, 6, "pixel.y is set correctly");
} }
function test_01a_Pixel_constructorFromString (t) {
t.plan( 4 );
pixel = new OpenLayers.Pixel("5","6");
t.ok( pixel instanceof OpenLayers.Pixel, "new OpenLayers.Pixel returns Pixel object" );
t.eq( pixel.CLASS_NAME, "OpenLayers.Pixel", "pixel.CLASS_NAME is set correctly");
t.eq( pixel.x, 5, "pixel.x is set correctly");
t.eq( pixel.y, 6, "pixel.y is set correctly");
}
function test_02_Pixel_toString(t) { function test_02_Pixel_toString(t) {
t.plan( 1 ); t.plan( 1 );
pixel = new OpenLayers.Pixel(5,6); pixel = new OpenLayers.Pixel(5,6);
+5 -7
View File
@@ -12,7 +12,8 @@
popup = new OpenLayers.Popup(); popup = new OpenLayers.Popup();
t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" ); t.ok( popup instanceof OpenLayers.Popup, "new OpenLayers.Popup returns Popup object" );
t.ok(popup.id.startsWith("Popup"), "good default popup.id"); t.ok(popup.id.startsWith("OpenLayers.Popup"), "valid default popupid");
var firstID = popup.id;
t.ok(popup.size.equals(size), "good default popup.size"); t.ok(popup.size.equals(size), "good default popup.size");
t.eq(popup.contentHTML, "", "good default popup.contentHTML"); t.eq(popup.contentHTML, "", "good default popup.contentHTML");
t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor"); t.eq(popup.backgroundColor, OpenLayers.Popup.COLOR, "good default popup.backgroundColor");
@@ -20,12 +21,9 @@
t.eq(popup.border, OpenLayers.Popup.BORDER, "good default popup.border"); t.eq(popup.border, OpenLayers.Popup.BORDER, "good default popup.border");
var oldIndex = parseInt(popup.id.slice("Popup".length));
popup = new OpenLayers.Popup(); popup = new OpenLayers.Popup();
var newIndex = parseInt(popup.id.slice("Popup".length)); var newID = popup.id;
t.ok(newID != firstID, "default id generator creating unique ids");
t.eq(newIndex, oldIndex + 1, "default id generator incrementing correctly");
} }
function test_02_Popup_constructor (t) { function test_02_Popup_constructor (t) {
@@ -75,7 +73,7 @@
popup.setBorder(border); popup.setBorder(border);
popup.draw(new OpenLayers.Pixel(x, y)); popup.draw(new OpenLayers.Pixel(x, y));
t.eq(popup.div.id, id + "_div", "popup.div.id set correctly"); t.eq(popup.div.id, id, "popup.div.id set correctly");
t.eq(popup.div.style.left, x + "px", "left position of popup.div set correctly"); t.eq(popup.div.style.left, x + "px", "left position of popup.div set correctly");
t.eq(popup.div.style.top, y + "px", "top position of popup.div set correctly"); t.eq(popup.div.style.top, y + "px", "top position of popup.div set correctly");
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly"); t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly");
+9
View File
@@ -13,6 +13,15 @@
t.eq( size.h, 6, "size.h is set correctly"); t.eq( size.h, 6, "size.h is set correctly");
} }
function test_01a_Size_constructorFromString (t) {
t.plan( 4 );
size = new OpenLayers.Size("5","6");
t.ok( size instanceof OpenLayers.Size, "new OpenLayers.Size returns size object" );
t.eq( size.CLASS_NAME, "OpenLayers.Size", "size.CLASS_NAME is set correctly");
t.eq( size.w, 5, "size.w is set correctly");
t.eq( size.h, 6, "size.h is set correctly");
}
function test_02_Size_toString(t) { function test_02_Size_toString(t) {
t.plan( 1 ); t.plan( 1 );
size = new OpenLayers.Size(5,6); size = new OpenLayers.Size(5,6);
+5 -11
View File
@@ -121,11 +121,9 @@ class Config:
for line in open(filename) for line in open(filename)
if line != "\n"] # Skip blank lines if line != "\n"] # Skip blank lines
self.forceFirst = \ self.forceFirst = lines[lines.index("[first]") + 1:lines.index("[last]")]
lines[lines.index("[first]") + 1:lines.index("[last]")]
self.forceLast = \ self.forceLast = lines[lines.index("[last]") + 1:lines.index("[exclude]")]
lines[lines.index("[last]") + 1:lines.index("[exclude]")]
self.exclude = lines[lines.index("[exclude]") + 1:] self.exclude = lines[lines.index("[exclude]") + 1:]
@@ -163,9 +161,7 @@ if __name__ == "__main__":
allFiles.append(filepath) allFiles.append(filepath)
## Header inserted at the start of each file in the output ## Header inserted at the start of each file in the output
HEADER = "/* " + "=" * 70 + "\n"\ HEADER = "/* " + "=" * 70 + " %s\n" + " " + "=" * 70 + " */\n\n"
" %s\n" +\
" " + "=" * 70 + " */\n\n"
files = {} files = {}
@@ -200,12 +196,10 @@ if __name__ == "__main__":
## Move forced first and last files to the required position ## Move forced first and last files to the required position
if cfg: if cfg:
print "Re-ordering files...\n" print "Re-ordering files...\n"
order = cfg.forceFirst + \ order = cfg.forceFirst + [item
[item
for item in order for item in order
if ((item not in cfg.forceFirst) and if ((item not in cfg.forceFirst) and
(item not in cfg.forceLast))] + \ (item not in cfg.forceLast))] + cfg.forceLast
cfg.forceLast
## Double check all dependencies have been met ## Double check all dependencies have been met
for fp in order: for fp in order: