Compare commits

...

66 Commits

Author SHA1 Message Date
crschmidt
6a7dab4ea8 Tag RC3.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.1-rc3@1502 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-26 20:24:20 +00:00
crschmidt
c7c21ea08a Pullup changes since RC2. Fixes:
* WorldWind layer working again
 * Popup.destroy() complaints
 * Decompose marker destruction code for easier subclassing.
 * Error catching for better layerPx error in Map.js
 * Several eamples, including getFeatureInfo, fullScreen, worldwind,
   layer-opacity


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1501 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-26 20:24:00 +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
93 changed files with 4235 additions and 1900 deletions

View File

@@ -1,10 +1,19 @@
#!/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><head><title>OpenLayers Class Reference Documentation</title><style type='text/css'> .type { background-color: #ddd } td { border: black solid 1px; padding: 3px; } table { border-collapse: collapse; margin: 5px 10px; } .classref { margin-left: 20px; } echo "<html>
<head>
<title>OpenLayers Class Reference Documentation</title>
<style type='text/css'>
.type { background-color: #ddd }
td { border: black solid 1px; padding: 3px; }
table { border-collapse: collapse; margin: 5px 10px; }
.classref { margin-left: 20px; }
div.index { float:left; width: 300px; } div.index { float:left; width: 300px; }
</style></head><body>" >> ../doc/reference.html </style>
</head>
<body>" >> ../doc/reference.html
for i in $CLASSES; do for i in $CLASSES; do
echo "<div class='index'><a href='#OpenLayers.$i'>OpenLayers.$i</a></div>" >> ../doc/reference.html echo "<div class='index'><a href='#OpenLayers.$i'>OpenLayers.$i</a></div>" >> ../doc/reference.html
@@ -14,16 +23,17 @@ echo "<br style='clear:both' />" >> ../doc/reference.html
for i in $CLASSES; do for i in $CLASSES; do
cat ../doc/$i.txt | \ cat ../doc/$i.txt | \
perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g' | \ perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g;
perl -pe 's!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g' | \ s!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g;
perl -pe 's!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!' | \ s!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!;
perl -pe 's!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g' | \ s!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g;
perl -pe 's!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!' | \ s!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!;
perl -pe 's!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g' | \ s!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g;
perl -pe 's!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g' | \ s!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g;
perl -pe 's!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!' | \ s!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!;
perl -pe 's!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \ s!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \
>> ../doc/reference.html >> ../doc/reference.html
echo '</table></div>' >> ../doc/reference.html echo '</table></div>' >> ../doc/reference.html
done done
echo "</body></html>" >> ../doc/reference.html echo " </body>
</html>" >> ../doc/reference.html

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.

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.

View File

@@ -1,6 +1,7 @@
OpenLayers.Layer.GeoRSS OpenLayers.Layer.GeoRSS
GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map. GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map. The GeoRSS layer supports 1.0 and 2.0 in IE and Firefox, and supports 2.0 in Safari. (Ticket #111 explains the reason for this difference.)
* Constructor * Constructor
OpenLayers.Layer.GeoRSS(name, url) -- Name and location of GeoRSS XML file. OpenLayers.Layer.GeoRSS(name, url) -- Name and location of GeoRSS XML file.

View File

@@ -1,6 +1,8 @@
OpenLayers.Layer.WMS OpenLayers.Layer.WMS
The WMS layer allows one to connect to a WMS server to obtain images. The WMS layer allows one to connect to a WMS server to obtain images. Params are available as a hash on the layer object, however, all keys are upper-cased automatically for maximum compatibility with WMS servers, so a parameter which is set as 'layers' will be uppercased to LAYERS. Where 'layer' is your Javscript variable for the layer, layer.params.LAYERS is the value of the layers param as set by the constructor.
If you wish to change params, you should use mergeNewParams, rather than accessing the parameters directly.
* Constructor * Constructor
OpenLayers.Layer.WMS(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer. OpenLayers.Layer.WMS(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer.
@@ -9,5 +11,5 @@ The WMS layer allows one to connect to a WMS server to obtain images.
getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a WMS URL for the given bounds based on the properties of the layer. getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a WMS URL for the given bounds based on the properties of the layer.
All other methods are inherited from {OpenLayers.Layer.Grid} All other methods are inherited from {OpenLayers.Layer.Grid}
* Parameters * Options
isBaseLayer -- WMS layers default to being base layers unless one of their parameters is 'transparent':'true'. isBaseLayer -- WMS layers default to being base layers unless one of their parameters is 'transparent':'true'.

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
doc/Util.txt Normal file
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).

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
examples/canvas.html Normal file
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>

40
examples/fullScreen.html Normal file
View File

@@ -0,0 +1,40 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 100%;
height: 100%;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"});
var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" });
map.addLayers([ol_wms, jpl_wms, dm_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<style type="text/css">
ul, li { padding-left: 0px; margin-left: 0px; }
</style>
<title>World Map Query</title>
</head>
<body>
<a id='permalink' href="">Permalink</a><br />
<div style="float:right;width:28%">
<h1 style="font-size:1.3em;">CIA Factbook</h1>
<p style='font-size:.8em;'>Click a country to see statistics about the country below.</p>
<div id="nodeList">
</div>
</div>
<div id="map" style="width:70%; height:90%"></div>
<script defer="defer" type="text/javascript">
OpenLayers.ProxyHost = "/dev/examples/proxy.cgi?url=";
var map = new OpenLayers.Map('map', {'maxResolution':'auto'});
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/factbook.map", {'layers': 'factbook'} );
map.addLayer(wms);
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
map.zoomToMaxExtent();
map.events.register('click', map, function (e) {
var url = wms.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: wms.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: wms.params.LAYERS,
WIDTH: wms.map.size.w,
HEIGHT: wms.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);
Event.stop(e);
});
function setHTML(response) {
$('nodeList').innerHTML = response.responseText;
}
</script>
</body>
</html>

View File

@@ -23,20 +23,23 @@
var map, layer; var map, layer;
function init(){ function init(){
map = new OpenLayers.Map( $('map') ); map = new OpenLayers.Map( $('map') ,
{ controls: [new OpenLayers.Control.MouseDefaults()] });
var normal = new OpenLayers.Layer.Google( "Google" ); var normal = new OpenLayers.Layer.Google( "Google", // );
{ minZoomLevel: 3, maxZoomLevel: 8 });
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP }); var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP });
var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP }); var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
map.addLayers([normal, satellite, hybrid]); map.addLayers([satellite, normal, hybrid]);
markers = new OpenLayers.Layer.Markers("markers"); markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers); map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() ); map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
} }

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," +

View File

@@ -0,0 +1,86 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
font-family: sans-serif;
}
#map {
width: 512px;
height: 350px;
border: 1px solid lightgray;
}
p {
width: 512px;
}
a {
text-decoration: none;
color: black;
font-weight: bold;
font-size: 1.1em;
}
#opacity {
padding: 0;
text-align: center;
width: 2em;
font-family: sans-serif;
background: transparent;
color: black;
border: 0;
}
p.note {
font-style: italic;
font-size: 0.8em;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map = null;
var shade = null;
var maxOpacity = 0.9;
var minOpacity = 0.1;
function changeOpacity(byOpacity) {
var newOpacity = (parseFloat($F('opacity')) + byOpacity).toFixed(1);
newOpacity = Math.min(maxOpacity,
Math.max(minOpacity, newOpacity));
$('opacity').value = newOpacity;
shade.setOpacity(newOpacity);
}
function init(){
var options = {
projection: "EPSG:26912",
units: 'm',
maxExtent: new OpenLayers.Bounds(455402, 4967657, 473295, 4984095),
maxResolution: 'auto',
maxZoomLevel: 8
};
map = new OpenLayers.Map('map', options);
var drg = new OpenLayers.Layer.WMS("Topo Maps",
"http://terraservice.net/ogcmap.ashx",
{layers: "DRG"});
shade = new OpenLayers.Layer.WMS("Shaded Relief",
"http://ims.cr.usgs.gov:80/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3",
{layers: "HR-NED.IMAGE", reaspect: "false", transparent: 'true'},
{isBaseLayer: false, opacity: 0.3});
map.addLayers([drg, shade]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(464348.5,4975876), 1);
}
// -->
</script>
</head>
<body onload="init()">
<h2>OpenLayers Layer Opacity Example</h2>
<div id="map"></div>
<p>
Note that if you also have the setOpacity method defined on the Layer
class, you can tweak the layer opacity after it has been added to the map.
</p>
<p>Opacity:
<a title="decrease opacity" href="javascript: changeOpacity(-0.1);">&lt;&lt;</a>
<input id="opacity" type="text" value="0.3" size="3" disabled="true" />
<a title="increase opacity" href="javascript: changeOpacity(0.1);">&gt;&gt;</a>
</p>
<p class="note">IE users: Wait until the shade layer has finished loading to try this.</p>
</body>
</html>

58
examples/mm.html Normal file
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>

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);

View File

@@ -20,7 +20,7 @@ url = fs.getvalue('url', "http://openlayers.org")
# Designed to prevent Open Proxy type stuff. # Designed to prevent Open Proxy type stuff.
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com'] allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in']
try: try:
host = url.split("/")[2] host = url.split("/")[2]

151
examples/scroll.html Normal file
View File

@@ -0,0 +1,151 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>OpenLayers: Home</title>
<link rel="stylesheet" href="http://openlayers.org/common.css" type="text/css" />
<link rel="stylesheet" href="http://trac.openlayers.org/chrome/common/css/trac.css" type="text/css" />
<link rel="stylesheet" href="http://trac.openlayers.org/chrome/common/css/wiki.css" type="text/css" />
<link rel="stylesheet" href="http://trac.openlayers.org/chrome/common/css/tracnav.css" type="text/css" />
<link rel="stylesheet" href="http://openlayers.org/website.css" type="text/css" />
<script type="text/javascript" src="//trac.openlayers.org/chrome/common/js/trac.js"></script>
<!--[if lt IE 7]>
<script defer="defer" type="text/javascript" src="/pngfix.js"></script>
<![endif]-->
</head>
<body>
<div id="olbanner">
<img class="openlayersbannerimg" src="http://www.openlayers.org/images/OpenLayers.trac.png" style="height: 44px; width: 49px" border="0" alt="OpenLayers" />
<a class="openlayersbanner" href="http://www.openlayers.org/" >
OpenLayers</a>
</div>
<div id="navcontainer">
<a class="navtabtraccurrent" href="http://www.openlayers.org">Home</a>
<a class="navtab" href="http://trac.openlayers.org">Support &amp; Development</a>
</div>
<div id="mainnav" class="nav"><ul><li class="first"><a href="http://trac.openlayers.org/wiki" accesskey="1">Wiki</a></li><li><a href="/QuickTutorial" accesskey="2">Tutorial</a></li><li><a href="http://trac.openlayers.org/wiki/HowToDownload" accesskey="3">Download</a></li><li><a href="/gallery">Gallery</a></li><li><a href="/EmailLists">Email Lists</a></li></ul></div>
<div id="main">
<div id="mapFrame">
<div id="map"></div>
<div align="center"><b>Put an open map widget in any web page!</b></div>
<div align="center">
Double-click to zoom in, and drag to pan. Hold down the shift key
and drag to zoom to a particular region.
</div>
</div>
<h3>Get OpenLayers Now</h3>
<p>
Latest stable release: <a href="/api/2/OpenLayers.js">Link to the hosted version</a> | <a href="/download/OpenLayers-2.0.tar.gz">OpenLayers-2.0.tar.gz</a> | <a href="/doc/reference.html">Class Documentation</a> | <a href="/gallery/">See Screenshots</a>
</p>
<p><b>Latest Development Release</b>: Test out OpenLayers 2.1-RC2! <a href="/api/2.1-rc2/OpenLayers.js">Link to 2.1-RC2 Hosted Version</a>.</p>
<p><b>FOSS4G</b>: Was the FOSS4G presentation too early for you this morning? The presentation is <a href="http://openlayers.org/presentations/foss4g2006/openlayers.odp">available in Open Office Impress format</a>, and the examples are <a href="http://openlayers.org/presentations/foss4g2006/examples/">available as well</a>.</p>
<h3>About...</h3>
<p>OpenLayers makes it easy to put a dynamic map in any web page. It can
display map tiles and markers loaded from any source. <a
href="http://www.metacarta.com/">MetaCarta</a> developed the initial version of
OpenLayers and gave it to the public to further the use of geographic
information of all kinds. OpenLayers is
completely free, Open Source JavaScript, released under the BSD License.</p>
<h3>Put a map in your page.</h3>
<p>We've released a Map Viewer Service that lets you put a map in your page easily. Just put this HTML in your page:</p>
<pre>
&lt;iframe src="http://openlayers.org/viewer/"
width="400px" height="200px"
scrolling="no"
marginwidth="0" marginheight="0"
frameborder="0"&gt;
&lt;/iframe&gt;</pre>
<p>Read more examples in the <a href="QuickTutorial">20-second tutorial</a>. The visual appearance of the MapViewer is not yet stable. If you like it, please join the <a href="EmailLists">users' email list</a> and tell us about your use.</p>
<h3>For Developers!</h3>
<p>OpenLayers is a pure JavaScript library for displaying map data in most
modern web browsers, with no server-side dependencies. OpenLayers implements a
(still-developing) <a href="//trac.openlayers.org/wiki/Documentation">JavaScript
API</a> for building rich web-based geographic applications, similar to the
Google Maps and MSN Virtual Earth APIs, with one important difference --
OpenLayers is Free Software, developed for and by the Open Source software
community.</p>
<p>Furthermore, OpenLayers implements industry-standard methods for geographic
data access, such as the OpenGIS Consortium's Web Mapping Service (WMS) and Web
Feature Service (WFS) protocols. Under the hood, OpenLayers is written in
object-oriented JavaScript, using <a
href="//prototype.conio.net/">Prototype.js</a> and components from the <a
href="//openrico.org/">Rico<a> library. The OpenLayers code base already has
hundreds of <a href="/dev/tests/run-tests.html">unit tests</a>, via the <a
href="http://straytree.com/TestAnotherWay/doc/index.html">Test.AnotherWay</a>
framework.</p>
<p>As a framework, OpenLayers is intended to separate map <i>tools</i> from map
<i>data</i> so that all the tools can operate on all the data sources. This
separation breaks the proprietary silos that earlier GIS revolutions have
taught civilization to avoid. The mapping revolution on the public Web should
benefit from the experience of history.</p>
<h3>Getting the Code</h3>
<p>Releases are made available on the <a href="/download/">downloads</a> page.
Additionally, if you wish to use OpenLayers in a web application, you can
include
<tt>
<a href="http://www.openlayers.org/api/OpenLayers.js">http://www.openlayers.org/api/OpenLayers.js</a>
</tt> in your page, to always get the latest release.</p>
<p> The code is also available in our
<a href="//trac.openlayers.org/wiki/HowToDownload">Subversion repository</a>.
Using Subversion, you can keep up to the absolute bleeding edge of the code.
If you wish to report a bug in the API, and you are able to use Subversion,
please see if the bug has been fixed in Subversion first: OpenLayers is
under rapid development, so things change quickly.
</p>
<p>If you don't have Subversion or don't want to download the code, you can
still try some <a href="/dev/examples/">live examples</a> on
openlayers.org. If you're familiar with JavaScript, try viewing the source
of the examples to get an idea how the OpenLayers library is used.</p>
<p>OpenLayers is still undergoing rapid development, so expect a lot to change
in the next few weeks and months. We need your support! Please check the <a
href="//trac.openlayers.org">wiki</a> for the very latest updates and
documentation, and thank you for taking an interest.</p>
</div>
<script type="text/javascript" src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "World Map",
"http://labs.metacarta.com/wms/vmap0?",
{layers: 'basic'} );
var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite",
"/world/index.php", {g: "satellite", map: "world"});
var dm_wms = new OpenLayers.Layer.WMS( "Canada",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" });
dm_wms.setVisibility(false);
map.addLayers([ol_wms, jpl_wms, dm_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
// -->
</script>
<div id="sidebar"></div>
<div id="footer"></div>
</div>
</body>
</html>

29
examples/setextent.html Normal file
View File

@@ -0,0 +1,29 @@
<html>
<head>
<title>Setting a visual Extent</title>
<script src="../lib/OpenLayers.js"></script>
</head>
<body>
<h1>Setting a Visual Extent</h1>
<p>
Because the ability to set the map to a given extent is limited by the
current resolutions available, zoomToExtent will not always set the map to
exactly the right extent. In order to visually annotate the actual extent,
this example, will use the Boxes layer to visually describe the desired
extent as well as setting the map extent.
</p>
<div style="width:100%; height:75%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var bounds = new OpenLayers.Bounds(-45,-45, 0, 45);
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToExtent(bounds);
var boxes = new OpenLayers.Layer.Boxes("boxes");
var box = new OpenLayers.Marker.Box(bounds);
boxes.addMarker(box);
map.addLayer(boxes);
</script>
</body>
</html>

View File

@@ -14,11 +14,12 @@
var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/4, controls:[]}); var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/4, controls:[]});
var ka_wms = new OpenLayers.Layer.KaMap( "TIGER (KaMap)", var ka_wms = new OpenLayers.Layer.KaMap( "TIGER (KaMap)",
"http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' }, 'degrees', 72 ); "http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' });
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic", var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi", "http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"}); {layers: "modis,global_mosaic"});
jpl_wms.setVisibility(false); jpl_wms.setVisibility(false);
ka_wms.isBaseLayer = false;
map.addLayers([jpl_wms,ka_wms]); map.addLayers([jpl_wms,ka_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MouseToolbar()); map.addControl(new OpenLayers.Control.MouseToolbar());

View File

@@ -11,15 +11,15 @@
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
function init(){ function init(){
var map = new OpenLayers.Map('map', {'maxResolution': 1.6, maxZoomLevel:20}); var mapOptions = { maxResolution: 1.6, numZoomLevels: 21};
var map = new OpenLayers.Map('map', mapOptions);
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
var ww = new OpenLayers.Layer.WorldWind( "Urban", var ww = new OpenLayers.Layer.WorldWind( "Urban",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", .8, 9, "http://worldwind25.arc.nasa.gov/tile/tile.aspx?", .8, 9,
{T:"104"}); {T:"104"}, { tileSize: new OpenLayers.Size(512,512) });
ww.setTileSize(new OpenLayers.Size(512,512));
map.addLayers([ol_wms, ww]); map.addLayers([ol_wms, ww]);

View File

@@ -18,20 +18,23 @@
var lon = 5; var lon = 5;
var lat = 40; var lat = 40;
var zoom = 5; var zoom = 15;
var map, velayer, layer; var map, velayer, layer;
function init(){ function init(){
map = new OpenLayers.Map( $('map') ); map = new OpenLayers.Map( $('map') ,
{controls:[new OpenLayers.Control.MouseDefaults()]});
velayer = new OpenLayers.Layer.VirtualEarth( "VE"); velayer = new OpenLayers.Layer.VirtualEarth( "VE",
{ minZoomLevel: 4, maxZoomLevel: 6 });
map.addLayer(velayer); map.addLayer(velayer);
markers = new OpenLayers.Layer.Markers("markers"); markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers); map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), 2); map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() ); map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
} }
function add() { function add() {

View File

@@ -35,7 +35,7 @@ var map,ia_wms;
<body onload="init()"> <body onload="init()">
<h1>OpenLayers Example</h1> <h1>OpenLayers Example</h1>
<p>WMS-T example: update the times, and the radar image will change. Uses Layer.changeParams. Thanks to David Bitner for the inspiration, the original code, and the kick in the butt!</p> <p>WMS-T example: update the times, and the radar image will change. Uses Layer.changeParams. Thanks to David Bitner for the inspiration, the original code, and the kick in the butt!</p>
<input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.changeParams({"time":this.value});' > <input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.mergeNewParams({"time":this.value});' >
<div id="map"></div> <div id="map"></div>
</body> </body>
</html> </html>

View File

@@ -10,20 +10,19 @@
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var ol_wms, ww, ww2;
function init(){ function init(){
var map = new OpenLayers.Map('map', {'maxResolution': .0703125*4}); var map = new OpenLayers.Map('map', {'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
var ww = new OpenLayers.Layer.WorldWind( "Bathy", ww = new OpenLayers.Layer.WorldWind( "Bathy",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4, "http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4,
{T:"bmng.topo.bathy.200406"}); {T:"bmng.topo.bathy.200406"});
ww.setTileSize(new OpenLayers.Size(512,512)); ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
var ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4,
{T:"105"}); {T:"105"});
ww2.setTileSize(new OpenLayers.Size(512,512));
@@ -37,5 +36,7 @@
<body onload="init()"> <body onload="init()">
<h1>OpenLayers Example</h1> <h1>OpenLayers Example</h1>
<div id="map"></div> <div id="map"></div>
<p>This is a demonstration of using Tiled WorldWind layers. WorldWind requires you to define a "LZTD" -- the 3rd param of the constructor -- and the number of zoom levels it supports. When a worldwind layer is not visible at a given tile level, and empty tile is placed there instead. Note that the maxResolution of the map times 512px, must be a multiple of a power of two different from the LZTD -- in this case, .28125 * 512 is 144, which is 36*4, and 2.25*64.</p>
<p>This example has a 'Bathy' layer, visible as you zoom out, and a 'landsat' layer, visible as you zoom in, both visible at zoom level 6.</p>
</body> </body>
</html> </html>

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>

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">
<!-- <!--

54
examples/zoomLevels.html Normal file
View File

@@ -0,0 +1,54 @@
<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>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 50;
var lat = 0;
var zoom = 0;
var map, layer;
function init(){
var options = {
// resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101],
// scales: [50000000, 10000000],
// maxResolution: 0.17578125,
// minResolution: 0.0439453125,
// maxScale: 10000000,
// minScale: 50000000,
minResolution: "auto",
minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
maxResolution: "auto",
maxExtent: new OpenLayers.Bounds(-180, -90, 90, 180),
// numZoomLevels: 5,
controls: [new OpenLayers.Control.MouseDefaults()]
};
map = new OpenLayers.Map( $('map') , options);
map.addControl(new OpenLayers.Control.PanZoomBar());
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

BIN
img/blank.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 B

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

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",

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);
}, },
/** /**
@@ -420,7 +420,7 @@ OpenLayers.Bounds.prototype = {
* @type OpenLayers.Bounds * @type OpenLayers.Bounds
*/ */
add:function(x, y){ add:function(x, y){
return new OpenLayers.Box(this.left + x, this.bottom + y, return new OpenLayers.Bounds(this.left + x, this.bottom + y,
this.right + x, this.top + y); this.right + x, this.top + y);
}, },

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();

View File

@@ -119,16 +119,18 @@ OpenLayers.Control.LayerSwitcher.prototype =
inputElem.type = (baseLayer) ? "radio" : "checkbox"; inputElem.type = (baseLayer) ? "radio" : "checkbox";
inputElem.value = layer.name; inputElem.value = layer.name;
inputElem.checked = checked; inputElem.checked = checked;
inputElem.defaultChecked = checked;
inputElem.layer = layer; inputElem.layer = layer;
inputElem.control = this;
Event.observe(inputElem, "mouseup",
this.onInputClick.bindAsEventListener(inputElem));
// 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, Event.observe(labelSpan, "click",
"click", this.onInputClick.bindAsEventListener(inputElem));
this.onLabelClick.bindAsEventListener(inputElem));
// create line break // create line break
var br = document.createElement("br"); var br = document.createElement("br");
@@ -158,11 +160,17 @@ OpenLayers.Control.LayerSwitcher.prototype =
* *
* @param {Event} e * @param {Event} e
*/ */
onLabelClick: function(e) {
var clickedRadioButton = ((this.type == "radio") && (this.checked)); onInputClick: function(e) {
if (!clickedRadioButton) { if (this.type == "radio") {
this.checked = true;
this.layer.map.setBaseLayer(this.layer, true);
this.layer.map.events.triggerEvent("changebaselayer");
} else {
this.checked = !this.checked; this.checked = !this.checked;
this.control.updateMap();
} }
Event.stop(e);
}, },
/** Need to update the map accordingly whenever user clicks in either of /** Need to update the map accordingly whenever user clicks in either of
@@ -189,7 +197,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
for(var i=0; i < this.baseLayerInputs.length; i++) { for(var i=0; i < this.baseLayerInputs.length; i++) {
var input = this.baseLayerInputs[i]; var input = this.baseLayerInputs[i];
if (input.checked) { if (input.checked) {
this.map.setBaseLayer(input.layer, true); this.map.setBaseLayer(input.layer, false);
} }
} }
@@ -271,6 +279,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
Event.observe(this.div, "mouseup", Event.observe(this.div, "mouseup",
this.mouseUp.bindAsEventListener(this)); this.mouseUp.bindAsEventListener(this));
Event.observe(this.div, "click",
this.ignoreEvent);
Event.observe(this.div, "mousedown", Event.observe(this.div, "mousedown",
this.mouseDown.bindAsEventListener(this)); this.mouseDown.bindAsEventListener(this));
Event.observe(this.div, "dblclick", this.ignoreEvent); Event.observe(this.div, "dblclick", this.ignoreEvent);
@@ -301,8 +311,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.baseLayersDiv = document.createElement("div"); this.baseLayersDiv = document.createElement("div");
this.baseLayersDiv.style.paddingLeft = "10px"; this.baseLayersDiv.style.paddingLeft = "10px";
Event.observe(this.baseLayersDiv, "click", /*Event.observe(this.baseLayersDiv, "click",
this.onLayerClick.bindAsEventListener(this)); this.onLayerClick.bindAsEventListener(this));
*/
this.layersDiv.appendChild(this.baseLayersDiv); this.layersDiv.appendChild(this.baseLayersDiv);
@@ -315,8 +326,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.dataLayersDiv = document.createElement("div"); this.dataLayersDiv = document.createElement("div");
this.dataLayersDiv.style.paddingLeft = "10px"; this.dataLayersDiv.style.paddingLeft = "10px";
Event.observe(this.dataLayersDiv, "click", /*Event.observe(this.dataLayersDiv, "click",
this.onLayerClick.bindAsEventListener(this)); this.onLayerClick.bindAsEventListener(this));
*/
this.layersDiv.appendChild(this.dataLayersDiv); this.layersDiv.appendChild(this.dataLayersDiv);
this.div.appendChild(this.layersDiv); this.div.appendChild(this.layersDiv);

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;
} }

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,21 +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( "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;
}, },
@@ -66,9 +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("dblclick", this, Event.stop);
btn.action = id; btn.action = id;
btn.title = title; btn.title = title;
btn.alt = title; btn.alt = title;
@@ -79,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
*/ */
@@ -92,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;
}, },
/** /**
@@ -102,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) {
@@ -122,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 = "";
@@ -144,6 +167,7 @@ OpenLayers.Control.MouseToolbar.prototype =
"absolute"); "absolute");
this.measureBox.style.width="4px"; this.measureBox.style.width="4px";
this.measureBox.style.height="4px"; this.measureBox.style.height="4px";
this.measureBox.style.fontSize = "1px";
this.measureBox.style.backgroundColor="red"; this.measureBox.style.backgroundColor="red";
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.layerContainerDiv.appendChild(this.measureBox); this.map.layerContainerDiv.appendChild(this.measureBox);
@@ -175,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") {
@@ -188,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() {
@@ -205,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";
} }
@@ -235,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) {
@@ -261,11 +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) {
if (this.performedDrag) {
this.performedDrag = false;
return false;
}
}
}));

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");

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,
@@ -25,10 +26,24 @@ OpenLayers.Control.PanZoomBar.prototype =
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments); OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X, this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X,
OpenLayers.Control.PanZoomBar.Y); OpenLayers.Control.PanZoomBar.Y);
},
// put code here to catch "changebaselayer" event from map, because /**
// we are going to have to redraw this thing each time, because * @param {OpenLayers.Map} map
// maxZoom will/might change. */
setMap: function(map) {
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
this.map.events.register("changebaselayer", this, this.redraw);
},
/** clear the div and start over.
*
*/
redraw: function() {
if (this.div != null) {
this.div.innerHTML = "";
}
this.draw();
}, },
/** /**
@@ -37,7 +52,7 @@ OpenLayers.Control.PanZoomBar.prototype =
draw: function(px) { draw: function(px) {
// initialize our internal div // initialize our internal div
OpenLayers.Control.prototype.draw.apply(this, arguments); OpenLayers.Control.prototype.draw.apply(this, arguments);
px = this.position; px = this.position.clone();
// place the controls // place the controls
this.buttons = new Array(); this.buttons = new Array();
@@ -63,15 +78,15 @@ OpenLayers.Control.PanZoomBar.prototype =
var imgLocation = OpenLayers.Util.getImagesLocation(); var imgLocation = OpenLayers.Util.getImagesLocation();
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id; var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
var slider = OpenLayers.Util.createAlphaImageDiv(id, var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1, centered.add(-1, zoomsToEnd * this.zoomStopHeight),
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
new OpenLayers.Size(20,9), new OpenLayers.Size(20,9),
imgLocation+"slider.png", imgLocation+"slider.png",
"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);
@@ -79,7 +94,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.sliderEvents.register("click", this, this.doubleClick); this.sliderEvents.register("click", this, this.doubleClick);
sz = new OpenLayers.Size(); sz = new OpenLayers.Size();
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1); sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
sz.w = this.zoomStopWidth; sz.w = this.zoomStopWidth;
var div = null var div = null
@@ -101,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);
@@ -115,7 +130,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.map.events.register("zoomend", this, this.moveZoomBar); this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0, centered = centered.add(0,
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1)); this.zoomStopHeight * this.map.getNumZoomLevels());
return centered; return centered;
}, },
/* /*
@@ -136,7 +151,7 @@ OpenLayers.Control.PanZoomBar.prototype =
var y = evt.xy.y; var y = evt.xy.y;
var top = Position.page(evt.object)[1]; var top = Position.page(evt.object)[1];
var levels = Math.floor((y - top)/this.zoomStopHeight); var levels = Math.floor((y - top)/this.zoomStopHeight);
this.map.zoomTo(this.map.getMaxZoomLevel() - levels); this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
Event.stop(evt); Event.stop(evt);
}, },
@@ -170,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);
}
}, },
/* /*
@@ -183,8 +198,8 @@ OpenLayers.Control.PanZoomBar.prototype =
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
if (this.zoomStart) { if (this.zoomStart) {
this.div.style.cursor="default"; this.div.style.cursor="default";
this.map.events.remove("mousemove"); this.map.events.unregister("mouseup", this, this.passEventToSlider);
this.map.events.remove("mouseup"); this.map.events.unregister("mousemove", this, this.passEventToSlider);
var deltaY = this.zoomStart.y - evt.xy.y var deltaY = this.zoomStart.y - evt.xy.y
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
this.moveZoomBar(); this.moveZoomBar();
@@ -198,8 +213,8 @@ OpenLayers.Control.PanZoomBar.prototype =
*/ */
moveZoomBar:function() { moveZoomBar:function() {
var newTop = var newTop =
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight ((this.map.getNumZoomLevels()-1) - this.map.getZoom()) *
+ this.startTop + 1; this.zoomStopHeight + this.startTop + 1;
this.slider.style.top = newTop + "px"; this.slider.style.top = newTop + "px";
}, },

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 */

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 + "_");
}, },
/** /**
@@ -63,7 +63,7 @@ OpenLayers.Feature.prototype= {
this.lonlat = null; this.lonlat = null;
this.data = null; this.data = null;
if (this.marker != null) { if (this.marker != null) {
this.marker.destroy(); this.destroyMarker(this.marker);
this.marker = null; this.marker = null;
} }
if (this.popup != null) { if (this.popup != null) {
@@ -89,6 +89,10 @@ OpenLayers.Feature.prototype= {
return this.marker; return this.marker;
}, },
destroyMarker: function() {
this.marker.destroy();
},
/** /**
* *
*/ */

View File

@@ -48,9 +48,8 @@ OpenLayers.Feature.WFS.prototype =
//this should be overridden by subclasses //this should be overridden by subclasses
// must return an Object with 'id' and 'lonlat' values set // must return an Object with 'id' and 'lonlat' values set
var point = xmlNode.getElementsByTagName("Point"); var point = xmlNode.getElementsByTagName("Point");
var text = OpenLayers.Util.getXmlNodeValue(point[0]); var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
var floats = text.split(","); var floats = text.split(",");
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]), return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
parseFloat(floats[1])), parseFloat(floats[1])),
id: null}; id: null};

View File

@@ -44,17 +44,29 @@ 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 int */ /** @type float */
minZoomLevel: null, minResolution: null,
/** @type int */ /** @type int */
maxZoomLevel: null, numZoomLevels: null,
/** @type float */ /** @type float */
minScale: null, minScale: null,
@@ -62,8 +74,6 @@ OpenLayers.Layer.prototype = {
/** @type float */ /** @type float */
maxScale: null, maxScale: null,
/** @type String */
units: null,
/** /**
* @constructor * @constructor
@@ -82,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;
} }
} }
}, },
@@ -148,6 +158,12 @@ OpenLayers.Layer.prototype = {
Object.extend(this, this.options); Object.extend(this, this.options);
}, },
/**
*
*/
onMapResize: function() {
//this function can be implemented by subclasses
},
/** /**
* @param {OpenLayers.Bounds} bound * @param {OpenLayers.Bounds} bound
@@ -163,24 +179,33 @@ OpenLayers.Layer.prototype = {
* so that subclasses can override this and take special action once * so that subclasses can override this and take special action once
* they have their map variable set. * they have their map variable set.
* *
* Here we take care to bring over any of the necessary default properties
* from the map.
*
* @param {OpenLayers.Map} map * @param {OpenLayers.Map} map
*/ */
setMap: function(map) { setMap: function(map) {
this.map = map; this.map = map;
var properties = new Array( var properties = new Array(
'projection', 'minExtent', 'maxExtent', 'projection', 'units',
'minScale', 'maxScale', 'scales', 'resolutions',
'maxScale', 'minScale',
'maxResolution', 'minResolution', 'maxResolution', 'minResolution',
'minZoomLevel', 'maxZoomLevel', 'units', 'minExtent', 'maxExtent',
'scales', 'resolutions' '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();
}
}, },
/** /**
@@ -201,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) &&
@@ -211,101 +236,170 @@ OpenLayers.Layer.prototype = {
} }
}, },
/********************************************************/
/* */
/* Layer Options */
/* */
/* Accessor functions to Layer Options parameters */
/* */
/********************************************************/
/** /**
* @type String * @param {Boolean} isBaseLayer
*/ */
getProjection: function() { setIsBaseLayer: function(isBaseLayer) {
return this.projection; this.isBaseLayer = isBaseLayer;
}, if (this.map != null) {
this.map.events.triggerEvent("changelayer");
/** }
* @type OpenLayers.Bounds
*/
getMaxExtent: function() {
return this.maxExtent;
},
/**
* @type float
*/
getMaxResolution: function() {
return this.maxResolution;
},
/**
* @returns The minimum zoom level that can be reached in this layer
* @type int
*/
getMinZoomLevel: function() {
return this.minZoomLevel;
},
/**
* @returns The maximum zoom level that can be reached in this layer
* @type int
*/
getMaxZoomLevel: function() {
return this.maxZoomLevel;
}, },
/********************************************************/ /********************************************************/
/* */ /* */
/* 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.map.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
@@ -315,15 +409,19 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.LonLat * @type OpenLayers.LonLat
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if (viewPortPx != null) {
var size = this.map.getSize(); var size = this.map.getSize();
var center = this.map.getCenter(); //map center lon/lat var center = this.map.getCenter();
var res = this.map.getResolution(); var res = this.map.getResolution();
var delta_x = viewPortPx.x - (size.w / 2); var delta_x = viewPortPx.x - (size.w / 2);
var delta_y = viewPortPx.y - (size.h / 2); var delta_y = viewPortPx.y - (size.h / 2);
return new OpenLayers.LonLat(center.lon + delta_x * res , lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res); center.lat - delta_y * res);
}
return lonlat;
}, },
/** /**
@@ -334,25 +432,30 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.Pixel * @type OpenLayers.Pixel
*/ */
getViewPortPxFromLonLat: function (lonlat) { getViewPortPxFromLonLat: function (lonlat) {
var px = null;
if (lonlat != null) {
var resolution = this.map.getResolution(); var resolution = this.map.getResolution();
var extent = this.map.getExtent(); var extent = this.map.getExtent();
return new OpenLayers.Pixel( px = new OpenLayers.Pixel(
Math.round(1/resolution * (lonlat.lon - extent.left)), Math.round(1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat)) Math.round(1/resolution * (extent.top - lonlat.lat))
); );
}
return px;
}, },
/** /**
* @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"
}; };

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"
});

View File

@@ -37,9 +37,6 @@ OpenLayers.Layer.EventPane.prototype =
if (arguments.length > 0) { if (arguments.length > 0) {
if (this.pane == null) { if (this.pane == null) {
this.pane = OpenLayers.Util.createDiv(); this.pane = OpenLayers.Util.createDiv();
this.pane.style.width = "100%";
this.pane.style.height = "100%";
this.pane.style.backgroundColor = "transparent";
} }
} }
}, },
@@ -55,12 +52,17 @@ OpenLayers.Layer.EventPane.prototype =
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1; this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
this.pane.style.display = this.div.style.display; this.pane.style.display = this.div.style.display;
this.pane.style.width="100%";
this.pane.style.height="100%";
if (/MSIE/.test(navigator.userAgent)) {
this.pane.style.background = "url("+OpenLayers.Util.getImagesLocation()+"blank.gif)";
}
if (this.isFixed) { if (this.isFixed) {
this.map.viewPortDiv.appendChild(this.pane); this.map.viewPortDiv.appendChild(this.pane);
} else { } else {
this.map.layerContainerDiv.appendChild(this.pane); this.map.layerContainerDiv.appendChild(this.pane);
} }
this.map.events.attachToElement(this.pane);
}, },
/** /**

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"
};

View File

@@ -11,11 +11,6 @@ OpenLayers.Layer.GeoRSS = Class.create();
OpenLayers.Layer.GeoRSS.prototype = OpenLayers.Layer.GeoRSS.prototype =
Object.extend( new OpenLayers.Layer.Markers(), { Object.extend( new OpenLayers.Layer.Markers(), {
/** GeoRSS layer is never a base layer.
* @type Boolean
*/
isBaseLayer: false,
/** store url of text file /** store url of text file
* @type str */ * @type str */
location:null, location:null,
@@ -75,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);

View File

@@ -2,31 +2,8 @@
* 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. */
if (typeof GMap2 != "undefined") {
/** Hack-on function because GMAPS does not give it to us
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div
// it seems like "b" is the main div
var div = this.b.firstChild.firstChild;
// adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop;
return gPoint;
};
}
/** /**
* @class * @class
@@ -35,7 +12,8 @@ if (typeof GMap2 != "undefined") {
*/ */
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,
@@ -49,7 +27,7 @@ OpenLayers.Layer.Google.prototype =
// OPTIONS // OPTIONS
/** @type int */ /** @type int */
minZoomLevel: -1, minZoomLevel: 0,
/** @type int */ /** @type int */
maxZoomLevel: 16, maxZoomLevel: 16,
@@ -62,9 +40,13 @@ 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);
} }
this.addContainerPxFunction();
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
}, },
/** /**
@@ -147,6 +129,13 @@ OpenLayers.Layer.Google.prototype =
} }
}, },
/**
* @param {Event} evt
*/
onMapResize: function() {
this.gmap.checkResize();
},
/** If we can't load the GMap, then display an error message to the /** If we can't load the GMap, then display an error message to the
* user and tell them where to go for help. * user and tell them where to go for help.
* *
@@ -259,6 +248,11 @@ OpenLayers.Layer.Google.prototype =
if ((this.gmap != null) && (this.gmap.getCenter() != null)) { if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
var gZoom = this.gmap.getBoundsZoomLevel(gBounds); var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
//make sure zoom is within bounds
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromGZoom(gZoom); zoom = this.getOLZoomFromGZoom(gZoom);
} }
return zoom; return zoom;
@@ -287,7 +281,7 @@ OpenLayers.Layer.Google.prototype =
getOLZoomFromGZoom: function(gZoom) { getOLZoomFromGZoom: function(gZoom) {
var zoom = null; var zoom = null;
if (gZoom != null) { if (gZoom != null) {
zoom = gZoom; zoom = gZoom - this.minZoomLevel;
} }
return zoom; return zoom;
}, },
@@ -302,7 +296,7 @@ OpenLayers.Layer.Google.prototype =
getGZoomFromOLZoom: function(olZoom) { getGZoomFromOLZoom: function(olZoom) {
var zoom = null; var zoom = null;
if (olZoom != null) { if (olZoom != null) {
zoom = olZoom; zoom = olZoom + this.minZoomLevel;
} }
return zoom; return zoom;
}, },
@@ -417,7 +411,33 @@ OpenLayers.Layer.Google.prototype =
return gLatLngBounds; return gLatLngBounds;
}, },
addContainerPxFunction: function() {
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
/** Hack-on function because GMAPS does not give it to us
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div
// it seems like "b" is the main div
var div = this.b.firstChild.firstChild;
// adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop;
return gPoint;
};
}
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google" CLASS_NAME: "OpenLayers.Layer.Google"
}); }));

View File

@@ -42,7 +42,6 @@ OpenLayers.Layer.Grid.prototype =
destroy: function() { destroy: function() {
this.clearGrid(); this.clearGrid();
this.grid = null; this.grid = null;
this.alpha = null;
this.tileSize = null; this.tileSize = null;
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments); OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
}, },
@@ -88,30 +87,6 @@ OpenLayers.Layer.Grid.prototype =
} }
}, },
/**
* @param {String} tileID
*
* @returns The OpenLayers.Tile with the corresponding ID from the grid.
* if no tile is found, returns null
* @type OpenLayers.Tile
*/
getTile: function(tileID) {
var foundTile = null;
if (this.grid) {
for(var iRow = 0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow];
for(var iCol = 0; iCol < row.length; iCol++) {
var tile = row[iCol];
if (tile.id == tileID) {
foundTile = tile;
}
}
}
}
return foundTile;
},
/** This function is called whenever the map is moved. All the moving /** This function is called whenever the map is moved. All the moving
* of actual 'tiles' is done by the map, but moveTo's role is to accept * of actual 'tiles' is done by the map, but moveTo's role is to accept
* a bounds and make sure the data that that bounds requires is pre-loaded. * a bounds and make sure the data that that bounds requires is pre-loaded.
@@ -150,6 +125,8 @@ OpenLayers.Layer.Grid.prototype =
}, },
/** /**
* @private
*
* @returns A Bounds object representing the bounds of all the currently * @returns A Bounds object representing the bounds of all the currently
* loaded tiles (including those partially or not at all seen * loaded tiles (including those partially or not at all seen
* onscreen) * onscreen)
@@ -170,7 +147,7 @@ OpenLayers.Layer.Grid.prototype =
}, },
/** /**
* * @private
*/ */
_initTiles:function() { _initTiles:function() {
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
@@ -247,7 +224,15 @@ OpenLayers.Layer.Grid.prototype =
}, },
/** /**
* @private
* *
* Starts at the top right corner of the grid and proceeds in a spiral
* towards the center, adding tiles one at a time to the beginning of a
* queue.
*
* Once all the grid's tiles have been added to the queue, we go back
* and iterate through the queue (thus reversing the spiral order from
* outside-in to inside-out), calling draw() on each tile.
*/ */
spiralTileLoad: function() { spiralTileLoad: function() {
var tileQueue = new Array(); var tileQueue = new Array();
@@ -279,19 +264,25 @@ OpenLayers.Layer.Grid.prototype =
break; break;
} }
// if the test grid coordinates are within the bounds of the
// 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];
} }
if ((tile != null) && (!tile.queued)) { if ((tile != null) && (!tile.queued)) {
//add tile to beginning of queue, mark it as queued.
tileQueue.unshift(tile); tileQueue.unshift(tile);
tile.queued = true; tile.queued = true;
//restart the directions counter and take on the new coords
directionsTried = 0; directionsTried = 0;
iRow = testRow; iRow = testRow;
iCell = testCell; iCell = testCell;
} else { } else {
//need to try to load a tile in a different direction
direction = (direction + 1) % 4; direction = (direction + 1) % 4;
directionsTried++; directionsTried++;
} }
@@ -301,6 +292,7 @@ OpenLayers.Layer.Grid.prototype =
for(var i=0; i < tileQueue.length; i++) { for(var i=0; i < tileQueue.length; i++) {
var tile = tileQueue[i] var tile = tileQueue[i]
tile.draw(); tile.draw();
//mark tile as unqueued for the next time (since tiles are reused)
tile.queued = false; tile.queued = false;
} }
}, },
@@ -320,67 +312,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.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) );
var maxZoomLevel = this.map.getMaxZoomLevel();
var minZoomLevel = this.map.getMinZoomLevel();
//make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, minZoomLevel),
maxZoomLevel );
return zoom;
},
/** go through and remove all tiles from the grid, calling /** go through and remove all tiles from the grid, calling
* destroy() on each of them to kill circular references * destroy() on each of them to kill circular references
* *

View File

@@ -36,10 +36,6 @@ OpenLayers.Layer.HTTPRequest.prototype =
this.params = Object.extend( new Object(), params); this.params = Object.extend( new Object(), params);
}, },
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
this.initResolutions();
},
/** /**
* *
*/ */
@@ -131,37 +127,6 @@ OpenLayers.Layer.HTTPRequest.prototype =
return requestString; return requestString;
}, },
initResolutions: function() {
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.maxZoomLevel = this.resolutions.length;
} else if (this.resolutions != null) {
this.maxZoomLevel = this.resolutions.length;
} else {
this.resolutions = new Array();
if (this.minScale)
this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units);
var maxRes = this.getMaxResolution();
if (this.maxScale) {
/* This will cause this.map.getMaxZoomLevel() to be set the next time
* it is called, which means that the next portion here will succeed. */
var minRes = OpenLayers.Util.getResolutionFromScale(this.maxScale);
this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) / Math.log(2));
}
for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) {
this.resolutions.push(maxRes / Math.pow(2, i));
}
}
},
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"
}); });

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);

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"
});

View File

@@ -11,12 +11,6 @@ OpenLayers.Layer.Text = Class.create();
OpenLayers.Layer.Text.prototype = OpenLayers.Layer.Text.prototype =
Object.extend( new OpenLayers.Layer.Markers(), { Object.extend( new OpenLayers.Layer.Markers(), {
/** Text layer is never a base layer.
*
* @type Boolean
*/
isBaseLayer: false,
/** store url of text file - this should be specified in the /** store url of text file - this should be specified in the
* "options" hashtable * "options" hashtable
* @type str */ * @type str */

View File

@@ -9,11 +9,18 @@
*/ */
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,
/** @type int */
minZoomLevel: 1,
/** @type int */
maxZoomLevel: 17,
/** /**
* @constructor * @constructor
* *
@@ -21,6 +28,10 @@ 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;
}, },
/** /**
@@ -200,6 +211,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
*/ */
getZoomForExtent: function (bounds) { getZoomForExtent: function (bounds) {
var zoom = null;
if (this.vemap != null) {
var maxRes = this.map.getMaxResolution(); var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
@@ -209,15 +222,15 @@ OpenLayers.Layer.VirtualEarth.prototype =
var degPerPixel = (width > height) ? width / viewSize.w var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h; : height / viewSize.h;
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) ); var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
var maxZoomLevel = this.map.getMaxZoomLevel();
var minZoomLevel = this.map.getMinZoomLevel();
//make sure zoom is within bounds //make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, minZoomLevel), var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
maxZoomLevel ); this.maxZoomLevel);
zoom = this.getOLZoomFromVEZoom(veZoom);
}
return zoom; return zoom;
}, },
@@ -245,7 +258,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getOLZoomFromVEZoom: function(veZoom) { getOLZoomFromVEZoom: function(veZoom) {
var zoom = null; var zoom = null;
if (veZoom != null) { if (veZoom != null) {
zoom = veZoom; zoom = veZoom - this.minZoomLevel;
} }
return zoom; return zoom;
}, },
@@ -260,7 +273,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getVEZoomFromOLZoom: function(olZoom) { getVEZoomFromOLZoom: function(olZoom) {
var zoom = null; var zoom = null;
if (olZoom != null) { if (olZoom != null) {
zoom = olZoom; zoom = olZoom + this.minZoomLevel;
} }
return zoom; return zoom;
}, },
@@ -342,4 +355,4 @@ OpenLayers.Layer.VirtualEarth.prototype =
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.VirtualEarth" CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
}); }));

View File

@@ -19,6 +19,8 @@ OpenLayers.Layer.WFS.prototype =
*/ */
isBaseLayer: false, isBaseLayer: false,
buffer: 1,
/** Allow the user to specify special classes for features and tiles. /** Allow the user to specify special classes for features and tiles.
* *
* This allows for easy-definition of behaviour. The defaults are * This allows for easy-definition of behaviour. The defaults are
@@ -157,10 +159,10 @@ OpenLayers.Layer.WFS.prototype =
* *
* Once params have been changed, we will need to re-init our tiles * Once params have been changed, we will need to re-init our tiles
* *
* @param {Object} params Hashtable of new params to use * @param {Object} newParams Hashtable of new params to use
*/ */
mergeNewParams:function(params) { mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(params); var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams]; var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
@@ -171,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.
* *

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));
}
}, },
/** /**
@@ -121,10 +121,10 @@ OpenLayers.Layer.WMS.prototype =
* *
* Once params have been changed, we will need to re-init our tiles * Once params have been changed, we will need to re-init our tiles
* *
* @param {Object} params Hashtable of new params to use * @param {Object} newParams Hashtable of new params to use
*/ */
mergeNewParams:function(params) { mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(params); var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams]; var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
newArguments); newArguments);
@@ -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.
* *

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));
}
}, },
/** /**
@@ -177,11 +175,32 @@ OpenLayers.Layer.WMS.Untiled.prototype =
* @param {Object} newParams * @param {Object} newParams
*/ */
mergeNewParams:function(newParams) { mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams];
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
arguments); newArguments);
//redraw
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.
* *

View File

@@ -25,11 +25,11 @@ OpenLayers.Layer.WorldWind.prototype =
zoomLevels: null, zoomLevels: null,
initialize: function(name, url, lzd, zoomLevels, params) { initialize: function(name, url, lzd, zoomLevels, params, options) {
this.lzd = lzd; this.lzd = lzd;
this.zoomLevels = zoomLevels; this.zoomLevels = zoomLevels;
var newArguments = new Array(); var newArguments = new Array();
newArguments.push(name, url, params); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {}); this.params = (params ? params : {});
if (arguments.length > 0 && params) { if (arguments.length > 0 && params) {
@@ -46,19 +46,16 @@ OpenLayers.Layer.WorldWind.prototype =
return new OpenLayers.Tile.Image(this, position, bounds, return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize); url, this.tileSize);
} else { } else {
var tile = new Object(); return new OpenLayers.Tile.Image(this, position, bounds,
tile.draw = function() {}; OpenLayers.Util.getImagesLocation() + "blank.gif",
tile.destroy = function() {}; this.tileSize);
tile.bounds = bounds;
tile.bounds = position;
return tile;
} }
}, },
getZoom: function () { getZoom: function () {
var zoom = this.map.getZoom(); var zoom = this.map.getZoom();
var extent = this.map.getMaxExtent(); var extent = this.map.getMaxExtent();
zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2); zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2);
return zoom; return zoom;
}, },
@@ -71,14 +68,21 @@ OpenLayers.Layer.WorldWind.prototype =
* @type String * @type String
*/ */
getURL: function (bounds) { getURL: function (bounds) {
var zoom = this.getZoom();
var extent = this.map.getMaxExtent();
var deg = this.lzd/Math.pow(2,this.getZoom()); var deg = this.lzd/Math.pow(2,this.getZoom());
var x = Math.floor((bounds.left - extent.left)/deg); var x = Math.floor((bounds.left - extent.left)/deg);
var y = Math.floor((bounds.bottom - extent.bottom)/deg); var y = Math.floor((bounds.bottom - extent.bottom)/deg);
if (this.map.getResolution() <= (this.lzd/512)
&& this.getZoom() <= this.zoomLevels) {
return this.getFullRequestString( return this.getFullRequestString(
{ L: zoom, { L: zoom,
X: x, X: x,
Y: y Y: y
}); });
} else {
return OpenLayers.Util.getImagesLocation() + "blank.gif";
}
}, },

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<77>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"
}); });

View File

@@ -78,11 +78,14 @@ OpenLayers.Map.prototype = {
// Options // Options
/** @type OpenLayers.Size */
tileSize: null,
/** @type String */ /** @type String */
projection: "EPSG:4326", projection: "EPSG:4326",
/** @type OpenLayers.Bounds */ /** @type String */
maxExtent: null, units: 'degrees',
/** default max is 360 deg / 256 px, which corresponds to /** default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps * zoom level 0 on gmaps
@@ -90,21 +93,23 @@ OpenLayers.Map.prototype = {
* @type float */ * @type float */
maxResolution: 1.40625, maxResolution: 1.40625,
/** @type int */ /** @type float */
minZoomLevel: 0, minResolution: null,
/** @type int */ /** @type float */
maxZoomLevel: 16, maxScale: null,
/** @type OpenLayers.Size */ /** @type float */
tileSize: null,
/** @type String */
units: 'degrees',
/** @type Float */
minScale: null, minScale: null,
/** @type OpenLayers.Bounds */
maxExtent: null,
/** @type OpenLayers.Bounds */
minExtent: null,
/** @type int */
numZoomLevels: 16,
/** /**
@@ -129,6 +134,8 @@ OpenLayers.Map.prototype = {
// the layerContainerDiv is the one that holds all the layers // the layerContainerDiv is the one that holds all the layers
id = div.id + "_OpenLayers_Container"; id = div.id + "_OpenLayers_Container";
this.layerContainerDiv = OpenLayers.Util.createDiv(id); this.layerContainerDiv = OpenLayers.Util.createDiv(id);
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
this.viewPortDiv.appendChild(this.layerContainerDiv); this.viewPortDiv.appendChild(this.layerContainerDiv);
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES); this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
@@ -207,16 +214,6 @@ OpenLayers.Map.prototype = {
// now add the options declared by the user // now add the options declared by the user
// (these will override defaults) // (these will override defaults)
Object.extend(this, options); Object.extend(this, options);
// if maxResolution is specified as "auto", calculate it
// based on the maxExtent and the viewSize
//
if (this.maxResolution == "auto" || this.maxResolution == null) {
var maxExtent = this.getMaxExtent();
var viewSize = this.getSize();
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
maxExtent.getHeight() / viewSize.h );
}
}, },
/** /**
@@ -374,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");
} }
@@ -438,7 +438,9 @@ OpenLayers.Map.prototype = {
removePopup: function(popup) { removePopup: function(popup) {
this.popups.remove(popup); this.popups.remove(popup);
if (popup.div) { if (popup.div) {
this.layerContainerDiv.removeChild(popup.div); try { this.layerContainerDiv.removeChild(popup.div); }
catch (e) { } // Popups sometimes apparently get disconnected
// from the layerContainerDiv, and cause complaints.
} }
popup.map = null; popup.map = null;
}, },
@@ -470,18 +472,25 @@ OpenLayers.Map.prototype = {
if (oldSize == null) if (oldSize == null)
this.size = oldSize = newSize; this.size = oldSize = newSize;
if (!newSize.equals(oldSize)) { if (!newSize.equals(oldSize)) {
// move the layer container so that the map is still centered
var dx = (newSize.w - oldSize.w) / 2, //notify layers of mapresize
dy = (newSize.h - oldSize.h) / 2; for(var i=0; i < this.layers.length; i++) {
var lcStyle = this.layerContainerDiv.style; this.layers[i].onMapResize();
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px"; }
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
// reset the map center
this.layerContainerOrigin = this.center.clone();
// store the new size // store the new size
this.size = newSize; this.size = newSize;
// the div might have moved on the page, also // the div might have moved on the page, also
this.events.element.offsets = null; this.events.element.offsets = null;
if (this.baseLayer != null) {
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
var centerLL = this.getLonLatFromViewPortPx(center);
var zoom = this.getZoom();
this.zoom = null;
this.setCenter(this.getCenter(), zoom);
}
} }
}, },
@@ -561,7 +570,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());
@@ -603,7 +611,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);
} }
} }
@@ -643,8 +651,8 @@ OpenLayers.Map.prototype = {
*/ */
isValidZoomLevel: function(zoomLevel) { isValidZoomLevel: function(zoomLevel) {
return ( (zoomLevel != null) && return ( (zoomLevel != null) &&
(zoomLevel >= this.getMinZoomLevel()) && (zoomLevel >= 0) &&
(zoomLevel <= this.getMaxZoomLevel()) ); (zoomLevel < this.getNumZoomLevels()) );
}, },
/** /**
@@ -680,15 +688,9 @@ 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;
} }
if (projection == null) {
projection = this.projection;
}
return projection; return projection;
}, },
@@ -698,15 +700,9 @@ 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;
} }
if (maxResolution == null) {
maxResolution = this.maxResolution;
}
return maxResolution; return maxResolution;
}, },
@@ -715,55 +711,25 @@ 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;
} }
if (maxExtent == null) {
maxExtent = this.maxExtent;
}
return maxExtent; return maxExtent;
}, },
/** /**
* @returns The maximum zoom level that can be reached in the map * @returns The total number of zoom levels that can be displayed by the
* current baseLayer.
* @type int * @type int
*/ */
getMaxZoomLevel: function() { getNumZoomLevels: function() {
var maxZoomLevel = null; var numZoomLevels = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
maxZoomLevel = this.baseLayer.getMaxZoomLevel(); numZoomLevels = this.baseLayer.numZoomLevels;
} }
return numZoomLevels;
if (maxZoomLevel == null) {
maxZoomLevel = this.maxZoomLevel;
}
return maxZoomLevel;
}, },
/**
* @returns The minimum zoom level that can be reached in the map
* @type int
*/
getMinZoomLevel: function() {
var minZoomLevel = null;
if (this.baseLayer != null) {
minZoomLevel = this.baseLayer.getMinZoomLevel();
}
if (minZoomLevel == null) {
minZoomLevel = this.minZoomLevel;
}
return minZoomLevel;
},
/********************************************************/ /********************************************************/
/* */ /* */
/* Baselayer Functions */ /* Baselayer Functions */
@@ -783,7 +749,6 @@ OpenLayers.Map.prototype = {
*/ */
getExtent: function () { getExtent: function () {
var extent = null; var extent = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
extent = this.baseLayer.getExtent(); extent = this.baseLayer.getExtent();
} }
@@ -797,7 +762,6 @@ OpenLayers.Map.prototype = {
*/ */
getResolution: function () { getResolution: function () {
var resolution = null; var resolution = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
resolution = this.baseLayer.getResolution(); resolution = this.baseLayer.getResolution();
} }
@@ -811,9 +775,8 @@ OpenLayers.Map.prototype = {
*/ */
getScale: function () { getScale: function () {
var scale = null; var scale = null;
if (this.baseLayer != null) { if (this.baseLayer != null) {
var res = this.baseLayer.getResolution(); var res = this.getResolution();
var units = this.baseLayer.units; var units = this.baseLayer.units;
scale = res * OpenLayers.INCHES_PER_UNIT[units] * scale = res * OpenLayers.INCHES_PER_UNIT[units] *
OpenLayers.DOTS_PER_INCH; OpenLayers.DOTS_PER_INCH;
@@ -830,14 +793,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 */
@@ -853,7 +830,9 @@ OpenLayers.Map.prototype = {
* @param {int} zoom * @param {int} zoom
*/ */
zoomTo: function(zoom) { zoomTo: function(zoom) {
if (this.isValidZoomLevel(zoom)) {
this.setCenter(null, zoom); this.setCenter(null, zoom);
}
}, },
/** /**
@@ -927,7 +906,11 @@ OpenLayers.Map.prototype = {
* @private * @private
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { getLonLatFromViewPortPx: function (viewPortPx) {
return this.baseLayer.getLonLatFromViewPortPx(viewPortPx); var lonlat = null;
if (this.baseLayer != null) {
lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
}
return lonlat;
}, },
/** /**
@@ -940,7 +923,11 @@ OpenLayers.Map.prototype = {
* @private * @private
*/ */
getViewPortPxFromLonLat: function (lonlat) { getViewPortPxFromLonLat: function (lonlat) {
return this.baseLayer.getViewPortPxFromLonLat(lonlat); var px = null;
if (this.baseLayer != null) {
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
}
return px;
}, },
@@ -1010,11 +997,11 @@ OpenLayers.Map.prototype = {
var dX = -parseInt(this.layerContainerDiv.style.left); var dX = -parseInt(this.layerContainerDiv.style.left);
var dY = -parseInt(this.layerContainerDiv.style.top); var dY = -parseInt(this.layerContainerDiv.style.top);
layerPx = viewPortPx.add(dX, dY); layerPx = viewPortPx.add(dX, dY);
if (isNaN(layerPx.x) || isNaN(layerPx.y)) {
layerPx = null;
}
} }
if (!isNaN(layerPx.x) && !isNaN(layerPx.y)) {
return layerPx; return layerPx;
}
return null;
}, },
// //

View File

@@ -30,7 +30,16 @@ OpenLayers.Marker.prototype = {
initialize: function(lonlat, icon) { initialize: function(lonlat, icon) {
if (arguments.length > 0) { if (arguments.length > 0) {
this.lonlat = lonlat; this.lonlat = lonlat;
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
if (this.icon == null) {
this.icon = newIcon;
} else {
this.icon.url = newIcon.url;
this.icon.size = newIcon.size;
this.icon.offset = newIcon.offset;
this.icon.calculateOffset = newIcon.calculateOffset;
}
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
} }
}, },

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"
}; };

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");

View File

@@ -64,7 +64,9 @@ OpenLayers.Tile.Image.prototype =
*/ */
clear: function() { clear: function() {
OpenLayers.Tile.prototype.clear.apply(this, arguments); OpenLayers.Tile.prototype.clear.apply(this, arguments);
if(this.imgDiv) {
this.imgDiv.style.display = "none"; this.imgDiv.style.display = "none";
}
}, },
/** /**
@@ -100,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 */

View File

@@ -79,8 +79,8 @@ OpenLayers.Tile.WFS.prototype =
if (this.urls != null) { if (this.urls != null) {
for(var i=0; i < this.urls.length; i++) { for(var i=0; i < this.urls.length; i++) {
var params = { BBOX:bounds.toBBOX() }; var params = { BBOX:this.bounds.toBBOX() };
var url = this.urls[i] + var url = this.urls[i] + "&" +
OpenLayers.Util.getParameterString(params); OpenLayers.Util.getParameterString(params);
OpenLayers.loadURL(url, null, this, success, failure); OpenLayers.loadURL(url, null, this, success, failure);
} }

View File

@@ -125,14 +125,30 @@ 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;
this.style.display = "";
}; };
@@ -355,6 +371,8 @@ OpenLayers.Util.getXmlNodeValue = function(node) {
Try.these( Try.these(
function() { function() {
val = node.text; val = node.text;
if (!val)
val = node.textContent;
}, },
function() { function() {
val = node.textContent; val = node.textContent;
@@ -499,3 +517,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;
};

56
news.txt Normal file
View File

@@ -0,0 +1,56 @@
OpenLayers 2.0 Release Notes
* Deprecated Methods which were removed:
For details, see r1228
* OpenLayers.Map
* removed: getFullExtent() -- use getMaxExtent() instead
* removed: zoomToFullExtent() -- use zoomToMaxExtent() instead
* OpenLayers.Layer.Grid
* removed: setTileSize() -- user should instead pass a 'tileSize' property
as one of the options when initializing the Grid Layer. ex:
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.WMS(name, url, params);
* OpenLayers.Layer.HTTPRequest
* removed: changeParams() -- use mergeNewParams() instead
* OpenLayers.Pixel
* removed: copyOf() -- use clone() instead
* OpenLayers.Size
* removed: copyOf() -- use clone() instead
* OpenLayers.LonLat
* removed: copyOf() -- use clone() instead
* OpenLayers.Bounds
* removed: copyOf() -- use clone() instead
* Array
* removed: copyOf() -- use clone() instead
* MouseWheel
* It is now possible to zoom in/out with the mouse wheel instead of clicks.
* Spiral Gridding
* Instead of loading from the top to bottom of the map, Openlayers will
now start loading tiles from the center of the map.
* Tile Re-Use
* In order to lower memory constraints and reduce element creation times,
OpenLayers now creates a single set of images/tiles and reuses them as
you scroll around the map.
* New Layer Support
* Google
* Virtual Earth
* GeoRSS (RSS 1.0 and 2.0 in FF, IE, RSS 2.0 in Safari)
* KaMap
* Untiled WMS
* Scale Based Methods
* It is now possible to set zooms based on the concept of scale. See
documentation in the options for the Map constructor.
OpenLayers 1.0
Initial release.

View File

@@ -38,7 +38,10 @@ Using OpenLayers in Your Own Website
The examples/ directory is full of useful examples. The examples/ directory is full of useful examples.
There is some documentation at http://trac.openlayers.org/ as well. Dcumentation is available in the doc/ directory: to build an HTML version
of the documentation, run ./docs.sh in the build/ directory.
Information on changes in the API is available in news.txt.
-------------------------- --------------------------
Contributing to OpenLayers Contributing to OpenLayers

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>

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" ) {

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);

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>

View File

@@ -20,8 +20,12 @@
if (!map.getCenter()) map.zoomToMaxExtent(); if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control); map.addControl(control);
map.pan(5, 0); map.pan(5, 0);
if (/MSIE/.test(navigator.userAgent)) {
t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
} else {
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink"); t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
} }
}
function test_03_Control_Permalink_updateLinksBase (t) { function test_03_Control_Permalink_updateLinksBase (t) {
t.plan( 2 ); t.plan( 2 );

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" );

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" );
@@ -89,28 +88,25 @@
function test_04_Layer_StandardOptionsAccessors (t) { function test_04_Layer_StandardOptionsAccessors (t) {
t.plan( 5 ); t.plan( 4 );
var projection = "chicken"; var projection = "chicken";
var maxExtent = new OpenLayers.Bounds(50,50,100,100); var maxExtent = new OpenLayers.Bounds(50,50,100,100);
var maxResolution = 1.5726; var maxResolution = 1.5726;
var minZoomLevel = 5; var numZoomLevels = 11;
var maxZoomLevel = 15;
var options = { projection: projection, var options = { projection: projection,
maxExtent: maxExtent, maxExtent: maxExtent,
maxResolution: maxResolution, maxResolution: maxResolution,
minZoomLevel: minZoomLevel, numZoomLevels: numZoomLevels
maxZoomLevel: maxZoomLevel
}; };
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.getMinZoomLevel(), minZoomLevel, "getMinZoomLevel() works"); t.eq(layer.numZoomLevels, numZoomLevels, "numZoomLevels set correctly");
t.eq(layer.getMaxZoomLevel(), maxZoomLevel, "getMaxZoomLevel() works");
} }
function test_05_Layer_visibility(t) { function test_05_Layer_visibility(t) {

View File

@@ -56,7 +56,11 @@
// MOUSEMOVE test does not seem to work... // MOUSEMOVE test does not seem to work...
// t.plan( 2 ); // t.plan( 2 );
if (document.createEventObject) {
t.plan(2);
} else {
t.plan(1); t.plan(1);
}
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.EventPane('Test Layer'); layer = new OpenLayers.Layer.EventPane('Test Layer');

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");
} }
@@ -114,13 +114,13 @@
* -insertColumn * -insertColumn
* -insertRow * -insertRow
function test_07_Layer_Grid_moveTo(t) { function 07_Layer_Grid_moveTo(t) {
} }
function test_08_Layer_Grid_insertColumn(t) { function 08_Layer_Grid_insertColumn(t) {
} }
function test_09_Layer_Grid_insertRow(t) { function 09_Layer_Grid_insertRow(t) {
} }
* *
@@ -166,41 +166,15 @@
} }
function test_11_Layer_Grid_getTile(t) {
t.plan(2);
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
//test with tile creation
layer = new OpenLayers.Layer.WMS(name, url, params);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
var gotTile = layer.getTile(tile.id);
t.ok( gotTile == tile, "got right tile");
gotTile = layer.getTile("chicken");
t.ok( gotTile == null, "getTile() of bogus id returns null");
}
function test_99_Layer_Grid_destroy (t) { function test_99_Layer_Grid_destroy (t) {
t.plan( 4 ); t.plan( 3 );
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Grid(name, url, params); layer = new OpenLayers.Layer.Grid(name, url, params);
map.addLayer(layer); map.addLayer(layer);
layer.destroy(); layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" ); t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" ); t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );

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");
} }
@@ -107,13 +107,13 @@
* -insertColumn * -insertColumn
* -insertRow * -insertRow
function test_07_Layer_KaMap_moveTo(t) { function 07_Layer_KaMap_moveTo(t) {
} }
function test_08_Layer_KaMap_insertColumn(t) { function 08_Layer_KaMap_insertColumn(t) {
} }
function test_09_Layer_KaMap_insertRow(t) { function 09_Layer_KaMap_insertRow(t) {
} }
* *
@@ -158,42 +158,15 @@
t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly"); t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly");
} }
function test_11_Layer_KaMap_getTile(t) {
t.plan(2);
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
//test with tile creation
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
var gotTile = layer.getTile(tile.id);
t.ok( gotTile == tile, "got right tile");
gotTile = layer.getTile("chicken");
t.ok( gotTile == null, "getTile() of bogus id returns null");
}
function test_99_Layer_KaMap_destroy (t) { function test_99_Layer_KaMap_destroy (t) {
t.plan( 4 ); t.plan( 3 );
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.KaMap(name, url, params, units); layer = new OpenLayers.Layer.KaMap(name, url, params, units);
map.addLayer(layer); map.addLayer(layer);
layer.destroy(); layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" ); t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" ); t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );

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>

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 );

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);

View File

@@ -27,7 +27,7 @@
t.ok( map.controls instanceof Array, "map.controls is an Array" ); t.ok( map.controls instanceof Array, "map.controls is an Array" );
t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" ); t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" );
t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" ); t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
t.ok( map.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" ); t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" );
} }
function test_02_Map_center(t) { function test_02_Map_center(t) {
t.plan(3); t.plan(3);
@@ -63,8 +63,8 @@
} }
function test_04_Map_options(t) { function test_04_Map_options(t) {
t.plan(2); t.plan(2);
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 3.14159}); map = new OpenLayers.Map($('map'), {numZoomLevels: 6, maxResolution: 3.14159});
t.eq( map.maxZoomLevel, 5, "map.maxZoomLevel set correctly via options hashtable" ); t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" );
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" ); t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" );
} }
function test_05_Map_center(t) { function test_05_Map_center(t) {
@@ -151,18 +151,10 @@
} }
t.ok(!found, "popup.div successfully removed from the map's viewPort"); t.ok(!found, "popup.div successfully removed from the map's viewPort");
} }
function test_10_Map_auto_res(t) {
t.plan(2);
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 'auto'});
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via auto" );
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: null});
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via null" );
}
/*** THIS IS A GOOD TEST, BUT IT SHOULD BE MOVED TO WMS. /*** THIS IS A GOOD TEST, BUT IT SHOULD BE MOVED TO WMS.
* Also, it won't work until we figure out the viewSize bug * Also, it won't work until we figure out the viewSize bug
function test_08_Map_px_lonlat_translation (t) { function 08_Map_px_lonlat_translation (t) {
t.plan( 6 ); t.plan( 6 );
map = new OpenLayers.Map($('map')); map = new OpenLayers.Map($('map'));
var baseLayer = new OpenLayers.Layer.WMS("Test Layer", var baseLayer = new OpenLayers.Layer.WMS("Test Layer",

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);

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");

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);

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: