Compare commits

...

228 Commits

Author SHA1 Message Date
crschmidt
4bc061f1c3 Tag 2.3RC2
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.3-rc2@2182 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-01-22 23:27:48 +00:00
crschmidt
7232cfa3a0 Pull up patches for the following bugs from trunk:
#385: building for windows users (fix license)
#453: IE gives new DOM elements a parent with fragment node type
#454: Fix tests which are breaking in Opera
#455: Util.isEquivalentUrl broken in Opera
#463: map.setBaseLayer is a bit funky
#464: Overview Map dissappears when on permalinked page
#465: allow controls to live outside viewport (for real)
#466: HTMLDivElement is still undefined in IE7 (but 
      OpenLayers.Util.alphaHack() is now false)
#467: isEquivalentURL() not complete for IE
#468: Overview MapLosing Rectangle
#469: Default marker is incorrectly centered
#470: Can not use "search" property IE7
#473: Remove call to checkImgURL
#474: overview map isn't properly updated when the argparser kicks in


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.3@2181 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-01-22 23:26:32 +00:00
crschmidt
2642f000fd Create 2.3 release.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.3@2105 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-31 02:10:30 +00:00
euzuro
8ebc5b227a adding example for changing the marker icon
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2103 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-27 21:11:35 +00:00
crschmidt
4cac0a24ea Patch from euzuro for #448 . Make mouseWheel work on MouseToolbar.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2102 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-27 16:53:26 +00:00
crschmidt
6c9cb570c7 Remove accidental debugging statement.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2101 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-23 05:20:09 +00:00
crschmidt
f028effec2 tschaub pointed out that this test didn't actually test anything interesting.
Change that.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2100 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 20:21:58 +00:00
Schuyler Erle
5d00a21863 Updated release.sh to fix #416.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2099 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 20:19:19 +00:00
Schuyler Erle
ba85494e5e Merged in r1747 from source:/sandbox/tschaub/wc/tools/mergejs.py.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2098 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 20:04:48 +00:00
Schuyler Erle
7c0bc17be1 Refactored mergejs.py to make it possible to call from other Python scripts.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2097 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 19:52:56 +00:00
Schuyler Erle
86d4133039 Statement should end in a semicolon.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2096 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 19:49:19 +00:00
euzuro
6462a7dc29 sorry. last few bits of #441
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2095 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 19:33:57 +00:00
euzuro
112978ac3d patch for #441 - resolving Rico namespace conflict
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2094 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 19:31:32 +00:00
crschmidt
01cf10f53d Tests, example change, and Util addition, plus usage in Tile/Image to allow
use of relative URLs, urls with port 80 in them, etc. patch originally from
tschaub, revised by euzuro, reviewed by me. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2093 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 19:03:32 +00:00
crschmidt
88ac5a803c Followup to #449: Missed part of the commit, which protects against doing
a checkImgURL on a tile which has been destroyed.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2092 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 18:50:30 +00:00
crschmidt
7e9eef8d07 Commit a number of improvements to grid handling from #449. This adds
support for buffer:0 on grids, and includes changes to Remove extra 
rows and columns from the grid in _initTiles when reusing an existing 
grid, which is a fix to #357 and #436. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2091 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 18:35:04 +00:00
crschmidt
b46a513077 Fix EOL-style on all remaining files.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2090 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 17:43:14 +00:00
crschmidt
f17ec3ab7d Fix SVN eol-style properties on controls.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2089 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 17:40:54 +00:00
crschmidt
063a10d4ac This is the outside_viewport patch from tschaub for #446:
http://trac.openlayers.org/attachment/ticket/446/outside_viewport.patch

The large diff is because I am suffering under constraints of a bad working
environment. I hate newlines! This patch closes #446.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 17:35:34 +00:00
crschmidt
46767efed2 change map.addControlToMap to allow controls outside viewport, from
Ticket #445: externalControl.patch. Closes #445. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2087 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-22 17:19:23 +00:00
crschmidt
9c6817f5d6 Apply "patch to put event registering in correct place", euzuro, #448 .
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2075 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-16 15:47:37 +00:00
crschmidt
94dc03ea90 Patch for #438 from Tim Schaub: "forces untiled WMS layer to redraw on
mergeNewParams". Since the Untiled layer won't redraw if the map is not
outside the current bounds, we force it with a 'zoomChanged' flag, which 
indicates that the layer should redraw regardless.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2074 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-16 15:30:16 +00:00
crschmidt
2d7f2d2f47 Commit tschaub's patch for #447. This should let people who are having 'pink
tile' problems where right clicking returns the right tile not have problems
anymore. Note that this is seperate from TileCache related issues where 
OpenLayers doesn't request tiles on a grid. 

Note that I have no reason why this should work. In fact, I'd say it 
*shouldn't* work, but other people are seeing this problem, so I'm glad
to have the code in trunk, since it doesn't change teh default behavior.

Thanks to Tim for the patch.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2048 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-13 20:22:30 +00:00
euzuro
c014e5ea72 r2039 contained a small stylistic change that I thought was insignificant but upon further reflection is not. the '||' style is beautiful, but it breaks if a 0, '', or 'false' value is specified (as they all evaluate to false, and thus the default is taken). So if the user wants to specify a 0-width border, s/he cannot. This commit reverts to how it previously was, with the addition of {} as per OL coding standards. Also the addition of one small line break, also for coding standards
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2040 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-13 13:22:47 +00:00
euzuro
d5a7f1ef5c updating jsdoc comments for accuracy
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2039 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-13 13:15:29 +00:00
euzuro
ba89ea595e updating jsdoc for parameter type on one more ajax handler
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2030 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-11 00:20:26 +00:00
euzuro
cc3a4c113b updating jsdoc for parameter type on ajax handlers
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2029 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-11 00:19:29 +00:00
crschmidt
2467940cd3 A fix for #440. Prevent people who somehow get a null element in the event
cache from shooting themselves in the foot: This doesn't seem to happen often,
but it has happened in internal code. I'm going to add more debugging info to 
#440 as we get it, but want to get this in to prevent people from shooting 
themselves in the foot in IE accidentally.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2024 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-07 21:18:24 +00:00
crschmidt
bef4a7d3a9 This is a partial fix to the fact that putting WMS overlays over WMS does not
use the same grid boundaries as the underlying tiles, although not a complete
fix.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2018 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-06 21:29:36 +00:00
crschmidt
046fbf0662 Patch for #430 by Tim Schaub. Reviewed, passes all tests.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2017 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-12-06 21:25:19 +00:00
crschmidt
632a2bd123 Typo in documentation, spotted by castaway. (Thx)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1973 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-26 19:55:15 +00:00
crschmidt
ff4899f520 The popup test had a test in here which tested the size of the content div...
however, for some reason, the test was testing the existing, broken behavior!
Fix the test so that we make sure we don't regress in the future. (Thanks uz.) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1949 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-21 15:47:02 +00:00
euzuro
15c2ab578f mousewheel zooms on mouse position. patch from #341. thanks frederic \!
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1945 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-21 09:32:13 +00:00
crschmidt
c951391368 Patch from penyaskito: setSize function got updated in AnchoredBubble,
but never updated in Popup.js. Fix for #422 .   


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1940 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-20 17:51:11 +00:00
euzuro
36eb8c0bc9 change name of example to be consistent with openlayers datatypes (ours is not called latlon, it is lonlat)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1937 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-20 12:07:28 +00:00
crschmidt
e6ef35c174 Fix for #415 , reported by penyaskito, approved by Schuyler. Due to an oversight
in my new setSize function didn't test setting size before popup was added to 
the map.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1935 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-20 01:11:21 +00:00
crschmidt
5e7b2e03f1 Commit TMS support from 'crschmidt/refractions' Ticket #394 , reviewed by
Schuyler.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1927 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-19 19:54:42 +00:00
crschmidt
71bcdb9b7c A nice overviewmap example. Shows how to use a different baselayer for the
OverviewMap, as well as how to set the min/max ratio to something different.
Thanks penyaskito! (Closes #413 ... with a vengence!)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1914 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-19 13:26:24 +00:00
crschmidt
e1d715fc94 Add example for determining lat/lon from pixel, on a mouse click.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1913 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-19 13:21:26 +00:00
crschmidt
4c9e46e240 Commit patches to documentation, from tickets #411 and #412 , from
penyaskito. (Thanks!) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1912 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 22:55:34 +00:00
crschmidt
c14732b711 Missed another broken test. I should really build in broken-test reporting.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1911 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 16:09:39 +00:00
crschmidt
41f798eaf2 Update test plan. Mistake from r1909.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1910 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 15:42:08 +00:00
crschmidt
d77b849405 Parameters for URLs should be URI encoded. Add test for params that need
to be URI encoded in test_Util, and add Tim Schaub's patch from #381 to make
test pass.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1909 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 15:35:02 +00:00
crschmidt
b4ae7778b6 Update tests in preperation for #381 -- this closes #383. The primary purpose
of this patch is to change the purpose of the getFullRequestString tests to actually
test that function, rather than testing both that function and getParameterString.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1908 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 15:29:32 +00:00
crschmidt
76850371fe Fix for #380 from Tim Schaub, with test. Don't overwrite already-existing parameters
in the URL. This makes the precedence of parameters: 
 * params in URL
 * params in Layer
 * DEFAULT_PARAMS on the Layer.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1907 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 15:19:42 +00:00
crschmidt
fb7b5fff56 Improve getArgs to not use deprecated features, and add support to pass a
URL to the function to parse instead of the window.location. Patch by
Tim Schaub, Closes #378 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1906 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 15:01:17 +00:00
crschmidt
57dc3a7f53 Commit patch from Tim Schaub for #361 : replace tabs with spaces in
jsmin.py and mergejs.py, to make all our python stuff follow the same 
conventions. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1905 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-18 14:53:52 +00:00
euzuro
ac949589a0 applying patch for #399 - MultiServer - some small formatting/commenting changes.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1872 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-16 09:03:17 +00:00
euzuro
1f18b68e7d ie and ff have some discrepancies in how they output formed html. in this case, ie was capitalizing everything and mixing the elements around. so we just compare straight on the dom. better this way anyways.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1783 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 19:01:48 +00:00
euzuro
17633136aa same as previous commit, need to give map div dimensions for proper tests in IE
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1782 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 18:44:17 +00:00
euzuro
6e8754af91 fix test which breaks in ie because there are no size values to grab
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1781 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 18:40:45 +00:00
crschmidt
876051d619 Fix for #392 , another tile.clear we missed.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1780 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 18:22:48 +00:00
euzuro
8bd55016aa applying patch from #387 - if map has changed size, destroy old tile, make a new one
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1779 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 16:42:56 +00:00
crschmidt
7ecc62e55a A fix for #366 , this prevents bailing out in the case where originPx
can't be determined from the baselayer yet. This is the case in Google,
because Google can't call getLatLonFromPx until after setCenter has been
called, which comes after this. There may be some cases where this isn't 
a perfect fix, but we're going to fix this for now, and punt on further
testing until 2.3.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1778 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 16:01:39 +00:00
crschmidt
819ccd7e06 Having a port number of ':80' in a WMS URL doesn't work right now, because
Firefox changes it, and then the URLs we're getting don't match the ones
we're expecting.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1774 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 11:48:59 +00:00
crschmidt
b5334bde43 Make the freemap example better documented and simpler. Before it had some
stuff that didn't actually work in there, so removing it is a Good Thing, and
makes the example more legible, and some additional comments which make
what the code is doing more understandable.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1773 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-11-08 11:45:57 +00:00
crschmidt
1325843cb3 Never actually committed layer.image docs.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1739 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-27 14:24:16 +00:00
Tim Schaub
9f9c366154 Apply patch for #376 - fixing tile.clear() calls that were mistakenly replaced with OpenLayers.Util.clearArray() at r1590
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1738 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-26 15:22:37 +00:00
Tim Schaub
3d58bc6698 Pull in euzuro's patch from #366 - changing how maxResolution is set and a number of other efficiency changes
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1737 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-25 23:05:23 +00:00
crschmidt
786c2a20fb Change files to point to repository-license. Part of build process will now
be to change the licensing terms in the final build.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1721 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-24 18:16:39 +00:00
crschmidt
af6307fd9b Jeff Dege offered better/more clear documentation for the MousePosition
control, and an updated default granularity to make it more useful by default.
Closes #372.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1719 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-24 14:45:20 +00:00
crschmidt
43c916a433 Patch from Tim Schaub to change from old class inheritance to new
inheritance. Closes #370.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1717 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-23 17:27:29 +00:00
crschmidt
69b66e2100 Patch layers which have had wiki page name changes. Patch from Erik, closes
#363. Request for pullup to 2.2 release. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1713 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-21 16:06:27 +00:00
crschmidt
f50fd0b7ac Bring in Tim Schaub's "Graphic" layer as "Layer.Image" (since in the future,
'graphic' may mean something different, like SVG graphic). Tests, docs, 
example, and library change. Thanks, Tim! 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1712 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-21 16:02:15 +00:00
jrf
7ced2241fe splitting release and repository licenses
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1711 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-20 19:41:24 +00:00
euzuro
02c285091e no longer need to exclude yahoo layer from singlefile build
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1710 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-20 18:49:41 +00:00
crschmidt
e31b13135d Committing erik's patch on #362 .
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1706 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-20 14:11:36 +00:00
euzuro
7eb3f4bb9a allow specification of untiled tile ratio. patch for #355 from crschmidt
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1705 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-18 19:12:31 +00:00
crschmidt
cb3af3eaba Add the ability to add a close button to popups via a final param to the
constructor of a popup. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1704 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-18 16:50:07 +00:00
crschmidt
27a8fee770 Add a 'loading' message to getfeatureinfo example.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1703 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-18 14:47:39 +00:00
crschmidt
b1490cf7a9 Use calculateBounds function from patch on #228. This is a refactoring of the
code that Tim Schaub contributed on that patch. Thanks Tim!


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1702 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-17 22:23:19 +00:00
crschmidt
97f92fb3a8 Adding some missing files.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1701 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-16 18:47:17 +00:00
crschmidt
0450c8e21e Zac Barton reports that IEs4Lin does not like document.body.filters. (Confirmed
via forums for the product.) Although this is a bug in that browser, this work
around will allow OL to work for that browser, according to testing.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1700 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-16 13:51:48 +00:00
crschmidt
7c2a8a0cab The OpenLayers server threw a disk, and clobbered another, resulting in a loss
of data up to our last backup. In the previous subversion repository, this was
r1694->r1777. I'm sorry to all those of you who might have checked out that 
code, as this will surely cause problems for you. We're currently working to
figure out what went wrong, and how to prevent it in the future.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1695 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-13 20:41:21 +00:00
crschmidt
60ba893119 WorldWind layer was broken for the first load. I never noticed because the
default example doesn't actually load tiles at the first load. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1694 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-08 03:29:36 +00:00
crschmidt
da1984d764 Almost impossible to debug. element.offsets is cached (3x speedup -- a change
made in the early days of openlayers) but the cache means that relative mouse
positions are off if your first mouse event over the map is *after* the page is
scrolled. This closes #333 , and fixes a long standing not-well understood bug.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1692 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-07 19:26:31 +00:00
crschmidt
e3386b3d50 Consistency is key. Mousmove->redraw in remaining location.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1673 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 20:34:51 +00:00
crschmidt
a9baa4798f This is why I should never just 'go ahead and commit'. Also why I should write
tests. This should be setMap: fixes the MousePosition control.  


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1672 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 20:32:48 +00:00
crschmidt
4aef16e1bd Jeff Dege contributed a MousePosition Control, which this commit adds to trunk.
Reviewed by Erik on Trac and in person. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1665 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 19:20:23 +00:00
crschmidt
185fd44437 Committing change for #328 . This will allow us to clone layers after they have been
added to a map, using the resolutions/scales/etc. that were originally set, and also
keeping ahold of all the new options set on the layer since we created it, like
isBaseLayer, to correspond to behavior of Size.clone and the like. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1662 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 18:57:44 +00:00
euzuro
8b909e9e53 bringing down r1660 from sandbox/euzuro/layerclone
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1661 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 18:23:51 +00:00
Schuyler Erle
9bae3e8848 Changes to Layer.Google and to default theme to move the GMaps chrome over to the lower left side to yield up the valuable lower right corner for our own stuff.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1659 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 17:28:01 +00:00
Schuyler Erle
f27cbc855f Add CSS classes to GMaps Terms of Use and Copyright elements.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1658 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 17:18:29 +00:00
crschmidt
e7834c8922 OpenLayers has been broken in Opera since we removed prototype. Now it's not.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1657 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 16:25:32 +00:00
euzuro
9b73a9a4c9 if there is no old base layer, dont try to get the zoom from it
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1655 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 16:17:10 +00:00
euzuro
5425ea861c ie on win does not like 'grey'
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1654 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 16:14:38 +00:00
euzuro
6387b71d88 copy over newOptions, don't re-copy all of the old options
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1653 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 16:11:38 +00:00
euzuro
53d2fd3033 super seems to be a reserved word (at least in mozilla)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1652 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 16:03:35 +00:00
Schuyler Erle
3be99e67e6 Convert all classes to use new-style class definitions. All tests pass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1651 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:57:33 +00:00
crschmidt
5280553306 IE, Safari, and Firefox all deal with XML elements with namespaces in different
ways. I can't even make thigns work in *two* browsers at once -- what a pain.
So, we'll wrap up all the browser-specific stuff in 
OpenLayers.Ajax.getElementsByTagNameNS(), which contains the browser funkies,
and as a benefit, we get working WFS in IE.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1650 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:33:33 +00:00
Schuyler Erle
95ec8bdc82 Update Layer classes to use new Class.create/inherit functions.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1649 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:33:29 +00:00
Schuyler Erle
f49885444b Include tests for r1647.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1648 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:33:00 +00:00
Schuyler Erle
8e4b06effd Added Class.inherit, changed Class.create to make it unnecessary to check for arguments.length > 0 in initialize().
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1647 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:32:38 +00:00
crschmidt
990f01a9c2 These changes shouldn't have needed to be there. We don't need to add code
to core to help cope with Safari's inadequacies.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1646 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:31:53 +00:00
crschmidt
f97ffae403 OpenLayers.js changes didn't suit Safari very well.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1645 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:29:47 +00:00
crschmidt
c6d40eb2d3 Apparently Safari doesn't always load these in order. Let's just put a
check around these to make sure we always have what we need.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1644 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 15:04:11 +00:00
Schuyler Erle
a5483e0f6d Fix plan in the Map tests for r1639.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1643 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 14:35:55 +00:00
crschmidt
9e8f7f796c Move permalink up after moving its styling information into style.css.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1642 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 11:28:48 +00:00
crschmidt
dd3562c26a 1. Move scalebar styling into CSS.
2. Move scalebar up, so we can move Permalink up slightly (that's the next 
   commit)  to not block google copyright.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1641 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 11:14:29 +00:00
crschmidt
7e5cd23ad0 Commit changes to code for skinning, including doc/customization, which
documents the class style naming for OL, although it isn't implemented yet,
so that we have a standard to work against. Update release scripts, tests,
and create a 'theme' directory which will hold theme information as it is
developed.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1639 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 04:03:58 +00:00
euzuro
5364ce73e5 break permalink into two controls: permalink and argparser. make the arg parser a default control that is added to the map. furthermore, make it such that on addition to the map, the permalink will hunt through the maps controls to make sure there is an argparser control loaded, and if not it will load one itself. now we add a new parameter to the permalink suite: 'layer'. the application will now save the layer visibility information. finally, update tests so nothing breaks.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1634 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 03:28:53 +00:00
crschmidt
781fbf1822 Event.Stop caused us to lose the ability to click on our permalink.
We like clicking on our permalink. bring that functionality back. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1632 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 03:19:01 +00:00
euzuro
99ea5db027 only draw the layer when it needs to be drawn
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1625 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 02:16:40 +00:00
Schuyler Erle
fbd82a300b Oops, forgot to check in the tests that prove that r1616 actually works.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1624 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 02:07:28 +00:00
crschmidt
7562f7097f Add revision property. This should allow us to check what version of the code
people are using, useful for debugging.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1623 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 01:03:13 +00:00
euzuro
dd2a5df781 allow permalink to store layer information. update tests so they pass
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1621 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 00:44:14 +00:00
euzuro
f5d644733b once we have set the layer's resolutions array, we can set its inRange
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1620 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-06 00:13:53 +00:00
euzuro
5d4ba864dc move addlayer event trigger to after the baselayer has been set
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1619 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 23:17:54 +00:00
Schuyler Erle
407604cc35 Set the new layer.grid to a new Array object, rather than null, in Layer.Grid.clone(). Passes all tests. Fixes #203.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1616 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 21:04:28 +00:00
euzuro
7ba704305a make setVisibility() actually call display(). also add some comments on this rather funky situation.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1615 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:56:40 +00:00
Schuyler Erle
a1ca8ebd08 Move the branding/ToS stuff up to the event pane in Layer.Google. Fixes #185. A big hurrah for the Uzmeister and his suggestion that solved this conundrum.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1614 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:46:58 +00:00
Schuyler Erle
7a1d3601a1 Change Layer.EventPane to override Layer.display() rather than Layer.setVisibility(). Also, add setZIndex() there to update the pane's z-index when the div's changes.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1613 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:45:12 +00:00
Schuyler Erle
bf075e63e0 Add Layer.setZIndex so that layers can add behavior when their div's z-index changes. Also, change Map.setLayerZIndex() to use it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1611 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:34:21 +00:00
euzuro
a0ed21125c typo
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1610 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:21:48 +00:00
euzuro
46b0402b0b oops. need to show/hide the layer when we change it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1609 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:11:53 +00:00
euzuro
ad545a0280 only move the visible and in range layers. the rest can redraw themselves when they come back into the picture.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1608 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:07:42 +00:00
euzuro
6366edc515 reinsertion of r1572
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1607 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 20:01:09 +00:00
euzuro
2b7c6cc844 refactor range checking into map and store a state variable in layer so that we dont fire changelayer every time user zooms
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1606 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 19:32:07 +00:00
crschmidt
3cf66a5779 Documentation and tests to close #259 .
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1605 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 19:31:00 +00:00
Schuyler Erle
fee4d6f973 Add map.getNumLayers(), map.getLayerIndex(), map.setLayerIndex(), map.raiseLayer() to support moving layers up and down in the map stack.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1604 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 19:07:19 +00:00
euzuro
8782ee3e15 no need to get this again.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1603 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 18:56:17 +00:00
Schuyler Erle
1f4a53291f Fix uninitialized var error introduced in r1600.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1602 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 18:31:32 +00:00
crschmidt
6de0698f43 By default, OpenLayers expects images in "../img" for non-single file builds,
and "./img" for single file builds. Allow anyone to override this by setting
OpenLayers.ImgPath = '/images/openlayers/' if they choose to. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1601 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 17:40:19 +00:00
Schuyler Erle
9e4bf497ca Remove check for Prototype.js.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1600 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 17:20:58 +00:00
euzuro
3a177683d5 rollback previous changeset. overriding inRange() not necessary
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1599 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 17:17:17 +00:00
euzuro
ab4f69ac48 special cased inRange() to return true if getResolution() returns null -- this way we get through and actually do load 3rd party layers.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1598 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 17:08:27 +00:00
euzuro
a1a1128ac7 for fixed zoom layers, be careful that if the 3rd party tool is not loaded, they wont be able to return a valid getExtent() and therefore neither a valid getResolution(). Make sure those return null without crashing.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1597 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 17:07:15 +00:00
euzuro
07ef71b7b0 Array.indexOf(), though implemented in FF, is not standard javascript. we replace it with OpenLayers.Util.indexOf(), replace all usage
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1596 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 16:28:24 +00:00
Schuyler Erle
d81c2f0187 Test for the presence of OpenLayers.Control before attempting to load controls. Makes it possible to run Map.js in the lightweight version.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1595 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:55:47 +00:00
Schuyler Erle
deb64d31fe Update build tools to make it possible to build a 'lite' version of the single file library.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1594 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:53:41 +00:00
Schuyler Erle
0da08584d8 Added simplest useful example.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1593 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:47:07 +00:00
Schuyler Erle
17eecb955d Removed unnecessary meta tags from all the other examples. Golly.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1592 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:44:33 +00:00
Schuyler Erle
c6db421ae6 Removed unnecessary meta tag from WMS example.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1591 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:42:55 +00:00
Schuyler Erle
4739147a2f Removed modifications to Array.prototype and moved them into OL.Util instead. All tests pass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1590 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:18:02 +00:00
euzuro
efa9499d57 add outgoing layers information to permalink
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1589 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 15:09:56 +00:00
Schuyler Erle
67ced536c0 Merged r1559:r1587 from source:/sandbox/crschmidt/noprototype. OpenLayers is now Prototype-free(tm).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1588 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 14:50:47 +00:00
euzuro
33c37ef78b fix for #191 - graceful dealing with setCenter() on lonlat out of maxexteng (on first setcenter() call). added test
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1585 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 06:20:47 +00:00
euzuro
fcc84782df now the scrollbar works again. that pesky results div was sitting on top of it, is what the problem was.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1584 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 05:56:50 +00:00
euzuro
fe4ae239d5 numbering
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1583 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 05:51:15 +00:00
euzuro
3a611993ce update example.html to showcase fixes for #182 and #262
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1582 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 05:06:57 +00:00
euzuro
1414f0f656 fix for #182 and #262 -- pick the best new resolution when changing baselayers, instead of just using the same index into the resolutions array.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1581 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 05:06:33 +00:00
euzuro
abde2fbc23 don't disable baselayers in the layerswitcher
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1580 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 05:02:06 +00:00
euzuro
5d724258e1 update example.html to show scale-dependent layer visibility. this pretty much finishes off #99
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1579 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 04:21:59 +00:00
euzuro
dc34753b50 oops. update test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1578 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 04:21:10 +00:00
euzuro
510ab8561c add a new property to layer.js called 'visibility' which we now need to store instead of reading directly from the visiblity of the div itself, since the div might be hidden, but only because it is out of range. we thus add a new method on layer called inRange() which returns whether or not the layer's max/min resolution settings allow it to be displayed at the current map's resolution. to make sure that min/max resolution, scale, etc are set for *all* layers, we remove the if statement limiting the running of initResolution() to only baselayers, and we add code at the end of that function that, once the resolutions array has been calculated, then goes back and sets min/max scale and resolution. now what we have to do is every time moveTo() is called on a layer, if the zoom has changed, then we must check if the layer is inRange() and update the display accordingly. on that same note, the layerswitcher must now be attentive to these changes, so we set it to redraw every time the zoom changes. in the layerswitcher code, we now add special code to disable a layer if it is out of range. must add the superclass call to moveTo() for all of the layers to ensure this code is executed for all. update test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1577 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 04:20:16 +00:00
crschmidt
f428473283 Safari is a bit pickier on syntax than other browsers. These two errors
were breaking Safari... but no longer!


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1576 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-05 02:37:23 +00:00
euzuro
1935953796 minor update to r1558 for coding standards, comments, etc
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1572 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 20:57:25 +00:00
crschmidt
844f92afe5 Introducing a horrible bug in OpenLayers.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1568 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 20:27:47 +00:00
euzuro
3ece418354 correct the class name
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1563 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 19:19:30 +00:00
crschmidt
86d573dd83 Test for null. Testing for existence means that when we pass toBBOX(0), we
want to round to whole numbers, not to 6 decimal places. (Thanks tschaub.) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1561 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 16:02:45 +00:00
crschmidt
dc7c266f1f Fix requires statement. Single file build of OpenLayers broken prior to this.
(Thx jrf)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1560 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 15:33:02 +00:00
crschmidt
8dfb4c3ce9 Add rounding support to the default toBBOX() call. Now, toBBOX() will by
default return values which are rounded to 6 decimal places. If you wish more
or less accuracy, you can change it by passing a numeric argument with the
accuracy you want to toBBOX(), and that accuracy will be used instead. Updated
tests to test rounding to various levels. This functionality should help 
prevent different browsers from hitting different caches. At the equator, this
rounding difference is only 4", and smaller as you head towards the poles.   


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1558 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 14:05:34 +00:00
crschmidt
e1a36bdc58 Some lessons learned from other untiled layers:
* Use existing Tile Class
 * Make the area double the current area, so we don't reload on one-pixel
   drag. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1557 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 10:56:02 +00:00
crschmidt
9f9c53218a Change timeout to 6 seconds instead of 4. We were still getting some reported
timeouts. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1556 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-04 03:02:44 +00:00
crschmidt
4a14ae5346 Add MapServer layer.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1555 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 21:29:44 +00:00
euzuro
994230e580 simplify defaultIcon now that default Icon sets offset to center
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1554 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 20:52:29 +00:00
euzuro
91505ff5d6 make default behaviour for an icon with no specified offset or calcuateOffset() function be to have a standard calculateOffset() function setting the offset point at the center of the icon
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1553 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 20:51:39 +00:00
euzuro
526c8a6e1e nullify these grids on exit so that we dont try to destroy them... which was raising errors when running tests on IE
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1552 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 19:52:19 +00:00
euzuro
25da469210 replace useage of OpenLayers.Util.setOpacity() with OpenLayers.Util.modifyDOMElement(). Rewrite the former to use the latter, and mark the former as deprecated.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1551 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 19:38:15 +00:00
euzuro
7fa0910fcf update all opacity tests so they pass in IE
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1550 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 19:37:14 +00:00
euzuro
66250b1342 add opacity support to createDiv() and createImage(). update their tests. also small update to modify tests for more completeness. updated one single complete usage of createImage() due to argument reordering
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1549 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 19:07:24 +00:00
crschmidt
964f777e64 Different browsers de-innerHTMLize differently. Just look for the words.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1548 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:55:05 +00:00
euzuro
7280a6211e allow opacity to be set with OpenLayers.Util.modifyDOMElement(). added test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1547 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:50:44 +00:00
euzuro
4f8c62df3f revert previous commit. going to do this another way. apologies.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1546 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:45:12 +00:00
euzuro
3a3e412090 use already created OpenLayers.Util.setOpacity() function
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:44:02 +00:00
euzuro
10e7761a97 now we can specify opacity on createAlphaImageDiv(). added tests. updated usage.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1544 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:38:40 +00:00
euzuro
8fe89ba734 opacity is float, not string
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1543 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:30:56 +00:00
euzuro
3e4109781b test for alpha hack, not just ie vs. mozilla
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1542 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 18:26:43 +00:00
euzuro
348b0b388d allow for setting opacity of alpha image divs. also give both Icon and Marker setOpacity() functions. added tests and modified examples/markers.html to show how to do it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1541 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 17:36:03 +00:00
crschmidt
634588abf0 If we're not running under IE, we should append script tags via the DOM.
This works in Safari, Firefox, Opera, and we check for IE and do it the old
way for them. Closes #177 . 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1540 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 14:11:43 +00:00
crschmidt
7e11c37610 Add 'ascending' flag to LayerSwitcher. Update docs. Add Demo. Add tests.
Closes #256 .


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1539 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 12:37:25 +00:00
euzuro
0adeb2670d changing 'minor' parameter name to 'dragging' for consistency
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1538 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 04:35:04 +00:00
crschmidt
97418cb70b Permalink will now save state if there's no base layer when it's added, and
change the map when the first baselayer loads.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1537 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 04:34:51 +00:00
euzuro
cab24b665d update map's getScale() to use getScaleFromResolution()
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1536 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 03:45:00 +00:00
euzuro
628409a993 change getScaleFromResolution() to return big scale value instead of normalized. update tests
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1535 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 03:44:37 +00:00
euzuro
a758efb2f2 added getScaleFromResolution() function to util, also added tests for both directions of the scale<->resolution tranformation functions, as well as the normalizeScale() function
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1534 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 03:21:45 +00:00
crschmidt
642c438c2c Add new test and fix code to make it work. Before, tests would sometimes
work in one direction, but not the other on interectsBounds.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1533 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 03:13:32 +00:00
crschmidt
2cb4306beb Tiles should not load data outside maxExtent unless the
'displayOutsideMaxExtent' option on the layer is set to true. Add
tests, docs, and code.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1531 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 01:08:00 +00:00
crschmidt
66a5d90965 Fix broken test of new Bounds.intersectBounds, add test to ensure it doesn't
break again in the future. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1530 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-03 01:05:42 +00:00
euzuro
07fc49ab31 add Bounds.intersectsBounds() function and tests
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1529 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 23:49:19 +00:00
euzuro
36a76054a4 allow layers to prevent themselves from displaying in the layer switcher via the 'displayInLayerSwitcher' boolean option. modify example.html to show usage
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1528 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 23:24:02 +00:00
euzuro
41f619b05e fix for r1478, #190 - need to specify a sort method. thanks to http://www.javascriptkit.com/javatutors/arraysort3.shtml
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1527 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 22:00:13 +00:00
euzuro
890b2a6ffc allow VE to specify map type. fix for #273. update ve.html example to show how
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1526 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 21:48:21 +00:00
euzuro
14a2418a62 remove old layer switcher. this fixes #200
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1525 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 21:22:43 +00:00
crschmidt
5852fb835e Patch for better IE support from Tim Schaub.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1524 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 16:16:58 +00:00
crschmidt
c5f2196f98 Patch from Tim Schaub to Box.js to make display better in IE.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1523 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 16:06:44 +00:00
crschmidt
2c80da26ff Untiled WMS layer didn't change on zoom. Now it should.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1522 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 15:50:07 +00:00
Schuyler Erle
ee29537bbe Added some different color markers, based on the original one.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1520 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-02 05:03:44 +00:00
crschmidt
1de712c82f I really need to switch this to a formatting language I didn't write myself.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1519 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-29 10:06:52 +00:00
crschmidt
97147a21a8 Map documentation update. Missed documentation of some event_types. Brought to
attention by David Herbert. (Thx david) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1518 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-29 10:01:45 +00:00
crschmidt
381f1d454d Add script to do part of release process. Will expand next time I get annoyed
with doing the same things over and over again.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1515 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-28 13:15:15 +00:00
euzuro
0565566118 coding standards
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1512 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-28 06:48:27 +00:00
euzuro
cf7920ea11 fix off-by-one error in getZoomForResolution(). Created test to prevent this from happenning again.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1511 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 23:08:37 +00:00
euzuro
73fb43712f add onScreen() function to OpenLayers.Feature, and add tests to prove it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1510 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 21:56:17 +00:00
euzuro
1cedf957b0 add test for marker.onScreen()
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1509 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 21:26:32 +00:00
euzuro
b774b592cd removing unnecessary line
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1508 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 21:03:59 +00:00
euzuro
3b60032995 use new functions from r1506.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1507 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 20:56:42 +00:00
euzuro
b5c6522c2b add containsPixel() and containsLonLat() functions to OpenLayers.Bounds object. added tests
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1506 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-27 20:52:15 +00:00
euzuro
2255e7d56c update comment
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1505 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-26 23:57:35 +00:00
euzuro
e658877014 return a copy of the mapsize, not the mapsize itself. this will hopefully prevent some nasty bugs.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1504 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-26 23:54:59 +00:00
euzuro
5804cc6cb3 small cleanup of basic OpenLayers.Feature functionality -- specifically adding full control for popup and marker creation and destruction and better comments for all that. all tests pass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1503 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-26 21:46:10 +00:00
crschmidt
003f00bc22 *Always test before committing*. One of these days, I will teach myself to
be a diligent committer. I promise.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1500 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-22 13:55:10 +00:00
crschmidt
dabba5ef41 We've had a number of problems related to browsers complaining on this line.
The popups go away, then cause:
[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "/lib/OpenLayers.js Line: 7663"]
This will hopefully silence the exception. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1499 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-22 13:51:08 +00:00
crschmidt
086e1efb5f Currently attempting to debug some odd behavior where loading a remote
URL is not workign the same as loading a local URL for reasons I don't
understand.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1498 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-21 17:05:48 +00:00
euzuro
6e2fd1bbf9 decompose the marker destruction code out so that it can be overridden in subclasses
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1497 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-20 11:24:54 +00:00
euzuro
492b144147 add code so that if initialize() is called on a marker that already has an icon created, it resets the icon's data but preserves its DOMElement div
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1496 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-20 11:24:16 +00:00
euzuro
5bd2c55610 reorder logic of test for isNaN so that if viewPortPx is null to start with we dont bomb out with error
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1495 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-20 09:51:21 +00:00
euzuro
c52e730378 protect px-lonlat translation from null values in default layer
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1494 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-20 09:44:53 +00:00
crschmidt
439ff9943e Change WorldWind layer to work properly when layer is not within appropriate
zoom levels. Adjusts to new method of inittileing.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1493 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-20 01:07:55 +00:00
crschmidt
a558ad0d88 WorldWind example has some documentation on the layer and the difficulties it presents.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1492 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 23:39:18 +00:00
crschmidt
42cb6b1fc3 Fix WorldWind layer.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1491 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 23:35:19 +00:00
crschmidt
157af40d45 layer-opacity example, from Tim Schaub's original use of it. Primarily because
I've never been so impressed by a demo of software I've helped write :)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1490 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 23:24:23 +00:00
crschmidt
651caa931a When we set the background color for an erroring image, we also want to
*display* the image... otherwise that color never shows up.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1489 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 20:23:48 +00:00
crschmidt
7cd4022d7b Update example to current API.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1488 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 19:01:49 +00:00
euzuro
34dfbef5a5 fix for dynamic resizing
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1487 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 17:08:43 +00:00
euzuro
b77dc94f32 add a fullscreen OL example
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1486 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 16:48:21 +00:00
crschmidt
4ab9950902 Don't need to have modifier -- just display on every click.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1485 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 16:45:48 +00:00
crschmidt
22c3ba7430 Add world.freemap.in to proxy.cgi, so we can include a getfeatureinfo
query in examples.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1484 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-19 00:52:57 +00:00
crschmidt
520f081688 r4612@creusa: crschmidt | 2006-09-17 14:51:38 -0400
sort() in javascript is not a numeric sort. As a result, this fails to sort
 "32, 75, 9" as "9,32,75", which means that with the current sort breaks 
 zoom levels in any case where we're sorting the resolutions. Remove this for
 the time being.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1478 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-17 23:56:16 +00:00
euzuro
601a6c8376 was able to reproduce the wierd clicking bug jrf found. it was happening because the mouseup was not being properly handled by the toolbar buttons. this is taken care of.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1477 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 20:20:59 +00:00
euzuro
263ff16782 coding standards -- spacing
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1476 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 20:00:41 +00:00
euzuro
74dfbbc927 was there a specific reason why we were double-zooming in toolbar mode but single-zooming in normal mode?
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1475 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 19:25:22 +00:00
euzuro
c38874b374 make it such that the map is dropped and the zoom box abandoned if the mouse goes off the screen. obviously the better solution would be to treat things as if we were still in the div -- mach 2 had this functionality. for now, however, we dont have time to code that, so i have created a ticket #263 and put it in the drawer for 2.2. this fix at least gives the user consistent behaviour, and does not allow for this annoying zooming with the zoom rectangle on mouseout.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1474 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 19:07:57 +00:00
euzuro
42db224f3d this function is an exact copy of the same in mousedefaults -- just use the original from the superclass.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1473 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 18:59:40 +00:00
euzuro
5ad0f05fc2 reproject no longer exists
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1472 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-15 00:01:58 +00:00
euzuro
d289fea786 do not allow doubleclicks to fall through to map from mousetoolbar
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1471 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 23:12:39 +00:00
euzuro
dd41ac7693 redo of r1438 to make popup use new Events-Fall-Through functionality (as introduced with r1468)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1470 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 20:58:46 +00:00
euzuro
88ff0bc9af give our events model the option of allowing events to fall through so that they can be picked up in lower layers. change the panzoombar and the mousetoolbar to use this new fallthrough option so that we aren't causing bugs when the drag zoom rectangle gets dropped over them, they dont freak out. next up i am going to re-fix the popup events code to use this feature.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1468 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 20:25:23 +00:00
143 changed files with 7365 additions and 4675 deletions

27
build/build.py Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python
import sys
sys.path.append("../tools")
import jsmin, mergejs
sourceDirectory = "../lib"
configFilename = "library.cfg"
outputFilename = "OpenLayers.js"
if len(sys.argv) > 1:
configFilename = sys.argv[1] + ".cfg"
if len(sys.argv) > 2:
outputFilename = sys.argv[2]
print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
print "Compressing."
minimized = jsmin.jsmin(merged)
print "Adding license file."
minimized = file("license.txt").read() + minimized
print "Writing to %s." % outputFilename
file(outputFilename, "w").write(minimized)
print "Done."

View File

@@ -1,40 +0,0 @@
#!/bin/sh
#
# Script to build compressed single file version of OpenLayers library
#
OUTPUT_FILENAME=OpenLayers.js
TMP_OUTPUT_FILENAME=tmp.${OUTPUT_FILENAME}
TOOLS_DIR=../tools
CFG_FILENAME=library.cfg
SRC_DIR=../lib
CMD_MERGE_JS=${TOOLS_DIR}/mergejs.py
CMD_SHRINKSAFE=${TOOLS_DIR}/shrinksafe.py
CMD_JSMIN=${TOOLS_DIR}/jsmin.py
LICENSE_HEADER_FILENAME=license.txt
## Generate "fat" single file library version
${CMD_MERGE_JS} -c ${CFG_FILENAME} ${TMP_OUTPUT_FILENAME} ${SRC_DIR}
## Compress ("shrink") the single file library version
echo
echo Shrinking and post-processing...
# (We also append the license header here.)
cat ${LICENSE_HEADER_FILENAME} > ${OUTPUT_FILENAME}
${CMD_JSMIN} <${TMP_OUTPUT_FILENAME} >> ${OUTPUT_FILENAME}
echo Cleaning up...
rm $TMP_OUTPUT_FILENAME
echo
echo Done.

View File

@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
rm ../doc/reference.html rm ../doc/reference.html
CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MouseToolbar Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util" CLASSES="Map Layer Layer.Image Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Layer.TMS Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MousePosition Control.MouseToolbar Control.OverviewMap Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util Ajax"
echo "<html> echo "<html>
<head> <head>
<title>OpenLayers Class Reference Documentation</title> <title>OpenLayers Class Reference Documentation</title>

View File

@@ -1,11 +1,13 @@
[first] [first]
Prototype.js
Rico/Corner.js
OpenLayers/SingleFile.js OpenLayers/SingleFile.js
OpenLayers.js OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/Util.js
Rico/Corner.js
[last] [last]
[include]
[exclude] [exclude]
OpenLayers/Layer/Yahoo.js
OpenLayers/Control/KeyboardDefaults.js OpenLayers/Control/KeyboardDefaults.js

View File

@@ -2,8 +2,8 @@
OpenLayers.js -- OpenLayers Map Viewer Library OpenLayers.js -- OpenLayers Map Viewer Library
Copyright 2005-2006 MetaCarta, Inc., released under the BSD License. Copyright 2005-2006 MetaCarta, Inc., released under a modified BSD license.
Please see http://svn.openlayers.org/trunk/openlayers/license.txt Please see http://svn.openlayers.org/trunk/openlayers/repository-license.txt
for the full text of the license. for the full text of the license.
Includes compressed code under the following licenses: Includes compressed code under the following licenses:
@@ -13,7 +13,9 @@
*/ */
/* Prototype JavaScript framework, version 1.4.0 /* Contains portions of Prototype.js:
*
* Prototype JavaScript framework, version 1.4.0
* (c) 2005 Sam Stephenson <sam@conio.net> * (c) 2005 Sam Stephenson <sam@conio.net>
* *
* Prototype is freely distributable under the terms of an MIT-style license. * Prototype is freely distributable under the terms of an MIT-style license.

20
build/lite.cfg Normal file
View File

@@ -0,0 +1,20 @@
[first]
OpenLayers/SingleFile.js
OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/Util.js
[last]
[include]
OpenLayers/Events.js
OpenLayers/Map.js
OpenLayers/Layer.js
OpenLayers/Layer/Grid.js
OpenLayers/Layer/HTTPRequest.js
OpenLayers/Layer/WMS.js
OpenLayers/Layer/WMS/Untiled.js
OpenLayers/Tile.js
OpenLayers/Tile/Image.js
[exclude]

View File

@@ -11,4 +11,4 @@ This control will by default display a small image in the upper right corner of
* Parameters * Parameters
position -- (inherited from {OpenLayers.Control}) {OpenLayers.Pixel} to use as the top-left corner of the control div, relative to the map area. position -- (inherited from {OpenLayers.Control}) {OpenLayers.Pixel} to use as the top-left corner of the control div, relative to the map area.
activeColor -- The color to use for the background of the layer switcher div. activeColor -- The color to use for the background of the layer switcher div.
ascending -- Ascending determines whether layers are added to the layer switcher in ascending or descending order. If ascending is true, the lowest layer is appended to the list first. If ascending is false, the lowest layer is at the very bottom of the LayerSwitcher. Default is true.

View File

@@ -0,0 +1,32 @@
OpenLayers.Control.MousePosition
A small control which displays the Longitude and Latitude of the current mouse position, by defualt in the lower right of the map viewport.
* Constructor
OpenLayers.Control.MousePosition({Object|options}) -- Creates a new MousePosition control.
* Parameters
element -- if not null, div in which to display the MousePosition
prefix -- html to precede the longitude value (default: '')
separator -- html to separate the longitude and latitude values (default: '<br />')
suffix -- html to follow the latitude value (default: '')
numdigits -- number of digits to the right of the decimal (default: 5)
granularity -- Don't refresh display if mouse has moved more than this (default: 10)
prefix, separator, and suffix are used to format the lon/lat values.
With:
prefix = 'Lon:&nbsp;'
suffix = '<br />Lat:&nbsp;'
suffix = ''
nudigits = 3
Lon/Lat is displayed as:
Lon: 95.123
Lat: 35.456
If the mouse has never been over the map, Lon/Lat will equal 0/0. If the mouse is over the map, Lon/Lat will equal the current mouse position. If the mouse has been moved off the map, Lon/Lat will equal the value displayed at the time the mouse was moved off the map.
If the mouse is moving slowly, the Lon/Lat will refresh continuously. If the mouse is moving rapidly, the refresh of Lon/Lat will be suspended until the mouse has slowed down or stopped. (Trying to update the Lon/Lat value while the mouse is in rapid movemement makes the movement of the mouse unacceptably jerky.)

View File

@@ -0,0 +1,38 @@
OpenLayers.Control.OverviewMap
This control provides a locator or overview map linked to another map. By default, the overview map shows up in the lower right of the main map and can be expdaned with the '+' button.
* Constructor
OpenLayers.Control.OverviewMap(opts?) -- Creates a new overview map. The opts variable is an object with various options, as described in the options section below.
* Methods
isSuitableOverview() -- {Boolean} -- Determines if the overview map is suitable given the extent and resolution of the main map.
getRectPxBounds() -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the extent rectangle's pixel bounds (relative to the parent element).
setRectPxBounds({OpenLayers.Bounds|bounds}) -- none -- Set extent rectangle pixel bounds.
getRectBoundsFromMapBounds({OpenLayers.Bounds|lonLatBounds}) -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the passed-in map lon/lat extent translated into pixel bounds for the overview map.
getMapBoundsFromRectBounds({OpenLayers.Bounds|pxBounds]}) -- {OpenLayers.Bounds|bounds} -- An OpenLayers.Bounds which is the passed-in overview rect bounds translated into lon/lat bounds for the overview map.
getLonLatFromOverviewPx({OpenLayers.Pixel|pixel}) -- {OpenLayers.LonLat|lonlat} -- An OpenLayers.LonLat which is the passed-in overview map OpenLayers.Pixel translated into lon/lat by the overview map.
getOverviewPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel|pixel} -- An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into overview map pixels
* Events
* Rectangle events
They are defined on OverviewMap.rectEvents
mouseover -- rectangle is moused over
mouseout -- rectangle is no longer mousedout
mousemove -- mouse moves inside rectangle
mousedown -- mouse button is pressed over the rectangle.
mouseup -- mouse button is released over the rectangle.
click -- mouse clicked
dblclick -- mouse double clicked
* Map events
They are defined on OverviewMap.mapDivEvents
click -- mouse clicked
* Options:
* minRatio -- The ratio of the overview map resolution to the main map resolution at which to zoom farther out on the overview map.
* maxRatio -- The ratio of the overview map resolution to the main map resolution at which to zoom farther in on the overview map.
* layers -- Ordered list of layers in the overview map. If none, then the map base layer is used.

View File

@@ -1,4 +1,4 @@
OpenLayers.Control.PanZoom OpenLayers.Control.PanZoomBar
Creates a small toolset for controlling the location of the map with panning and zooming, including four directional arrows, a zoom in and zoom out, and a bar on which a slider can be moved to zoom in or out by multiple stops at once. Creates a small toolset for controlling the location of the map with panning and zooming, including four directional arrows, a zoom in and zoom out, and a bar on which a slider can be moved to zoom in or out by multiple stops at once.

View File

@@ -12,5 +12,5 @@ The Google Layer in OpenLayers allows you to include Google Maps functionality i
getGPointFromOLPixel({OpenLayers.Pixel|pixel}) -- GPoint -- Create GPoint from OpenLayers Pixel. getGPointFromOLPixel({OpenLayers.Pixel|pixel}) -- GPoint -- Create GPoint from OpenLayers Pixel.
* Parameters * Parameters
type -- one of G_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, used to choose the type of map to display. type -- one of G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, used to choose the type of map to display. (See <a href="http://www.google.com/apis/maps/documentation/reference.html#GMapType">GMapType in the Google documentation</a> for more.)

View File

@@ -6,6 +6,8 @@ Sublass of Layer used for services which require initiating multiple HTTPRequest
OpenLayers.Layer.HTTPRequest(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.HTTPRequest(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.
* Methods * Methods
initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/maxZoomLevels/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming. initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/numZoomLevel/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming.
getFullRequestString(newParams) -- {String} -- Returns the full request string for a combination of the defaults on this layer and the parameters passed via newParams. getFullRequestString(newParams) -- {String} -- Returns the full request string for a combination of the defaults on this layer and the parameters passed via newParams.
* Options
reproject -- If reproject is true, then the layer will alter the bounding boxes of its tiles to be based on the geographic location of the pixel bounds in the base layer. This is important for reprojecting WMS tiles onto something like Google Maps. Tile locations are calculated, and then when creating the tile request, the bounding box is adjusted to match the bounding box of the base layer at that location.

9
doc/Layer.Image.txt Normal file
View File

@@ -0,0 +1,9 @@
OpenLayers.Layer.Image
The Image Layer allows you to load a single image and use it as a layer in your
map.
* Constructor
OpenLayers.Layer(name, url, {OpenLayers.Bounds|bounds}, {OpenLayers.Size|size}, {options}) -- Image Layer constructor requires a name, URL of the image, geographic bounds of the image, pixel size of the image, and an optional options parameter.

15
doc/Layer.TMS.txt Normal file
View File

@@ -0,0 +1,15 @@
OpenLayers.Layer.TMS
The TMS layer allows one to connect to a TMS -- Tiled Map Service -- server to obtain images.
* Constructor
OpenLayers.Layer.TMS(name, url, options) -- URL is the base URL to the layer. Options is a set of options, extending the parameters of the layer.
* Methods
getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a TMS URL for the given bounds based on the properties of the layer.
All other methods are inherited from {OpenLayers.Layer.Grid}
* Options
tileOrigin -- The tileOrigin option will allow you to set your tileOrigin to something other than the lower left extent of your map.
layername -- Name of the layer in the TMS request.
type -- The extension images have.

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.
@@ -21,8 +20,10 @@ of different layers.
getZoomForExtent({OpenLayers.Bounds|bounds}) -- {Integer} -- return the integer zoom which most closely matches the passed bounds. getZoomForExtent({OpenLayers.Bounds|bounds}) -- {Integer} -- return the integer zoom which most closely matches the passed bounds.
getLonLatFromViewPortPx({OpenLayers.Pixel|pixel}) -- {OpenLayers.LonLat} -- Returns an OpenLayers.LonLat which is the passed-in view port OpenLayers.Pixel, translated into lon/lat by the laye getLonLatFromViewPortPx({OpenLayers.Pixel|pixel}) -- {OpenLayers.LonLat} -- Returns an OpenLayers.LonLat which is the passed-in view port OpenLayers.Pixel, translated into lon/lat by the laye
getViewPortPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel} -- Returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into view port pixels getViewPortPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel} -- Returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into view port pixels
addOptions({options})) -- none -- Change the options on the layer. This is the supported way to change properties of the layer.
* Parameters * Parameters
displayOutsideMaxExtent -- Determine whether images or data are loaded outside the maxExtent. Default is false.
isBaseLayer -- This determines whether the layer is a base layer or an overlay. Only one Base Layer can be displayed on the map at once. Default is false. isBaseLayer -- This determines whether the layer is a base layer or an overlay. Only one Base Layer can be displayed on the map at once. Default is false.
projection -- SRS string to describe the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map. projection -- SRS string to describe the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.
maxExtent -- an OpenLayers.Bounds for the layer. This is the maximum geographic extent of the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map. maxExtent -- an OpenLayers.Bounds for the layer. This is the maximum geographic extent of the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.
@@ -31,6 +32,7 @@ of different layers.
minScale -- The scale at zoom level 0. If this is set on the map before the Layer is added to the map, it will inherit from the map. minScale -- The scale at zoom level 0. If this is set on the map before the Layer is added to the map, it will inherit from the map.
maxScale -- The scale at the highest zoom level. If this is set on the map before the Layer is added to the map, it will inherit from the map. maxScale -- The scale at the highest zoom level. If this is set on the map before the Layer is added to the map, it will inherit from the map.
units -- The units the map is projected into. If this is set on the map before the Layer is added to the map, it will inherit from the map. units -- The units the map is projected into. If this is set on the map before the Layer is added to the map, it will inherit from the map.

View File

@@ -54,6 +54,8 @@ Instantiate class {OpenLayers.Map} in order to create a map. This is the central
changelayer -- a layer has some property of it, typically visibility, changed. changelayer -- a layer has some property of it, typically visibility, changed.
changebaselayer -- the current base layer changes changebaselayer -- the current base layer changes
movestart -- start of a movement in the map movestart -- start of a movement in the map
move -- end of movement in a map. this happens while te mouse is dragging as well as for all other events.
moveend -- end of movement in a map, but does not happen when the 'dragging' flag is set, as is the case when the move event is in the middle of a drag action.
zoomend -- end of a zoom action zoomend -- end of a zoom action
mouseover -- map is moused over mouseover -- map is moused over
mouseout -- map is no longer mousedout mouseout -- map is no longer mousedout
@@ -72,4 +74,4 @@ Instantiate class {OpenLayers.Map} in order to create a map. This is the central
* maxScale -- The maximum scale the map should include. Overrides maxZoomLevel if present. * maxScale -- The maximum scale the map should include. Overrides maxZoomLevel if present.
* units -- The units of the map. Defaults to degrees. Neccesary when using scale in any way. * units -- The units of the map. Defaults to degrees. Neccesary when using scale in any way.
* scales -- An array of scale values. Overrides maxResolution, maxZoomLevel, resolutions, and min/max scale if present. * scales -- An array of scale values. Overrides maxResolution, maxZoomLevel, resolutions, and min/max scale if present.

View File

@@ -5,3 +5,4 @@ Utility class. Stores a bunch of methods and settings that don't fit anywhere el
* Options * 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). 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).
OpenLayers.ImgPath -- A string to be used as the base for images for controls and the like. Should end with '/'.

View File

@@ -10,6 +10,8 @@ Patch contributors
------------------ ------------------
Corey Puffault Corey Puffault
Tim Schaub Tim Schaub
Jeff Dege
Sean Gilles
OpenLayers is graciously supported by MetaCarta, Inc. OpenLayers is graciously supported by MetaCarta, Inc.
<http://www.metacarta.com>. <http://www.metacarta.com>.

49
doc/customization Normal file
View File

@@ -0,0 +1,49 @@
Customizing OpenLayers
======================
OpenLayers is designed to fit many needs -- fitting in alongside all kinds of
various applications which are currently in use.
Currently, OpenLayers supports a 'theme' option when creating a map. This
theme option allows you to specify the location of a CSS theme which should
be included.
A default theme is available as an example in the theme/ directory: the setup
is:
* theme/
* theme/default/
* theme/default/style.css
* theme/default/img/
Currently, the OpenLayers code does not support class names, and therefore,
it is not possible to control many aspects of OpenLayers code with CSS
classes. However, with this framework in place, we expect to invest time
to make existing features and new features use the CSS theming framework
where apropriate.
Class Naming
============
Elements should have class names which are descriptive of the Javascript
class from which they come. For example, the main layer switcher element
in the OpenLayers.Control.LayerSwitcher would be classed:
olControlLayerSwitcher
This would allow users to add to their style.css class in their theme,
changing, for example:
::
.olControlLayerSwitcher input {
width:10px;
}
Sub elements of a particular control can add to the class name:
::
.olControlLayerSwitcherBaseLabel {
color: red;
}

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 100%; width: 100%;
@@ -14,7 +13,9 @@
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script> <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
<!-- Localhost key --> <!-- Localhost key -->
<!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>--> <!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
<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">
<!-- <!--
@@ -35,15 +36,18 @@
{layers: 'basic'} ); {layers: 'basic'} );
var google = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP }); var google = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
var ve = new OpenLayers.Layer.VirtualEarth( "VE"); var ve = new OpenLayers.Layer.VirtualEarth( "VE");
var yahoo = new OpenLayers.Layer.Yahoo( "Yahoo");
var mm = new OpenLayers.Layer.MultiMap( "MultiMap");
map.addLayers([wms, google, ve]); map.addLayers([wms, google, ve, yahoo, mm]);
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.MousePosition() );
} }

View File

@@ -13,6 +13,13 @@
function init(){ function init(){
var map = new OpenLayers.Map('map', { controls: [] }); var map = new OpenLayers.Map('map', { controls: [] });
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
map.addControl(new OpenLayers.Control.Permalink());
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.OverviewMap());
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", "http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} ); {layers: 'basic'} );
@@ -31,11 +38,6 @@
dm_wms.setVisibility(false); dm_wms.setVisibility(false);
map.addLayers([ol_wms, jpl_wms, dm_wms]); map.addLayers([ol_wms, jpl_wms, dm_wms]);
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Permalink());
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
if (!map.getCenter()) map.zoomToMaxExtent(); if (!map.getCenter()) map.zoomToMaxExtent();
} }
// --> // -->

View File

@@ -13,18 +13,28 @@
function init(){ function init(){
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
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]
};
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'},
options);
var options2 = {
resolutions: [0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101]
};
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"}, options2);
var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo", var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"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," +
"prov_bound,fedlimit,rail,road,popplace", "prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" }); transparent: "true", format: "image/png"},
{minResolution: 0.17578125,
maxResolution: 0.703125});
map.addLayers([ol_wms, jpl_wms, dm_wms]); map.addLayers([ol_wms, jpl_wms, dm_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());

View File

@@ -1,16 +1,14 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
body { font-family: sans-serif; font-weight: bold; font-size: .8em; }
body { body {
border: 0px; border: 0px;
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
#map { #map {
width: 65%; width: 100%;
height: 100%; height: 100%;
border: 0px; border: 0px;
padding: 0px; padding: 0px;
@@ -23,86 +21,29 @@
var lat = 900863; var lat = 900863;
var lon = 235829; var lon = 235829;
var zoom = 6; var zoom = 6;
var map, layer; var map, layer;
function init(){ function init(){
// these should be object methods or something
map = new OpenLayers.Map( $('map') ); map = new OpenLayers.Map( $('map') );
var basemap = new OpenLayers.Layer.WMS( "Boston", var basemap = new OpenLayers.Layer.WMS( "Boston",
"http://boston.freemap.in/cgi-bin/mapserv?", "http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads', format: 'png', 'transparent': 'off'}, {map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads,rapid_transit,buildings', format: 'png', 'transparent': 'off'},
// These are the important parts for creating a non-epsg:4326
// map: Maxextent is the boundary of the map/tile loading area,
// maxResolution is the units/pixel at the highest zoom, and
// projection is the projection to be used in WMS/WFS Requests.
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } ); {maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
var rapid = new OpenLayers.Layer.WMS( "Rapid Transit",
"http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/mass.map', layers: 'rapid_transit', format: 'png', transparent:'true'} );
var buildings = new OpenLayers.Layer.WMS( "Buildings",
"http://boston.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/boston/map/mass.map', layers: 'buildings', format: 'png', transparent:'true'} );
map.addLayer(basemap); map.addLayer(basemap);
map.addLayer(rapid);
map.addLayer(buildings);
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());
} }
function getaddress() {
if (!document.getElementById('address').value) {return; }
document.getElementById('status').innerHTML = "Finding address...";
var address = document.getElementById('address').value;
address = escape(address);
addr = "/geocode.cgi?address="+address;
var handler = XMLrequest();
if (handler) {
handler.onreadystatechange=function() {
if (handler.readyState == 4 && handler.status == 200) {
var latlon = handler.responseText;
latlon = latlon.split(",");
if (latlon[1]) {
map.setCenter(new OpenLayers.LonLat(parseFloat(latlon[1]), parseFloat(latlon[0])), 15);
document.getElementById('status').innerHTML = "";
} else {
document.getElementById('status').innerHTML = "Could not find address, sorry.";
}
}
}
handler.open("GET", addr, true);
handler.send('');
}
}
function XMLrequest() {
xmlhttp={};
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) { }
}
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {}
return xmlhttp;
}
function setLink() {
var link = document.getElementById("link");
var center = map.getCenter();
var zoom = map.getZoom();
link.innerHTML="http://boston.freemap.in/?zoom="+zoom+"&amp;lat="+center.lat+"&amp;lon="+center.lon;
}
// --> // -->
</script> </script>
</head> </head>
<body onload="init()"> <body onload="init()">
<div id="right" style="float:right;width:30%;padding:10px;" ><h1>Boston Free Map</h1><!--Search: <input type="text" id='address' name="address"><input type="submit" value="Go!" onclick="javascript:getaddress()"/>--><div id="status" style="height:20px;min-height:20px;">&nbsp;</div>
<div>Map powered by <a href="http://www.openlayers.org/">OpenLayers</a>
and <a href="http://mapserver.gis.umn.edu/">MapServer</a>.
Data downloaded from
<a href="http://www.mass.gov/mgis/">Office of Geographic and Environmental Information (MassGIS)</a>.</div>
<!--<a onclick="setLink(); return false" href="#" id="update">Update Link</a>
<div id="link"></div>-->
</div>
<div id="map"></div> <div id="map"></div>
</body> </body>
</html> </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:80/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

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 800px; width: 800px;

View File

@@ -0,0 +1,47 @@
<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) {
$('nodeList').innerHTML = "Loading... please wait...";
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

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 100%; width: 100%;
@@ -11,7 +10,7 @@
</style> </style>
<!-- this gmaps key generated for http://openlayers.org/dev/ --> <!-- this gmaps key generated for http://openlayers.org/dev/ -->
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script> <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
<!-- Localhost key --> <!-- Localhost key -->
<!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>--> <!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
@@ -19,25 +18,35 @@
<!-- <!--
var lon = 5; var lon = 5;
var lat = 40; var lat = 40;
var zoom = 5; var zoom = 17;
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()] }); { controls: [new OpenLayers.Control.MouseDefaults()] , 'numZoomLevels':20});
var normal = new OpenLayers.Layer.Google( "Google", // ); var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} );
{ minZoomLevel: 3, maxZoomLevel: 8 });
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP });
var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
map.addLayers([satellite, normal, hybrid]); map.addLayers([satellite]);
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
layer.setVisibility(false);
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
layer.setVisibility(false);
map.addLayer(layer);
var twms = new OpenLayers.Layer.WMS( "World Map",
"http://world.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/world/map/factbooktrans.map', transparent:'true',
layers: 'factbook', 'format':'png'} );
map.addLayer(twms);
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(10.205188,48.857593), 5);
map.addControl( new OpenLayers.Control.LayerSwitcher() ); map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() ); map.addControl( new OpenLayers.Control.PanZoomBar() );

51
examples/image-layer.html Normal file
View File

@@ -0,0 +1,51 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
p {
width: 512px;
}
#map {
width: 512px;
height: 256px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map');
var options = {maxResolution: 'auto', numZoomLevels: 3};
var graphic = new OpenLayers.Layer.Image(
'City Lights',
'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288),
options);
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"}, options);
map.addLayers([graphic, jpl_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Image Layer Example</h1>
<div id="map"></div>
<p>
The "City Lights" layer above is created from a single web accessible
image. If you construct it without any resolution related options,
the layer will be given a single resolution based on the extent/size.
Otherwise, it behaves much like a regular layer. This is primarily
intended to be used in an overview map - where another layer type
might not make a good overview.
</p>
</body>
</html>

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($('opacity').value) + 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/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>

31
examples/lite.html Normal file
View File

@@ -0,0 +1,31 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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 = 5;
var lat = 40;
var zoom = 5;
var map, layer;
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);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,43 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Cursor Example</title>
<style type="text/css">
#map {
width: 700px;
height: 400px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map', { controls: [] });
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.MousePosition());
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} );
map.addLayers([ol_wms]);
OpenLayers.Event.observe($('map'),"click",mapclicked.bindAsEventListener(map));
function mapclicked(e){
var lonlat = map.getLonLatFromPixel(e.xy);
alert("Lat: " + lonlat.lat + " (Pixel.x:" + e.xy.x + ")" + "\n" + "Lon: " + lonlat.lon + " (Pixel.y:" + e.xy.y + ")" );
};
if (!map.getCenter()) map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Cursor Example</h1>
<div id="map"></div>
</body>
</html>

34
examples/mapserver.html Normal file
View File

@@ -0,0 +1,34 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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 = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;
@@ -21,20 +20,29 @@
map.addLayer(layer); map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.setCenter(new OpenLayers.LonLat(0, 0), 0);
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var newl = new OpenLayers.Layer.Text( "text", { location:"./textfile.txt"} ); var newl = new OpenLayers.Layer.Text( "text", { location:"./textfile.txt"} );
map.addLayer(newl); map.addLayer(newl);
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(10,17); var size = new OpenLayers.Size(10,17);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',size,offset); var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',size,offset);
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon)); markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,45),icon.clone()));
var halfIcon = icon.clone();
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,45),halfIcon));
marker = new OpenLayers.Marker(new OpenLayers.LonLat(90,10),icon.clone()); marker = new OpenLayers.Marker(new OpenLayers.LonLat(90,10),icon.clone());
marker.setOpacity(0.2);
marker.events.register('mousedown', marker, function(evt) { alert(this.icon.url); Event.stop(evt); }); marker.events.register('mousedown', marker, function(evt) { alert(this.icon.url); Event.stop(evt); });
markers.addMarker(marker); markers.addMarker(marker);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent(); map.zoomToMaxExtent();
halfIcon.setOpacity(0.5);
} }
// --> // -->
</script> </script>

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 100%; width: 100%;

35
examples/multiserver.html Normal file
View File

@@ -0,0 +1,35 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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 = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
var urlArray = ["http://labs.metacarta.com/wms-c/Basic.py",
"http://monitor.metacarta.com/wms-c/Basic.py"];
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
urlArray,
{layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -15,7 +15,7 @@
var ol_wms = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS", var ol_wms = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
ol_wms.isBaseLayer = true; ol_wms.addOptions({isBaseLayer: true});
map.addLayers([ol_wms]); map.addLayers([ol_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.setCenter(new OpenLayers.LonLat(0, 0), 0);

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 800px; width: 800px;

47
examples/overviewmap.html Normal file
View File

@@ -0,0 +1,47 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Overview Map Example</title>
<script src="../lib/OpenLayers.js" type="text/javascript"></script>
<style>
#map{
width:100%;
height:500px;
border:1px solid;
}
</style>
</head>
<body>
<div id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
// my city
var constantina = new OpenLayers.LonLat(-5.6165,37.8623);
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
var nasa_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"} );
map.addLayers([
nasa_wms,
wms
]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var options = {
layers: [wms.clone()],
minRatio: 8,
maxRatio: 128
};
var overview = new OpenLayers.Control.OverviewMap(options);
map.addControl(overview);
map.setCenter(constantina, 4);
overview.maximizeControl();
</script>
</body>
</html>

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;
@@ -38,7 +37,8 @@
popup = new OpenLayers.Popup("chicken", popup = new OpenLayers.Popup("chicken",
new OpenLayers.LonLat(5,40), new OpenLayers.LonLat(5,40),
new OpenLayers.Size(200,200), new OpenLayers.Size(200,200),
"example popup"); "example popup",
true);
map.addPopup(popup); map.addPopup(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>

View File

@@ -1,4 +1,4 @@
point title description iconSize point title description icon
10,20 my orange title my orange description 21,25 10,20 my orange title my orange description
2,4 my aqua title my aqua description 21,25 2,4 my aqua title my aqua description
42,-71 my purple title my purple description<br/>is great. 21,25 42,-71 my purple title my purple description<br/>is great. http://www.openlayers.org/api/img/zoom-world-mini.png

View File

@@ -19,7 +19,7 @@
"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; ka_wms.addOptions({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());

39
examples/tms.html Normal file
View File

@@ -0,0 +1,39 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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 = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map'), {maxResolution:1.40625/2} );
layer = new OpenLayers.Layer.TMS( "TMS",
"http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png'} );
map.addLayer(layer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
function addTMS() {
l=new OpenLayers.Layer.TMS($('layer').value, $('url').value, {layername: $('layer').value, type:$('type').value});
map.addLayer(l);
map.setBaseLayer(l);
}
// -->
</script>
</head>
<body onload="init()">
URL of TMS (Should end in /): <input type="text" id="url" size="60" /> layer_name <input type="text" id="layer" /> <select id="type"><option>png</option><option>jpg</option></select> <input type="submit" onclick="addTMS()"/><br />
Example: http://mapserver.refractions.net/cgi-bin/tms/, global_mosaic, jpg
<div id="map"></div>
</body>
</html>

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 100%; width: 100%;
@@ -26,8 +25,16 @@
{controls:[new OpenLayers.Control.MouseDefaults()]}); {controls:[new OpenLayers.Control.MouseDefaults()]});
velayer = new OpenLayers.Layer.VirtualEarth( "VE", velayer = new OpenLayers.Layer.VirtualEarth( "VE",
{ minZoomLevel: 4, maxZoomLevel: 6 }); { minZoomLevel: 4, maxZoomLevel: 6, 'type': VEMapStyle.Aerial});
map.addLayer(velayer); map.addLayer(velayer);
var twms = new OpenLayers.Layer.WMS( "World Map",
"http://world.freemap.in/cgi-bin/mapserv?",
{ map: '/www/freemap.in/world/map/factbooktrans.map',
transparent:'true',
layers: 'factbook',
'format':'png'} );
map.addLayer(twms);
markers = new OpenLayers.Layer.Markers("markers"); markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers); map.addLayer(markers);

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 800px; width: 800px;

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,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 512px; width: 512px;

View File

@@ -1,6 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css"> <style type="text/css">
#map { #map {
width: 800px; width: 800px;

BIN
img/close.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/marker-blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

BIN
img/marker-gold.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

BIN
img/marker-green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
//// ////
/// This blob sucks in all the files in uncompressed form for ease of use /// This blob sucks in all the files in uncompressed form for ease of use
/// ///
@@ -48,11 +49,10 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
*/ */
(function() { (function() {
var jsfiles=new Array( var jsfiles=new Array(
"Prototype.js",
"Rico/Corner.js",
"Rico/Color.js",
"OpenLayers/BaseTypes.js", "OpenLayers/BaseTypes.js",
"OpenLayers/Util.js", "OpenLayers/Util.js",
"Rico/Corner.js",
"Rico/Color.js",
"OpenLayers/Ajax.js", "OpenLayers/Ajax.js",
"OpenLayers/Events.js", "OpenLayers/Events.js",
"OpenLayers/Map.js", "OpenLayers/Map.js",
@@ -66,6 +66,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Feature/WFS.js", "OpenLayers/Feature/WFS.js",
"OpenLayers/Tile/Image.js", "OpenLayers/Tile/Image.js",
"OpenLayers/Tile/WFS.js", "OpenLayers/Tile/WFS.js",
"OpenLayers/Layer/Image.js",
"OpenLayers/Layer/EventPane.js", "OpenLayers/Layer/EventPane.js",
"OpenLayers/Layer/FixedZoomLevels.js", "OpenLayers/Layer/FixedZoomLevels.js",
"OpenLayers/Layer/Google.js", "OpenLayers/Layer/Google.js",
@@ -73,6 +74,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"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/MapServer.js",
"OpenLayers/Layer/KaMap.js", "OpenLayers/Layer/KaMap.js",
"OpenLayers/Layer/MultiMap.js", "OpenLayers/Layer/MultiMap.js",
"OpenLayers/Layer/Markers.js", "OpenLayers/Layer/Markers.js",
@@ -84,34 +86,40 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Layer/GeoRSS.js", "OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/Canvas.js", "OpenLayers/Layer/Canvas.js",
"OpenLayers/Layer/TMS.js",
"OpenLayers/Popup/Anchored.js", "OpenLayers/Popup/Anchored.js",
"OpenLayers/Popup/AnchoredBubble.js", "OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Control.js", "OpenLayers/Control.js",
"OpenLayers/Control/MouseDefaults.js", "OpenLayers/Control/MouseDefaults.js",
"OpenLayers/Control/MouseToolbar.js", "OpenLayers/Control/MouseToolbar.js",
"OpenLayers/Control/MousePosition.js",
"OpenLayers/Control/OverviewMap.js",
"OpenLayers/Control/KeyboardDefaults.js", "OpenLayers/Control/KeyboardDefaults.js",
"OpenLayers/Control/PanZoom.js", "OpenLayers/Control/PanZoom.js",
"OpenLayers/Control/PanZoomBar.js", "OpenLayers/Control/PanZoomBar.js",
"OpenLayers/Control/ArgParser.js",
"OpenLayers/Control/Permalink.js", "OpenLayers/Control/Permalink.js",
"OpenLayers/Control/Scale.js", "OpenLayers/Control/Scale.js",
"OpenLayers/Control/LayerSwitcher.js", "OpenLayers/Control/LayerSwitcher.js"
"OpenLayers/Control/LayerTabs.js"
); // etc. ); // etc.
var allScriptTags = ""; var allScriptTags = "";
var host = OpenLayers._getScriptLocation() + "lib/"; var host = OpenLayers._getScriptLocation() + "lib/";
// check to see if prototype.js was already loaded for (var i = 0; i < jsfiles.length; i++) {
// if so, skip the first dynamic include if (/MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) {
// var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";
var start=1; allScriptTags += currentScriptTag;
try { x = Prototype; } } else {
catch (e) { start=0; } var s = document.createElement("script");
s.src = host + jsfiles[i];
for (var i = start; i < jsfiles.length; i++) { var h = document.getElementsByTagName("head").length ?
var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>"; document.getElementsByTagName("head")[0] :
allScriptTags += currentScriptTag; document.body;
h.appendChild(s);
}
} }
document.write(allScriptTags); if (allScriptTags) document.write(allScriptTags);
})(); })();
} }
OpenLayers.VERSION_NUMBER="$Revision$";

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
OpenLayers.ProxyHost = ""; OpenLayers.ProxyHost = "";
//OpenLayers.ProxyHost = "examples/proxy.cgi?url="; //OpenLayers.ProxyHost = "examples/proxy.cgi?url=";
@@ -60,7 +61,7 @@ OpenLayers.loadURL = function(uri, params, caller,
: OpenLayers.nullHandler; : OpenLayers.nullHandler;
// from prototype.js // from prototype.js
new Ajax.Request(uri, new OpenLayers.Ajax.Request(uri,
{ method: 'get', { method: 'get',
parameters: params, parameters: params,
onComplete: success, onComplete: success,
@@ -83,7 +84,7 @@ OpenLayers.parseXMLString = function(text) {
text = text.substring(index); text = text.substring(index);
} }
var ajaxResponse = Try.these( var ajaxResponse = OpenLayers.Util.Try(
function() { function() {
var xmldom = new ActiveXObject('Microsoft.XMLDOM'); var xmldom = new ActiveXObject('Microsoft.XMLDOM');
xmldom.loadXML(text); xmldom.loadXML(text);
@@ -106,3 +107,202 @@ OpenLayers.parseXMLString = function(text) {
return ajaxResponse; return ajaxResponse;
}; };
OpenLayers.Ajax = {
emptyFunction: function () {},
getTransport: function() {
return OpenLayers.Util.Try(
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
function() {return new XMLHttpRequest()}
) || false;
},
activeRequestCount: 0
};
OpenLayers.Ajax.Responders = {
responders: [],
register: function(responderToAdd) {
for (var i = 0; i < this.responders.length; i++)
if (responderToAdd == this.responders[i])
return;
this.responders.push(responderToAdd);
},
dispatch: function(callback, request, transport, json) {
for (var i = 0; i < this.responders.length; i++) {
responder = this.responders[i];
if (responder[callback] && typeof responder[callback] == 'function') {
try {
responder[callback].apply(responder, [request, transport, json]);
} catch (e) {}
}
}
}
};
OpenLayers.Ajax.Responders.register({
onCreate: function() {
OpenLayers.Ajax.activeRequestCount++;
},
onComplete: function() {
OpenLayers.Ajax.activeRequestCount--;
}
});
OpenLayers.Ajax.Base = function() {};
OpenLayers.Ajax.Base.prototype = {
setOptions: function(options) {
this.options = {
method: 'post',
asynchronous: true,
parameters: ''
}
OpenLayers.Util.extend(this.options, options || {});
},
responseIsSuccess: function() {
return this.transport.status == undefined
|| this.transport.status == 0
|| (this.transport.status >= 200 && this.transport.status < 300);
},
responseIsFailure: function() {
return !this.responseIsSuccess();
}
}
OpenLayers.Ajax.Request = OpenLayers.Class.create();
OpenLayers.Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
OpenLayers.Ajax.Request.prototype = OpenLayers.Class.inherit( OpenLayers.Ajax.Base, {
initialize: function(url, options) {
this.transport = OpenLayers.Ajax.getTransport();
this.setOptions(options);
this.request(url);
},
request: function(url) {
var parameters = this.options.parameters || '';
if (parameters.length > 0) parameters += '&_=';
try {
this.url = url;
if (this.options.method == 'get' && parameters.length > 0)
this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
OpenLayers.Ajax.Responders.dispatch('onCreate', this, this.transport);
this.transport.open(this.options.method, this.url,
this.options.asynchronous);
if (this.options.asynchronous) {
this.transport.onreadystatechange = this.onStateChange.bind(this);
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
}
this.setRequestHeaders();
var body = this.options.postBody ? this.options.postBody : parameters;
this.transport.send(this.options.method == 'post' ? body : null);
} catch (e) {
this.dispatchException(e);
}
},
setRequestHeaders: function() {
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest',
'X-Prototype-Version', 'OpenLayers'];
if (this.options.method == 'post') {
requestHeaders.push('Content-type',
'application/x-www-form-urlencoded');
/* Force "Connection: close" for Mozilla browsers to work around
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType)
requestHeaders.push('Connection', 'close');
}
if (this.options.requestHeaders)
requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
for (var i = 0; i < requestHeaders.length; i += 2)
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
},
onStateChange: function() {
var readyState = this.transport.readyState;
if (readyState != 1)
this.respondToReadyState(this.transport.readyState);
},
header: function(name) {
try {
return this.transport.getResponseHeader(name);
} catch (e) {}
},
evalJSON: function() {
try {
return eval(this.header('X-JSON'));
} catch (e) {}
},
evalResponse: function() {
try {
return eval(this.transport.responseText);
} catch (e) {
this.dispatchException(e);
}
},
respondToReadyState: function(readyState) {
var event = OpenLayers.Ajax.Request.Events[readyState];
var transport = this.transport, json = this.evalJSON();
if (event == 'Complete') {
try {
(this.options['on' + this.transport.status]
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
|| OpenLayers.Ajax.emptyFunction)(transport, json);
} catch (e) {
this.dispatchException(e);
}
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
this.evalResponse();
}
try {
(this.options['on' + event] || OpenLayers.Ajax.emptyFunction)(transport, json);
OpenLayers.Ajax.Responders.dispatch('on' + event, this, transport, json);
} catch (e) {
this.dispatchException(e);
}
/* Avoid memory leak in MSIE: clean up the oncomplete event handler */
if (event == 'Complete')
this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction;
},
dispatchException: function(exception) {
(this.options.onException || OpenLayers.Ajax.emptyFunction)(this, exception);
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
}
});
OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, nsprefix, tagname) {
return parentnode.getElementsByTagNameNS ?
parentnode.getElementsByTagNameNS(nsuri, tagname)
: parentnode.getElementsByTagName(nsprefix + ':' + tagname);
}

View File

@@ -1,21 +1,51 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/* OpenLayers.Class metaclass */
OpenLayers.Class = {
isPrototype: function () {}, // magic anonymous value
create: function() {
return function() {
if (arguments && arguments[0] != OpenLayers.Class.isPrototype)
this.initialize.apply(this, arguments);
}
},
inherit: function () {
var superClass = arguments[0];
var proto = new superClass(OpenLayers.Class.isPrototype);
for (var i = 1; i < arguments.length; i++) {
if (typeof arguments[i] == "function") {
var mixin = arguments[i];
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
}
OpenLayers.Util.extend(proto, arguments[i]);
}
return proto;
}
};
/*
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, OpenLayers.Layer.HTTPRequest, {
some stuff
});
*/
/********************* /*********************
* * * *
* PIXEL * * PIXEL *
* * * *
*********************/ *********************/
/** /**
* @class * @class
* *
* This class represents a screen coordinate, in x and y coordinates * This class represents a screen coordinate, in x and y coordinates
*/ */
OpenLayers.Pixel = Class.create(); OpenLayers.Pixel = OpenLayers.Class.create();
OpenLayers.Pixel.prototype = { OpenLayers.Pixel.prototype = {
/** @type float */ /** @type float */
@@ -86,7 +116,11 @@ OpenLayers.Pixel.prototype = {
* @type OpenLayers.Pixel * @type OpenLayers.Pixel
*/ */
offset:function(px) { offset:function(px) {
return this.add(px.x, px.y); var newPx = this.clone();
if (px) {
newPx = this.add(px.x, px.y);
}
return newPx;
}, },
/** @final @type str */ /** @final @type str */
@@ -106,7 +140,7 @@ OpenLayers.Pixel.prototype = {
* *
* This class represents a width and height pair * This class represents a width and height pair
*/ */
OpenLayers.Size = Class.create(); OpenLayers.Size = OpenLayers.Class.create();
OpenLayers.Size.prototype = { OpenLayers.Size.prototype = {
/** @type float */ /** @type float */
@@ -177,7 +211,7 @@ OpenLayers.Size.prototype = {
* *
* This class represents a longitude and latitude pair * This class represents a longitude and latitude pair
*/ */
OpenLayers.LonLat = Class.create(); OpenLayers.LonLat = OpenLayers.Class.create();
OpenLayers.LonLat.prototype = { OpenLayers.LonLat.prototype = {
/** @type float */ /** @type float */
@@ -290,7 +324,7 @@ OpenLayers.LonLat.fromString = function(str) {
* This class represents a bounding box. * This class represents a bounding box.
* Data stored as left, bottom, right, top floats * Data stored as left, bottom, right, top floats
*/ */
OpenLayers.Bounds = Class.create(); OpenLayers.Bounds = OpenLayers.Class.create();
OpenLayers.Bounds.prototype = { OpenLayers.Bounds.prototype = {
/** @type float */ /** @type float */
@@ -360,13 +394,24 @@ OpenLayers.Bounds.prototype = {
}, },
/** /**
* @return Simple String representation of OpenLayers.Bounds object. * @param {int} decimal How many significant digits in the bbox coords?
* (ex. <i>"5,42,10,45"</i>) * Default is 6
* @type String *
*/ * @returns Simple String representation of OpenLayers.Bounds object.
toBBOX:function() { * (ex. <i>"5,42,10,45"</i>)
return (this.left + "," + this.bottom + "," * @type String
+ this.right + "," + this.top); */
toBBOX:function(decimal) {
if (decimal== null) {
decimal = 6;
}
var mult = Math.pow(10, decimal);
var bbox = Math.round(this.left * mult) / mult + "," +
Math.round(this.bottom * mult) / mult + "," +
Math.round(this.right * mult) / mult + "," +
Math.round(this.top * mult) / mult;
return bbox;
}, },
/** /**
@@ -424,6 +469,30 @@ OpenLayers.Bounds.prototype = {
this.right + x, this.top + y); this.right + x, this.top + y);
}, },
/**
* @param {OpenLayers.LonLat} ll
* @param {Boolean} inclusive Whether or not to include the border.
* Default is true
*
* @return Whether or not the passed-in lonlat is within this bounds
* @type Boolean
*/
containsLonLat:function(ll, inclusive) {
return this.contains(ll.lon, ll.lat, inclusive);
},
/**
* @param {OpenLayers.Pixel} px
* @param {Boolean} inclusive Whether or not to include the border.
* Default is true
*
* @return Whether or not the passed-in pixel is within this bounds
* @type Boolean
*/
containsPixel:function(px, inclusive) {
return this.contains(px.x, px.y, inclusive);
},
/** /**
* @param {float} x * @param {float} x
* @param {float} y * @param {float} y
@@ -450,7 +519,40 @@ OpenLayers.Bounds.prototype = {
} }
return contains; return contains;
}, },
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} inclusive Whether or not to include the border.
* Default is true
*
* @return Whether or not the passed-in OpenLayers.Bounds object intersects
* this bounds. Simple math just check if either contains the other,
* allowing for partial.
* @type Boolean
*/
intersectsBounds:function(bounds, inclusive) {
if (inclusive == null) {
inclusive = true;
}
var inBottom = (bounds.bottom == this.bottom && bounds.top == this.top) ?
true : (((bounds.bottom > this.bottom) && (bounds.bottom < this.top)) ||
((this.bottom > bounds.bottom) && (this.bottom < bounds.top)));
var inTop = (bounds.bottom == this.bottom && bounds.top == this.top) ?
true : (((bounds.top > this.bottom) && (bounds.top < this.top)) ||
((this.top > bounds.bottom) && (this.top < bounds.top)));
var inRight = (bounds.right == this.right && bounds.left == this.left) ?
true : (((bounds.right > this.left) && (bounds.right < this.right)) ||
((this.right > bounds.left) && (this.right < bounds.right)));
var inLeft = (bounds.right == this.right && bounds.left == this.left) ?
true : (((bounds.left > this.left) && (bounds.left < this.right)) ||
((this.left > bounds.left) && (this.left < bounds.right)));
return (this.containsBounds(bounds, true, inclusive) ||
bounds.containsBounds(this, true, inclusive) ||
((inTop || inBottom ) && (inLeft || inRight )));
},
/** /**
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* @param {Boolean} partial If true, only part of passed-in * @param {Boolean} partial If true, only part of passed-in
@@ -491,7 +593,7 @@ OpenLayers.Bounds.prototype = {
inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top); inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top);
} }
return (partial) ? (inTop || inBottom) && (inLeft || inRight ) return (partial) ? (inTop || inBottom ) && (inLeft || inRight )
: (inTop && inLeft && inBottom && inRight); : (inTop && inLeft && inBottom && inRight);
}, },
@@ -584,7 +686,88 @@ OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
}; };
/*********************
* *
* ELEMENT *
* *
*********************/
OpenLayers.Element = {
visible: function(element) {
return $(element).style.display != 'none';
},
toggle: function() {
for (var i = 0; i < arguments.length; i++) {
var element = $(arguments[i]);
OpenLayers.Element[OpenLayers.Element.visible(element) ? 'hide' : 'show'](element);
}
},
hide: function() {
for (var i = 0; i < arguments.length; i++) {
var element = $(arguments[i]);
element.style.display = 'none';
}
},
show: function() {
for (var i = 0; i < arguments.length; i++) {
var element = $(arguments[i]);
element.style.display = '';
}
},
remove: function(element) {
element = $(element);
element.parentNode.removeChild(element);
},
getHeight: function(element) {
element = $(element);
return element.offsetHeight;
},
getDimensions: function(element) {
element = $(element);
if (OpenLayers.Element.getStyle(element, 'display') != 'none')
return {width: element.offsetWidth, height: element.offsetHeight};
// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = '';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = 'none';
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
},
getStyle: function(element, style) {
element = $(element);
var value = element.style[style.camelize()];
if (!value) {
if (document.defaultView && document.defaultView.getComputedStyle) {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css.getPropertyValue(style) : null;
} else if (element.currentStyle) {
value = element.currentStyle[style.camelize()];
}
}
if (window.opera && OpenLayers.Util.indexOf(['left', 'top', 'right', 'bottom'],style) != -1)
if (OpenLayers.Element.getStyle(element, 'position') == 'static') value = 'auto';
return value == 'auto' ? null : value;
}
};
/********************* /*********************
* * * *
@@ -592,8 +775,6 @@ OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
* * * *
*********************/ *********************/
/** /**
* @param {String} sStart * @param {String} sStart
* *
@@ -635,50 +816,26 @@ String.prototype.trim = function() {
}; };
String.indexOf = function(object) {
for (var i = 0; i < this.length; i++)
/********************* if (this[i] == object) return i;
* * return -1;
* ARRAY *
* *
*********************/
/** Remove an object from an array. Iterates through the array
* to find the item, then removes it.
*
* @param {Object} item
*
* @returns A reference to the array
* @type Array
*/
Array.prototype.remove = function(item) {
for(var i=0; i < this.length; i++) {
if(this[i] == item) {
this.splice(i,1);
//break;more than once??
}
}
return this;
}
/**
* @returns A fresh copy of the array
* @type Array
*/
Array.prototype.clone = function() {
var clone = new Array();
for (var i = 0; i < this.length; i++) {
clone[i] = this[i];
}
return clone;
}; };
/** String.prototype.camelize = function() {
*/ var oStringList = this.split('-');
Array.prototype.clear = function() { if (oStringList.length == 1) return oStringList[0];
this.length = 0;
var camelizedString = this.indexOf('-') == 0
? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
: oStringList[0];
for (var i = 1, len = oStringList.length; i < len; i++) {
var s = oStringList[i];
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
}
return camelizedString;
}; };
@@ -688,8 +845,6 @@ Array.prototype.clear = function() {
* * * *
*********************/ *********************/
/** NOTE: Works only with integer values does *not* work with floats! /** NOTE: Works only with integer values does *not* work with floats!
* *
* @param {int} sig * @param {int} sig
@@ -706,3 +861,28 @@ Number.prototype.limitSigDigs = function(sig) {
} }
return parseInt(number); return parseInt(number);
} }
/*********************
* *
* FUNCTION *
* *
*********************/
Function.prototype.bind = function() {
var __method = this, args = [], object = arguments[0];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
return function(moreargs) {
for (var i = 0; i < arguments.length; i++)
args.push(arguments[i]);
return __method.apply(object, args);
}
};
Function.prototype.bindAsEventListener = function(object) {
var __method = this;
return function(event) {
return __method.call(object, event || window.event);
}
};

View File

@@ -1,11 +1,12 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
*/ */
OpenLayers.Control = Class.create(); OpenLayers.Control = OpenLayers.Class.create();
OpenLayers.Control.prototype = { OpenLayers.Control.prototype = {
/** @type String */ /** @type String */
@@ -30,7 +31,7 @@ OpenLayers.Control.prototype = {
* @param {Object} options * @param {Object} options
*/ */
initialize: function (options) { initialize: function (options) {
Object.extend(this, options); OpenLayers.Util.extend(this, options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
}, },
@@ -63,6 +64,7 @@ OpenLayers.Control.prototype = {
if (this.div == null) { if (this.div == null) {
this.div = OpenLayers.Util.createDiv(); this.div = OpenLayers.Util.createDiv();
this.div.id = this.id; this.div.id = this.id;
this.div.className = 'olControl';
} }
if (px != null) { if (px != null) {
this.position = px.clone(); this.position = px.clone();

View File

@@ -0,0 +1,114 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.ArgParser = OpenLayers.Class.create();
OpenLayers.Control.ArgParser.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.LonLat */
center: null,
/** @type int */
zoom: null,
/** @type Array */
layers: null,
/**
* @constructor
*
* @param {DOMElement} element
* @param {String} base
*/
initialize: function(element, base) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
},
/** Set the map property for the control.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Control.prototype.setMap.apply(this, arguments);
//make sure we dont already have an arg parser attached
for(var i=0; i< this.map.controls.length; i++) {
var control = this.map.controls[i];
if ( (control != this) &&
(control.CLASS_NAME == "OpenLayers.Control.ArgParser") ) {
break;
}
}
if (i == this.map.controls.length) {
var args = OpenLayers.Util.getArgs();
if (args.lat && args.lon) {
this.center = new OpenLayers.LonLat(parseFloat(args.lon),
parseFloat(args.lat));
if (args.zoom) {
this.zoom = parseInt(args.zoom);
}
// when we add a new baselayer to see when we can set the center
this.map.events.register('changebaselayer', this,
this.setCenter);
this.setCenter();
}
if (args.layers) {
this.layers = args.layers;
// when we add a new layer, set its visibility
this.map.events.register('addlayer', this,
this.configureLayers);
this.configureLayers();
}
}
},
/** As soon as a baseLayer has been loaded, we center and zoom
* ...and remove the handler.
*/
setCenter: function() {
if (this.map.baseLayer) {
//dont need to listen for this one anymore
this.map.events.unregister('changebaselayer', this,
this.setCenter);
this.map.setCenter(this.center, this.zoom);
}
},
/** As soon as all the layers are loaded, cycle through them and
* hide or show them.
*/
configureLayers: function() {
if (this.layers.length == this.map.layers.length) {
this.map.events.unregister('addlayer', this, this.configureLayers);
for(var i=0; i < this.layers.length; i++) {
var layer = this.map.layers[i];
var c = this.layers.charAt(i);
if (c == "B") {
this.map.setBaseLayer(layer);
} else if ( (c == "T") || (c == "F") ) {
layer.setVisibility(c == "T");
}
}
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.ArgParser"
});

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.KeyboardDefaults = Class.create(); OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
OpenLayers.Control.KeyboardDefaults.prototype = OpenLayers.Control.KeyboardDefaults.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type int */ /** @type int */
slideFactor: 50, slideFactor: 50,
@@ -25,7 +26,7 @@ OpenLayers.Control.KeyboardDefaults.prototype =
* *
*/ */
draw: function() { draw: function() {
Event.observe(document, OpenLayers.Event.observe(document,
'keypress', 'keypress',
this.defaultKeyDown.bind(this)); this.defaultKeyDown.bind(this));
}, },
@@ -35,16 +36,16 @@ OpenLayers.Control.KeyboardDefaults.prototype =
*/ */
defaultKeyDown: function (evt) { defaultKeyDown: function (evt) {
switch(evt.keyCode) { switch(evt.keyCode) {
case Event.KEY_LEFT: case OpenLayers.Event.KEY_LEFT:
this.map.pan(-50, 0); this.map.pan(-50, 0);
break; break;
case Event.KEY_RIGHT: case OpenLayers.Event.KEY_RIGHT:
this.map.pan(50, 0); this.map.pan(50, 0);
break; break;
case Event.KEY_UP: case OpenLayers.Event.KEY_UP:
this.map.pan(0, -50); this.map.pan(0, -50);
break; break;
case Event.KEY_DOWN: case OpenLayers.Event.KEY_DOWN:
this.map.pan(0, 50); this.map.pan(0, 50);
break; break;
} }

View File

@@ -1,15 +1,15 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.LayerSwitcher = Class.create(); OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
OpenLayers.Control.LayerSwitcher.prototype = OpenLayers.Control.LayerSwitcher.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type String */ /** @type String */
activeColor: "darkblue", activeColor: "darkblue",
@@ -43,6 +43,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
/** @type DOMElement */ /** @type DOMElement */
maximizeDiv: null, maximizeDiv: null,
/** @type Boolean */
ascending: true,
/** /**
* @constructor * @constructor
*/ */
@@ -99,53 +102,64 @@ OpenLayers.Control.LayerSwitcher.prototype =
var containsOverlays = false; var containsOverlays = false;
for( var i = 0; i < this.map.layers.length; i++) { var layers = this.map.layers.slice();
var layer = this.map.layers[i]; if (!this.ascending) { layers.reverse(); }
for( var i = 0; i < layers.length; i++) {
var layer = layers[i];
var baseLayer = layer.isBaseLayer; var baseLayer = layer.isBaseLayer;
if (!baseLayer) { if (baseLayer || layer.displayInLayerSwitcher) {
containsOverlays = true;
if (!baseLayer) {
containsOverlays = true;
}
// only check a baselayer if it is *the* baselayer, check data
// layers if they are visible
var checked = (baseLayer) ? (layer == this.map.baseLayer)
: layer.getVisibility();
// create input element
var inputElem = document.createElement("input");
inputElem.id = "input_" + layer.name;
inputElem.name = (baseLayer) ? "baseLayers" : layer.name;
inputElem.type = (baseLayer) ? "radio" : "checkbox";
inputElem.value = layer.name;
inputElem.checked = checked;
inputElem.defaultChecked = checked;
inputElem.layer = layer;
inputElem.control = this;
if (!baseLayer && !layer.inRange) {
inputElem.disabled = true;
}
OpenLayers.Event.observe(inputElem, "mouseup",
this.onInputClick.bindAsEventListener(inputElem));
// create span
var labelSpan = document.createElement("span");
if (!baseLayer && !layer.inRange) {
labelSpan.style.color = "gray";
}
labelSpan.innerHTML = layer.name;
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline";
OpenLayers.Event.observe(labelSpan, "click",
this.onInputClick.bindAsEventListener(inputElem));
// create line break
var br = document.createElement("br");
var groupArray = (baseLayer) ? this.baseLayerInputs
: this.dataLayerInputs;
groupArray.push(inputElem);
var groupDiv = (baseLayer) ? this.baseLayersDiv
: this.dataLayersDiv;
groupDiv.appendChild(inputElem);
groupDiv.appendChild(labelSpan);
groupDiv.appendChild(br);
} }
// only check a baselayer if it is *the* baselayer, check data
// layers if they are visible
var checked = (baseLayer) ? (layer == this.map.baseLayer)
: layer.getVisibility();
// create input element
var inputElem = document.createElement("input");
inputElem.id = "input_" + layer.name;
inputElem.name = (baseLayer) ? "baseLayers" : layer.name;
inputElem.type = (baseLayer) ? "radio" : "checkbox";
inputElem.value = layer.name;
inputElem.checked = checked;
inputElem.defaultChecked = checked;
inputElem.layer = layer;
inputElem.control = this;
Event.observe(inputElem, "mouseup",
this.onInputClick.bindAsEventListener(inputElem));
// create span
var labelSpan = document.createElement("span");
labelSpan.innerHTML = layer.name;
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline";
Event.observe(labelSpan, "click",
this.onInputClick.bindAsEventListener(inputElem));
// create line break
var br = document.createElement("br");
var groupArray = (baseLayer) ? this.baseLayerInputs
: this.dataLayerInputs;
groupArray.push(inputElem);
var groupDiv = (baseLayer) ? this.baseLayersDiv
: this.dataLayersDiv;
groupDiv.appendChild(inputElem);
groupDiv.appendChild(labelSpan);
groupDiv.appendChild(br);
} }
// if no overlays, dont display the overlay label // if no overlays, dont display the overlay label
@@ -162,15 +176,17 @@ OpenLayers.Control.LayerSwitcher.prototype =
*/ */
onInputClick: function(e) { onInputClick: function(e) {
if (this.type == "radio") { if (!this.disabled) {
this.checked = true; if (this.type == "radio") {
this.layer.map.setBaseLayer(this.layer, true); this.checked = true;
this.layer.map.events.triggerEvent("changebaselayer"); this.layer.map.setBaseLayer(this.layer, true);
} else { this.layer.map.events.triggerEvent("changebaselayer");
this.checked = !this.checked; } else {
this.control.updateMap(); this.checked = !this.checked;
this.control.updateMap();
}
} }
Event.stop(e); OpenLayers.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
@@ -222,7 +238,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.showControls(false); this.showControls(false);
if (e != null) { if (e != null) {
Event.stop(e); OpenLayers.Event.stop(e);
} }
}, },
@@ -239,7 +255,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.showControls(true); this.showControls(true);
if (e != null) { if (e != null) {
Event.stop(e); OpenLayers.Event.stop(e);
} }
}, },
@@ -277,13 +293,13 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.div.style.color = "white"; this.div.style.color = "white";
this.div.style.backgroundColor = "transparent"; this.div.style.backgroundColor = "transparent";
Event.observe(this.div, "mouseup", OpenLayers.Event.observe(this.div, "mouseup",
this.mouseUp.bindAsEventListener(this)); this.mouseUp.bindAsEventListener(this));
Event.observe(this.div, "click", OpenLayers.Event.observe(this.div, "click",
this.ignoreEvent); this.ignoreEvent);
Event.observe(this.div, "mousedown", OpenLayers.Event.observe(this.div, "mousedown",
this.mouseDown.bindAsEventListener(this)); this.mouseDown.bindAsEventListener(this));
Event.observe(this.div, "dblclick", this.ignoreEvent); OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);
// layers list div // layers list div
@@ -307,14 +323,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
baseLbl.style.marginTop = "3px"; baseLbl.style.marginTop = "3px";
baseLbl.style.marginLeft = "3px"; baseLbl.style.marginLeft = "3px";
baseLbl.style.marginBottom = "3px"; baseLbl.style.marginBottom = "3px";
this.layersDiv.appendChild(baseLbl);
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", /*OpenLayers.Event.observe(this.baseLayersDiv, "click",
this.onLayerClick.bindAsEventListener(this)); this.onLayerClick.bindAsEventListener(this));
*/ */
this.layersDiv.appendChild(this.baseLayersDiv);
this.dataLbl = document.createElement("div"); this.dataLbl = document.createElement("div");
@@ -322,23 +336,30 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.dataLbl.style.marginTop = "3px"; this.dataLbl.style.marginTop = "3px";
this.dataLbl.style.marginLeft = "3px"; this.dataLbl.style.marginLeft = "3px";
this.dataLbl.style.marginBottom = "3px"; this.dataLbl.style.marginBottom = "3px";
this.layersDiv.appendChild(this.dataLbl);
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",
this.onLayerClick.bindAsEventListener(this));
*/
this.layersDiv.appendChild(this.dataLayersDiv);
if (this.ascending) {
this.layersDiv.appendChild(baseLbl);
this.layersDiv.appendChild(this.baseLayersDiv);
this.layersDiv.appendChild(this.dataLbl);
this.layersDiv.appendChild(this.dataLayersDiv);
} else {
this.layersDiv.appendChild(this.dataLbl);
this.layersDiv.appendChild(this.dataLayersDiv);
this.layersDiv.appendChild(baseLbl);
this.layersDiv.appendChild(this.baseLayersDiv);
}
this.div.appendChild(this.layersDiv); this.div.appendChild(this.layersDiv);
Rico.Corner.round(this.div, {corners: "tl bl", OpenLayers.Rico.Corner.round(this.div, {corners: "tl bl",
bgColor: "transparent", bgColor: "transparent",
color: this.activeColor, color: this.activeColor,
blend: false}); blend: false});
Rico.Corner.changeOpacity(this.layersDiv, 0.75); OpenLayers.Rico.Corner.changeOpacity(this.layersDiv, 0.75);
var imgLocation = OpenLayers.Util.getImagesLocation(); var imgLocation = OpenLayers.Util.getImagesLocation();
var sz = new OpenLayers.Size(18,18); var sz = new OpenLayers.Size(18,18);
@@ -355,7 +376,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.maximizeDiv.style.right = "0px"; this.maximizeDiv.style.right = "0px";
this.maximizeDiv.style.left = ""; this.maximizeDiv.style.left = "";
this.maximizeDiv.style.display = "none"; this.maximizeDiv.style.display = "none";
Event.observe(this.maximizeDiv, OpenLayers.Event.observe(this.maximizeDiv,
"click", "click",
this.maximizeControl.bindAsEventListener(this)); this.maximizeControl.bindAsEventListener(this));
@@ -374,7 +395,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.minimizeDiv.style.right = "0px"; this.minimizeDiv.style.right = "0px";
this.minimizeDiv.style.left = ""; this.minimizeDiv.style.left = "";
this.minimizeDiv.style.display = "none"; this.minimizeDiv.style.display = "none";
Event.observe(this.minimizeDiv, OpenLayers.Event.observe(this.minimizeDiv,
"click", "click",
this.minimizeControl.bindAsEventListener(this)); this.minimizeControl.bindAsEventListener(this));
@@ -387,7 +408,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
ignoreEvent: function(evt) { ignoreEvent: function(evt) {
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/** Register a local 'mouseDown' flag so that we'll know whether or not /** Register a local 'mouseDown' flag so that we'll know whether or not

View File

@@ -1,226 +0,0 @@
/* 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/Control.js
*/
OpenLayers.Control.LayerTabs = Class.create();
/** color used in the UI to show a layer is active/displayed
*
* @final
* @type String
*/
OpenLayers.Control.LayerTabs.ACTIVE_COLOR = "darkblue";
/** color used in the UI to show a layer is deactivated/hidden
*
* @final
* @type String
*/
OpenLayers.Control.LayerTabs.NONACTIVE_COLOR = "lightblue";
OpenLayers.Control.LayerTabs.prototype =
Object.extend( new OpenLayers.Control(), {
/** @type String */
activeColor: "",
/** @type String */
nonActiveColor: "",
/** @type String */
mode: "checkbox",
/**
* @constructor
*/
initialize: function(options) {
this.activeColor = OpenLayers.Control.LayerTabs.ACTIVE_COLOR;
this.nonActiveColor = OpenLayers.Control.LayerTabs.NONACTIVE_COLOR;
this.backdrops = [];
OpenLayers.Control.prototype.initialize.apply(this, arguments);
},
/**
* @returns A reference to the DIV DOMElement containing the switcher tabs
* @type DOMElement
*/
draw: function() {
// initialize our internal div
OpenLayers.Control.prototype.draw.apply(this);
this.div.style.position = "absolute";
this.div.style.top = "10px";
this.div.style.right = "0px";
this.div.style.left = "";
this.div.style.fontFamily = "sans-serif";
this.div.style.color = "white";
this.div.style.fontWeight = "bold";
this.div.style.marginTop = "3px";
this.div.style.marginLeft = "3px";
this.div.style.marginBottom = "3px";
this.div.style.fontSize="smaller";
this.div.style.width = "10em";
this.map.events.register("addlayer", this, this.redraw);
this.map.events.register("removelayer", this, this.redraw);
return this.redraw();
},
/**
* @returns A reference to the DIV DOMElement containing the switcher tabs
* @type DOMElement
*/
redraw: function() {
//clear out previous incarnation of LayerTabs tabs
this.div.innerHTML = "";
var visible = false;
for( var i = 0; i < this.map.layers.length; i++) {
if (visible && this.mode == "radio") {
this.map.layers[i].setVisibility(false);
} else {
visible = this.map.layers[i].getVisibility();
}
this.addTab(this.map.layers[i]);
}
return this.div;
},
/**
* @param {Event} evt
*/
singleClick: function(evt) {
var div = Event.element(evt);
// See comment about OL #57 fix below.
// If the click occurred on the corner spans we need
// to make sure we act on the actual label tab instead.
div = div.labelElement || div;
var layer = div.layer;
if (this.mode == "radio") {
for(var i=0; i < this.backdrops.length; i++) {
this.setTabActivation(this.backdrops[i], false);
this.backdrops[i].layer.setVisibility(false);
}
this.setTabActivation(div, true);
layer.setVisibility(true);
} else {
var visible = layer.getVisibility();
this.setTabActivation(div, !visible);
layer.setVisibility(!visible);
}
Event.stop(evt);
},
/**
* @private
*
* @param {Event} evt
*/
ignoreEvent: function(evt) {
Event.stop(evt);
return false;
},
/**
* @private
*
* @param {OpenLayers.Layer} layer
*/
addTab: function(layer) {
// Outer DIV - for Rico Corners
//
var backdropLabelOuter = document.createElement('div');
backdropLabelOuter.id = "LayerTabs_" + layer.name + "_Tab";
backdropLabelOuter.style.marginTop = "4px";
backdropLabelOuter.style.marginBottom = "4px";
this._setEventHandlers(backdropLabelOuter);
// Inner Label - for Rico Corners
//
var backdropLabel = document.createElement('p');
backdropLabel.innerHTML = layer.name;
backdropLabel.style.marginTop = "0px";
backdropLabel.style.marginBottom = "0px";
backdropLabel.style.paddingLeft = "10px";
backdropLabel.style.paddingRight = "10px";
// add reference to layer onto the div for use in event handlers
backdropLabel.layer = layer;
// set event handlers
this._setEventHandlers(backdropLabel);
// add label to div
backdropLabelOuter.appendChild(backdropLabel);
this.backdrops.push(backdropLabel);
// add div to main LayerTabs Div
this.div.appendChild(backdropLabelOuter);
Rico.Corner.round(backdropLabelOuter, {corners: "tl bl",
bgColor: "transparent",
color: "white",
blend: false});
// extend the event handlers to operate on the
// rounded corners as well. (Fixes OL #57.)
var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
this._setEventHandlers(spanElements[currIdx], backdropLabel);
}
this.setTabActivation(backdropLabel, layer.getVisibility());
},
/*
@private
@param {DOMElement} div
@param {Boolean} activate
*/
_setEventHandlers : function(element, labelDiv) {
// We only want to respond to a mousedown event.
element.onclick = this.singleClick.bindAsEventListener(this);
element.ondblclick = this.singleClick.bindAsEventListener(this);
element.onmouseup = this.ignoreEvent.bindAsEventListener(this);
element.onmousedown = this.ignoreEvent.bindAsEventListener(this);
// If we are operating on a corner span we need to store a
// reference to the actual tab. (See comment about OL #57 fix above.)
if (labelDiv) {
element.labelElement = labelDiv;
}
},
/**
* @private
*
* @param {DOMElement} div
* @param {Boolean} activate
*/
setTabActivation:function(div, activate) {
var color = (activate) ? this.activeColor : this.nonActiveColor;
Rico.Corner.changeColor(div, color);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.LayerTabs"
});

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.MouseDefaults = Class.create(); OpenLayers.Control.MouseDefaults = OpenLayers.Class.create();
OpenLayers.Control.MouseDefaults.prototype = OpenLayers.Control.MouseDefaults.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type Boolean */ /** @type Boolean */
performedDrag: false, performedDrag: false,
@@ -19,14 +20,6 @@ OpenLayers.Control.MouseDefaults.prototype =
*/ */
initialize: function() { initialize: function() {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
//register mousewheel events specifically on the window and document
Event.observe(window, "DOMMouseScroll",
this.onWheelEvent.bindAsEventListener(this));
Event.observe(window, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
Event.observe(document, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
}, },
/** /**
@@ -39,6 +32,24 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.events.register( "mouseup", this, this.defaultMouseUp ); this.map.events.register( "mouseup", this, this.defaultMouseUp );
this.map.events.register( "mousemove", this, this.defaultMouseMove ); this.map.events.register( "mousemove", this, this.defaultMouseMove );
this.map.events.register( "mouseout", this, this.defaultMouseOut ); this.map.events.register( "mouseout", this, this.defaultMouseOut );
this.registerWheelEvents();
},
/**
*
*/
registerWheelEvents: function() {
//register mousewheel events specifically on the window and document
OpenLayers.Event.observe(window, "DOMMouseScroll",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(window, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(document, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
}, },
/** /**
@@ -47,7 +58,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @type Boolean * @type Boolean
*/ */
defaultClick: function (evt) { defaultClick: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
var notAfterDrag = !this.performedDrag; var notAfterDrag = !this.performedDrag;
this.performedDrag = false; this.performedDrag = false;
return notAfterDrag; return notAfterDrag;
@@ -59,7 +70,7 @@ OpenLayers.Control.MouseDefaults.prototype =
defaultDblClick: function (evt) { defaultDblClick: function (evt) {
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); OpenLayers.Event.stop(evt);
return false; return false;
}, },
@@ -67,7 +78,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseDown: function (evt) { defaultMouseDown: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
this.performedDrag = false; this.performedDrag = false;
if (evt.shiftKey) { if (evt.shiftKey) {
@@ -86,13 +97,16 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
} }
document.onselectstart=function() { return false; } document.onselectstart=function() { return false; }
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/** /**
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseMove: function (evt) { defaultMouseMove: function (evt) {
// record the mouse position, used in onWheelEvent
this.mousePosition = evt.xy.clone();
if (this.mouseDragStart != null) { if (this.mouseDragStart != null) {
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);
@@ -124,7 +138,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
if (this.zoomBox) { if (this.zoomBox) {
this.zoomBoxEnd(evt); this.zoomBoxEnd(evt);
} else { } else {
@@ -141,9 +155,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;
} }
}, },
@@ -151,15 +168,21 @@ OpenLayers.Control.MouseDefaults.prototype =
/** User spun scroll wheel up /** User spun scroll wheel up
* *
*/ */
defaultWheelUp: function() { defaultWheelUp: function(evt) {
this.map.zoomIn(); if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() + 1);
}
}, },
/** User spun scroll wheel down /** User spun scroll wheel down
* *
*/ */
defaultWheelDown: function() { defaultWheelDown: function(evt) {
this.map.zoomOut(); if (this.map.getZoom() > 0) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() - 1);
}
}, },
/** Zoombox function. /** Zoombox function.
@@ -176,11 +199,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var left = Math.min(start.lon, end.lon); var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon); var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top); var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds); this.map.zoomToExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
} else { } else {
var end = this.map.getLonLatFromViewPortPx( evt.xy ); var end = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(new OpenLayers.LonLat( this.map.setCenter(new OpenLayers.LonLat(
@@ -188,9 +207,16 @@ OpenLayers.Control.MouseDefaults.prototype =
(end.lat) (end.lat)
), this.map.getZoom() + 1); ), this.map.getZoom() + 1);
} }
this.map.viewPortDiv.removeChild(this.zoomBox); this.removeZoomBox();
this.zoomBox = null; }
} },
/**
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null;
}, },
@@ -207,7 +233,7 @@ OpenLayers.Control.MouseDefaults.prototype =
// first determine whether or not the wheeling was inside the map // first determine whether or not the wheeling was inside the map
var inMap = false; var inMap = false;
var elem = Event.element(e); var elem = OpenLayers.Event.element(e);
while(elem != null) { while(elem != null) {
if (this.map && elem == this.map.div) { if (this.map && elem == this.map.div) {
inMap = true; inMap = true;
@@ -231,15 +257,20 @@ OpenLayers.Control.MouseDefaults.prototype =
delta = -e.detail / 3; delta = -e.detail / 3;
} }
if (delta) { if (delta) {
// add the mouse position to the event because mozilla has a bug
// with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
// getLonLatFromViewPortPx(e) returns wrong values
e.xy = this.mousePosition;
if (delta < 0) { if (delta < 0) {
this.defaultWheelDown(); this.defaultWheelDown(e);
} else { } else {
this.defaultWheelUp(); this.defaultWheelUp(e);
} }
} }
//only wheel the map, not the window //only wheel the map, not the window
Event.stop(e); OpenLayers.Event.stop(e);
} }
}, },

View File

@@ -0,0 +1,107 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.MousePosition = OpenLayers.Class.create();
OpenLayers.Control.MousePosition.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type DOMElement */
element: null,
/** @type String */
prefix: '',
/** @type String */
separator: ', ',
/** @type String */
suffix: '',
/** @type int */
numdigits: 5,
/** @type int */
granularity: 10,
/** @type OpenLayers.LonLat */
lastXy: null,
/**
* @constructor
*
* @param {DOMElement} options Options for control.
*/
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
},
/**
* @type DOMElement
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
if (!this.element) {
this.div.left = "";
this.div.top = "";
this.div.className = "olControlMousePosition";
this.element = this.div;
}
this.redraw();
return this.div;
},
/**
*
*/
redraw: function(evt) {
var lonLat;
if (evt == null) {
lonLat = new OpenLayers.LonLat(0, 0);
} else {
if (this.lastXy == null ||
Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||
Math.abs(evt.xy.y - this.lastXy.y) > this.granularity)
{
this.lastXy = evt.xy;
return;
}
lonLat = this.map.getLonLatFromPixel(evt.xy);
this.lastXy = evt.xy;
}
var digits = parseInt(this.numdigits);
var newHtml =
this.prefix +
lonLat.lon.toFixed(digits) +
this.separator +
lonLat.lat.toFixed(digits) +
this.suffix;
if (newHtml != this.element.innerHTML) {
this.element.innerHTML = newHtml;
}
},
/**
*
*/
setMap: function() {
OpenLayers.Control.prototype.setMap.apply(this, arguments);
this.map.events.register( 'mousemove', this, this.redraw);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.MousePosition"
});

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,12 +9,11 @@
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
* @requires OpenLayers/Control/MouseDefaults.js * @requires OpenLayers/Control/MouseDefaults.js
*/ */
OpenLayers.Control.MouseToolbar = Class.create(); OpenLayers.Control.MouseToolbar = OpenLayers.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(), OpenLayers.Class.inherit( OpenLayers.Control.MouseDefaults, {
Object.extend( new OpenLayers.Control.MouseDefaults(), {
mode: null, mode: null,
@@ -21,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,
@@ -45,8 +48,10 @@ OpenLayers.Control.MouseToolbar.prototype =
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.switchModeTo("pan"); this.switchModeTo("pan");
this.registerWheelEvents();
return this.div; return this.div;
}, },
_addButton:function(id, img, activeImg, xy, sz, title) { _addButton:function(id, img, activeImg, xy, sz, title) {
@@ -62,10 +67,10 @@ OpenLayers.Control.MouseToolbar.prototype =
btn.imgLocation = imgLocation; btn.imgLocation = imgLocation;
btn.activeImgLocation = activeImgLocation; btn.activeImgLocation = activeImgLocation;
btn.events = new OpenLayers.Events(this, btn); btn.events = new OpenLayers.Events(this, btn, null, true);
btn.events.register("mousedown", this, this.buttonClick); btn.events.register("mousedown", this, this.buttonDown);
btn.events.register("mouseup", this, Event.stop); btn.events.register("mouseup", this, this.buttonUp);
btn.events.register("click", this, Event.stop); btn.events.register("dblclick", this, OpenLayers.Event.stop);
btn.action = id; btn.action = id;
btn.title = title; btn.title = title;
btn.alt = title; btn.alt = title;
@@ -76,10 +81,27 @@ OpenLayers.Control.MouseToolbar.prototype =
return btn; return btn;
}, },
buttonClick: function(evt) { /**
if (!Event.isLeftClick(evt)) return; * @param {Event} evt
this.switchModeTo(evt.element.action); */
Event.stop(evt); buttonDown: function(evt) {
if (!OpenLayers.Event.isLeftClick(evt)) return;
this.buttonClicked = evt.element.action;
OpenLayers.Event.stop(evt);
},
/**
* @param {Event} evt
*/
buttonUp: function(evt) {
if (!OpenLayers.Event.isLeftClick(evt)) return;
if (this.buttonClicked != null) {
if (this.buttonClicked == evt.element.action) {
this.switchModeTo(evt.element.action);
}
OpenLayers.Event.stop(evt);
this.buttonClicked = null;
}
}, },
/** /**
@@ -89,8 +111,8 @@ 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); OpenLayers.Event.stop(evt);
return false; return false;
}, },
@@ -98,7 +120,7 @@ OpenLayers.Control.MouseToolbar.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseDown: function (evt) { defaultMouseDown: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
this.performedDrag = false; this.performedDrag = false;
this.startViaKeyboard = false; this.startViaKeyboard = false;
@@ -174,11 +196,13 @@ OpenLayers.Control.MouseToolbar.prototype =
break; break;
} }
document.onselectstart = function() { return false; } document.onselectstart = function() { return false; }
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
switchModeTo: function(mode) { switchModeTo: function(mode) {
if (mode != this.mode) { if (mode != this.mode) {
if (this.mode && this.buttons[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);
} }
@@ -195,6 +219,15 @@ OpenLayers.Control.MouseToolbar.prototype =
if (this.buttons[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;
}
} }
}, },
@@ -238,7 +271,7 @@ OpenLayers.Control.MouseToolbar.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
switch (this.mode) { switch (this.mode) {
case "zoombox": case "zoombox":
this.zoomBoxEnd(evt); this.zoomBoxEnd(evt);
@@ -254,17 +287,26 @@ OpenLayers.Control.MouseToolbar.prototype =
this.map.div.style.cursor = "default"; this.map.div.style.cursor = "default";
}, },
/**
* @param {Event} evt
*/
defaultMouseOut: function (evt) { defaultMouseOut: function (evt) {
if (this.mouseDragStart != null if (this.mouseDragStart != null
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) { && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt); if (this.zoomBox) {
this.removeZoomBox();
if (this.startViaKeyboard) this.leaveMode();
}
this.mouseDragStart = null;
this.map.div.style.cursor = "default";
} }
}, },
defaultClick: function (evt) { defaultClick: function (evt) {
if (this.performedDrag) { if (this.performedDrag) {
this.performedDrag = false; this.performedDrag = false;
return false; return false;
} }
} }
})); });

View File

@@ -0,0 +1,542 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @fileoverview Locator Map Control
* @author Tim Schaub
*/
// @require: OpenLayers/Control.js
/**
* @class
*/
OpenLayers.Control.OverviewMap = OpenLayers.Class.create();
OpenLayers.Control.OverviewMap.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** For div.id
* @type String */
id: "OverviewMap",
/** @type DOMElement */
element: null,
/**
* The overvew map itself.
* @type OpenLayers.Map
*/
ovmap: null,
/**
* The overvew map size in pixels. Note that this is the size of the map
* itself - the element that contains the map (class name
* olControlOverviewMapElement) may have padding or other style attributes
* added via CSS.
* @type OpenLayers.Size
*/
size: new OpenLayers.Size(180, 90),
/**
* Ordered list of layers in the overview map. If none are sent at
* construction, then the default below is used.
*
* @type Array(OpenLayers.Layer)
*/
layers: [],
/**
* The ratio of the overview map resolution to the main map resolution
* at which to zoom farther out on the overview map.
* @type Float
*/
minRatio: 8,
/**
* The ratio of the overview map resolution to the main map resolution
* at which to zoom farther in on the overview map.
* @type Float
*/
maxRatio: 32,
/**
* An object containing any non-default properties to be sent to the
* overview map's map constructor. These should include any non-default
* options that the main map was constructed with.
* @type: Object
*/
mapOptions: {},
/**
* @constructor
* @param {Object} options Hashtable of options to set on the overview map
*/
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
},
/**
* @type DOMElement
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
if(!(this.layers.length > 0)) {
if (this.map.baseLayer) {
var layer = this.map.baseLayer.clone();
this.layers = [layer];
} else {
this.map.events.register("changebaselayer", this, this.baseLayerDraw);
return this.div;
}
}
// create overview map DOM elements
this.element = document.createElement('div');
this.element.className = 'olControlOverviewMapElement';
this.element.style.display = 'none';
this.mapDiv = document.createElement('div');
this.mapDiv.style.width = this.size.w + 'px';
this.mapDiv.style.height = this.size.h + 'px';
this.mapDiv.style.position = 'relative';
this.mapDiv.style.overflow = 'hidden';
this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');
this.extentRectangle = document.createElement('div');
this.extentRectangle.style.position = 'absolute';
this.extentRectangle.style.zIndex = 1000; //HACK
this.extentRectangle.style.backgroundImage = 'url(' +
OpenLayers.Util.getImagesLocation() +
'/blank.png)';
this.extentRectangle.className = 'olControlOverviewMapExtentRectangle';
this.mapDiv.appendChild(this.extentRectangle);
this.element.appendChild(this.mapDiv);
this.div.appendChild(this.element);
this.map.events.register('moveend', this, this.update);
// Set up events. The image div recenters the map on click.
// The extent rectangle can be dragged to recenter the map.
// If the mousedown happened elsewhere, then mousemove and mouseup
// should slip through.
this.elementEvents = new OpenLayers.Events(this, this.element);
this.elementEvents.register('mousedown', this, function(e) {
OpenLayers.Event.stop(e);
});
this.elementEvents.register('click', this, function(e) {
OpenLayers.Event.stop(e);
});
this.elementEvents.register('dblclick', this, function(e) {
OpenLayers.Event.stop(e);
});
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle);
this.rectEvents.register('mouseout', this, this.rectMouseOut);
this.rectEvents.register('mousedown', this, this.rectMouseDown);
this.rectEvents.register('mousemove', this, this.rectMouseMove);
this.rectEvents.register('mouseup', this, this.rectMouseUp);
this.rectEvents.register('click', this, function(e) {
OpenLayers.Event.stop(e);
});
this.rectEvents.register('dblclick', this, this.rectDblClick );
this.mapDivEvents = new OpenLayers.Events(this, this.mapDiv);
this.mapDivEvents.register('click', this, this.mapDivClick);
// Optionally add min/max buttons if the control will go in the
// map viewport.
if(!this.outsideViewport) {
this.div.className = 'olControlOverviewMapContainer';
var imgLocation = OpenLayers.Util.getImagesLocation();
// maximize button div
var img = imgLocation + 'layer-switcher-maximize.png';
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
'olControlOverviewMapMaximizeButton',
null,
new OpenLayers.Size(18,18),
img,
'absolute');
this.maximizeDiv.style.display = 'none';
this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton';
OpenLayers.Event.observe(this.maximizeDiv,
'click',
this.maximizeControl.bindAsEventListener(this));
this.div.appendChild(this.maximizeDiv);
// minimize button div
var img = imgLocation + 'layer-switcher-minimize.png';
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
'OpenLayers_Control_minimizeDiv',
null,
new OpenLayers.Size(18,18),
img,
'absolute');
this.minimizeDiv.style.display = 'none';
this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton';
OpenLayers.Event.observe(this.minimizeDiv,
'click',
this.minimizeControl.bindAsEventListener(this));
this.div.appendChild(this.minimizeDiv);
this.minimizeControl();
} else {
// show the overview map
this.element.style.display = '';
}
if(this.map.getExtent()) {
this.update();
}
return this.div;
},
baseLayerDraw: function() {
this.draw();
this.map.events.unregister("changebaselayer", this, this.baseLayerDraw);
},
/**
* @param {OpenLayers.Event} evt
*/
rectMouseOut: function (evt) {
if(this.rectDragStart != null) {
if(this.performedRectDrag) {
this.rectMouseMove(evt);
var rectPxBounds = this.getRectPxBounds();
// if we're off of the overview map, update the main map
// otherwise, keep moving the rect
if((rectPxBounds.top <= 0) || (rectPxBounds.left <= 0) ||
(rectPxBounds.bottom >= this.size.h - this.hComp) ||
(rectPxBounds.right >= this.size.w - this.wComp)) {
this.updateMapToRect();
} else {
return;
}
}
document.onselectstart = null;
this.rectDragStart = null;
}
},
/**
* @param {OpenLayers.Event} evt
*/
rectMouseDown: function (evt) {
if(!OpenLayers.Event.isLeftClick(evt)) return;
this.rectDragStart = evt.xy.clone();
this.performedRectDrag = false;
OpenLayers.Event.stop(evt);
},
/**
* @param {OpenLayers.Event} evt
*/
rectMouseMove: function(evt) {
if(this.rectDragStart != null) {
var deltaX = this.rectDragStart.x - evt.xy.x;
var deltaY = this.rectDragStart.y - evt.xy.y;
var rectPxBounds = this.getRectPxBounds();
var rectTop = rectPxBounds.top;
var rectLeft = rectPxBounds.left;
var rectHeight = Math.abs(rectPxBounds.getHeight());
var rectWidth = rectPxBounds.getWidth();
// don't allow dragging off of parent element
var newTop = Math.max(0, (rectTop - deltaY));
newTop = Math.min(newTop,
this.ovmap.size.h - this.hComp - rectHeight);
var newLeft = Math.max(0, (rectLeft - deltaX));
newLeft = Math.min(newLeft,
this.ovmap.size.w - this.wComp - rectWidth);
this.setRectPxBounds(new OpenLayers.Bounds(newLeft,
newTop + rectHeight,
newLeft + rectWidth,
newTop));
this.rectDragStart = evt.xy.clone();
this.performedRectDrag = true;
OpenLayers.Event.stop(evt);
}
},
/**
* @param {OpenLayers.Event} evt
*/
rectMouseUp: function(evt) {
if(!OpenLayers.Event.isLeftClick(evt)) return;
if(this.performedRectDrag) {
this.updateMapToRect();
OpenLayers.Event.stop(evt);
}
document.onselectstart = null;
this.rectDragStart = null;
},
/**
* @param {OpenLayers.Event} evt
*/
rectDblClick: function(evt) {
this.performedRectDrag = false;
OpenLayers.Event.stop(evt);
this.updateOverview();
},
/**
* @param {OpenLayers.Event} evt
*/
mapDivClick: function(evt) {
var pxBounds = this.getRectPxBounds();
var pxCenter = pxBounds.getCenterPixel();
var deltaX = evt.xy.x - pxCenter.x;
var deltaY = evt.xy.y - pxCenter.y;
var top = pxBounds.top;
var left = pxBounds.left;
var height = Math.abs(pxBounds.getHeight());
var width = pxBounds.getWidth();
var newTop = Math.max(0, (top + deltaY));
newTop = Math.min(newTop, this.ovmap.size.h - height);
var newLeft = Math.max(0, (left + deltaX));
newLeft = Math.min(newLeft, this.ovmap.size.w - width);
this.setRectPxBounds(new OpenLayers.Bounds(newLeft,
newTop + height,
newLeft + width,
newTop));
this.updateMapToRect();
OpenLayers.Event.stop(evt);
},
/** Set up the labels and divs for the control
*
* @param {OpenLayers.Event} e
*/
maximizeControl: function(e) {
this.element.style.display = '';
this.showToggle(false);
if (e != null) {
OpenLayers.Event.stop(e);
}
},
/** Hide all the contents of the control, shrink the size,
* add the maximize icon
*
* @param {OpenLayers.Event} e
*/
minimizeControl: function(e) {
this.element.style.display = 'none';
this.showToggle(true);
if (e != null) {
OpenLayers.Event.stop(e);
}
},
/** Hide/Show all LayerSwitcher controls depending on whether we are
* minimized or not
*
* @private
*
* @param {Boolean} minimize
*/
showToggle: function(minimize) {
this.maximizeDiv.style.display = minimize ? '' : 'none';
this.minimizeDiv.style.display = minimize ? 'none' : '';
},
/**
* Update the overview map after layers move.
*/
update: function() {
if(this.ovmap == null) {
this.createMap();
}
if(!this.isSuitableOverview()) {
this.updateOverview();
}
// update extent rectangle
this.updateRectToMap();
},
/**
* Determines if the overview map is suitable given the extent and
* resolution of the main map.
*/
isSuitableOverview: function() {
var mapExtent = this.map.getExtent();
var maxExtent = this.map.maxExtent;
var testExtent = new OpenLayers.Bounds(
Math.max(mapExtent.left, maxExtent.left),
Math.max(mapExtent.bottom, maxExtent.bottom),
Math.min(mapExtent.right, maxExtent.right),
Math.min(mapExtent.top, maxExtent.top));
var resRatio = this.ovmap.getResolution() / this.map.getResolution();
return ((resRatio > this.minRatio) &&
(resRatio <= this.maxRatio) &&
(this.ovmap.getExtent().containsBounds(testExtent)));
},
updateOverview: function() {
var mapRes = this.map.getResolution();
var targetRes = this.ovmap.getResolution();
var resRatio = targetRes / mapRes;
if(resRatio > this.maxRatio) {
// zoom in overview map
targetRes = this.minRatio * mapRes;
} else if(resRatio <= this.minRatio) {
// zoom out overview map
targetRes = this.maxRatio * mapRes;
}
this.ovmap.setCenter(this.map.center,
this.ovmap.getZoomForResolution(targetRes));
this.updateRectToMap();
},
createMap: function() {
// create the overview map
var options = OpenLayers.Util.extend(
{controls: [], maxResolution: 'auto'}, this.mapOptions);
this.ovmap = new OpenLayers.Map(this.mapDiv.id, options);
this.ovmap.addLayers(this.layers);
this.ovmap.zoomToMaxExtent();
// check extent rectangle border width
this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
'border-left-width')) +
parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
'border-right-width'));
this.wComp = (this.wComp) ? this.wComp : 2;
this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
'border-top-width')) +
parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
'border-bottom-width'));
this.hComp = (this.hComp) ? this.hComp : 2;
},
/**
* Updates the extent rectangle position and size to match the map extent
*/
updateRectToMap: function() {
// The base layer for overview map needs to be in the same projection
// as the base layer for the main map. This should be made more robust.
if(this.map.units != 'degrees') {
if(this.map.getProjection() != this.ovmap.getProjection()) {
alert('The overview map only works when it is in the same projection as the main map');
}
}
var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent());
this.setRectPxBounds(pxBounds);
},
/**
* Updates the map extent to match the extent rectangle position and size
*/
updateMapToRect: function() {
var pxBounds = this.getRectPxBounds();
var lonLatBounds = this.getMapBoundsFromRectBounds(pxBounds);
this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);
},
/**
* Get extent rectangle pixel bounds
* @returns An OpenLayers.Bounds wich is the extent rectangle's pixel
* bounds (relative to the parent element)
*/
getRectPxBounds: function() {
var top = parseInt(this.extentRectangle.style.top);
var left = parseInt(this.extentRectangle.style.left);
var height = parseInt(this.extentRectangle.style.height);
var width = parseInt(this.extentRectangle.style.width);
return new OpenLayers.Bounds(left, top + height, left + width, top);
},
/**
* Set extent rectangle pixel bounds.
* @param {OpenLayers.Bounds} pxBounds
*/
setRectPxBounds: function(pxBounds) {
var top = Math.max(pxBounds.top, 0);
var left = Math.max(pxBounds.left, 0);
var bottom = Math.min(pxBounds.top + Math.abs(pxBounds.getHeight()),
this.ovmap.size.h - this.hComp);
var right = Math.min(pxBounds.left + pxBounds.getWidth(),
this.ovmap.size.w - this.wComp);
this.extentRectangle.style.top = parseInt(top) + 'px';
this.extentRectangle.style.left = parseInt(left) + 'px';
this.extentRectangle.style.height = parseInt(bottom - top)+ 'px';
this.extentRectangle.style.width = parseInt(right - left) + 'px';
},
/**
* @param {OpenLayers.Bounds} lonLatBounds
*
* @returns An OpenLayers.Bounds which is the passed-in map lon/lat extent
* translated into pixel bounds for the overview map
* @type OpenLayers.Bounds
*/
getRectBoundsFromMapBounds: function(lonLatBounds) {
var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left,
lonLatBounds.bottom);
var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right,
lonLatBounds.top);
var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat);
var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat);
return new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
rightTopPx.x, rightTopPx.y);
},
/**
* @param {OpenLayers.Bounds} pxBounds
*
* @returns An OpenLayers.Bounds which is the passed-in overview rect bounds
* translated into lon/lat bounds for the overview map
* @type OpenLayers.Bounds
*/
getMapBoundsFromRectBounds: function(pxBounds) {
var leftBottomPx = new OpenLayers.Pixel(pxBounds.left,
pxBounds.bottom);
var rightTopPx = new OpenLayers.Pixel(pxBounds.right,
pxBounds.top);
var leftBottomLonLat = this.getLonLatFromOverviewPx(leftBottomPx);
var rightTopLonLat = this.getLonLatFromOverviewPx(rightTopPx);
return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,
rightTopLonLat.lon, rightTopLonLat.lat);
},
/**
* @param {OpenLayers.Pixel} overviewMapPx
*
* @returns An OpenLayers.LonLat which is the passed-in overview map
* OpenLayers.Pixel, translated into lon/lat by the overview map
* @type OpenLayers.LonLat
*/
getLonLatFromOverviewPx: function(overviewMapPx) {
var size = this.ovmap.size;
var res = this.ovmap.getResolution();
var center = this.ovmap.getExtent().getCenterLonLat();
var delta_x = overviewMapPx.x - (size.w / 2);
var delta_y = overviewMapPx.y - (size.h / 2);
return new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into overview map pixels
* @type OpenLayers.Pixel
*/
getOverviewPxFromLonLat: function(lonlat) {
var res = this.ovmap.getResolution();
var extent = this.ovmap.getExtent();
return new OpenLayers.Pixel(
Math.round(1/res * (lonlat.lon - extent.left)),
Math.round(1/res * (extent.top - lonlat.lat))
);
},
/** @final @type String */
CLASS_NAME: 'OpenLayers.Control.OverviewMap'
});

View File

@@ -1,17 +1,18 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.PanZoom = Class.create(); OpenLayers.Control.PanZoom = OpenLayers.Class.create();
OpenLayers.Control.PanZoom.X = 4; OpenLayers.Control.PanZoom.X = 4;
OpenLayers.Control.PanZoom.Y = 4; OpenLayers.Control.PanZoom.Y = 4;
OpenLayers.Control.PanZoom.prototype = OpenLayers.Control.PanZoom.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type int */ /** @type int */
slideFactor: 50, slideFactor: 50,
@@ -101,7 +102,7 @@ OpenLayers.Control.PanZoom.prototype =
* @type Boolean * @type Boolean
*/ */
doubleClick: function (evt) { doubleClick: function (evt) {
Event.stop(evt); OpenLayers.Event.stop(evt);
return false; return false;
}, },
@@ -109,7 +110,7 @@ OpenLayers.Control.PanZoom.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
buttonDown: function (evt) { buttonDown: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
switch (this.action) { switch (this.action) {
case "panup": case "panup":
@@ -135,7 +136,7 @@ OpenLayers.Control.PanZoom.prototype =
break; break;
} }
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/** /**

View File

@@ -1,17 +1,18 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control/PanZoom.js * @requires OpenLayers/Control/PanZoom.js
*/ */
OpenLayers.Control.PanZoomBar = Class.create(); OpenLayers.Control.PanZoomBar = OpenLayers.Class.create();
OpenLayers.Control.PanZoomBar.X = 4; 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(), { OpenLayers.Class.inherit( OpenLayers.Control.PanZoom, {
/** @type Array(...) */ /** @type Array(...) */
buttons: null, buttons: null,
@@ -86,7 +87,7 @@ OpenLayers.Control.PanZoomBar.prototype =
"absolute"); "absolute");
this.slider = slider; this.slider = slider;
this.sliderEvents = new OpenLayers.Events(this, slider); this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
this.sliderEvents.register("mousedown", this, this.zoomBarDown); this.sliderEvents.register("mousedown", this, this.zoomBarDown);
this.sliderEvents.register("mousemove", this, this.zoomBarDrag); this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
this.sliderEvents.register("mouseup", this, this.zoomBarUp); this.sliderEvents.register("mouseup", this, this.zoomBarUp);
@@ -116,7 +117,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);
@@ -147,12 +148,12 @@ OpenLayers.Control.PanZoomBar.prototype =
* and sets the zoom level appropriately. * and sets the zoom level appropriately.
*/ */
divClick: function (evt) { divClick: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
var y = evt.xy.y; var y = evt.xy.y;
var top = Position.page(evt.object)[1]; var top = OpenLayers.Util.pagePosition(evt.object)[1];
var levels = Math.floor((y - top)/this.zoomStopHeight); var levels = Math.floor((y - top)/this.zoomStopHeight);
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels); this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/* /*
@@ -160,13 +161,13 @@ OpenLayers.Control.PanZoomBar.prototype =
* event listener for clicks on the slider * event listener for clicks on the slider
*/ */
zoomBarDown:function(evt) { zoomBarDown:function(evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
this.map.events.register("mousemove", this, this.passEventToSlider); this.map.events.register("mousemove", this, this.passEventToSlider);
this.map.events.register("mouseup", this, this.passEventToSlider); this.map.events.register("mouseup", this, this.passEventToSlider);
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
this.zoomStart = evt.xy.clone(); this.zoomStart = evt.xy.clone();
this.div.style.cursor = "move"; this.div.style.cursor = "move";
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/* /*
@@ -178,14 +179,14 @@ OpenLayers.Control.PanZoomBar.prototype =
zoomBarDrag:function(evt) { zoomBarDrag:function(evt) {
if (this.mouseDragStart != null) { if (this.mouseDragStart != null) {
var deltaY = this.mouseDragStart.y - evt.xy.y var deltaY = this.mouseDragStart.y - evt.xy.y
var offsets = Position.page(this.zoombarDiv); var offsets = OpenLayers.Util.pagePosition(this.zoombarDiv);
if ((evt.clientY - offsets[1]) > 0 && if ((evt.clientY - offsets[1]) > 0 &&
(evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) { (evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {
var newTop = parseInt(this.slider.style.top) - deltaY; var newTop = parseInt(this.slider.style.top) - deltaY;
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); OpenLayers.Event.stop(evt);
} }
}, },
@@ -195,7 +196,7 @@ OpenLayers.Control.PanZoomBar.prototype =
* and switch to it. * and switch to it.
*/ */
zoomBarUp:function(evt) { zoomBarUp:function(evt) {
if (!Event.isLeftClick(evt)) return; if (!OpenLayers.Event.isLeftClick(evt)) return;
if (this.zoomStart) { if (this.zoomStart) {
this.div.style.cursor="default"; this.div.style.cursor="default";
this.map.events.unregister("mouseup", this, this.passEventToSlider); this.map.events.unregister("mouseup", this, this.passEventToSlider);
@@ -204,7 +205,7 @@ OpenLayers.Control.PanZoomBar.prototype =
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();
this.mouseDragStart = null; this.mouseDragStart = null;
Event.stop(evt); OpenLayers.Event.stop(evt);
} }
}, },

View File

@@ -1,22 +1,23 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.Permalink = Class.create(); OpenLayers.Control.Permalink = OpenLayers.Class.create();
OpenLayers.Control.Permalink.prototype = OpenLayers.Control.Permalink.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type DOMElement */ /** @type DOMElement */
element: null, element: null,
/** @type String */ /** @type String */
base: '', base: '',
/** /**
* @constructor * @constructor
* *
@@ -26,7 +27,29 @@ OpenLayers.Control.Permalink.prototype =
initialize: function(element, base) { initialize: function(element, base) {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.element = element; this.element = element;
if (base) this.base = base; if (base) {
this.base = base;
}
},
/** Set the map property for the control.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Control.prototype.setMap.apply(this, arguments);
//make sure we have an arg parser attached
for(var i=0; i< this.map.controls.length; i++) {
var control = this.map.controls[i];
if (control.CLASS_NAME == "OpenLayers.Control.ArgParser") {
break;
}
}
if (i == this.map.controls.length) {
this.map.addControl(new OpenLayers.Control.ArgParser());
}
}, },
/** /**
@@ -34,29 +57,16 @@ OpenLayers.Control.Permalink.prototype =
*/ */
draw: function() { draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments); OpenLayers.Control.prototype.draw.apply(this, arguments);
var args = OpenLayers.Util.getArgs();
if (args.lat && args.lon) {
this.map.setCenter(
new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat))
);
}
if (args.zoom) {
this.map.zoomTo(parseInt(args.zoom));
}
if (!this.element) { if (!this.element) {
this.div.className = 'olControlPermalink';
this.element = document.createElement("a"); this.element = document.createElement("a");
this.div.style.right = "3px";
this.div.style.bottom = "3px";
this.div.style.left = "";
this.div.style.top = "";
this.div.style.display = "block";
this.div.style.position = "absolute";
this.element.style.fontSize="smaller"; this.element.style.fontSize="smaller";
this.element.innerHTML = "Permalink"; this.element.innerHTML = "Permalink";
this.element.href=""; this.element.href="";
this.div.appendChild(this.element); this.div.appendChild(this.element);
} }
this.map.events.register( 'moveend', this, this.updateLink); this.map.events.register('moveend', this, this.updateLink);
return this.div; return this.div;
}, },
@@ -65,13 +75,25 @@ OpenLayers.Control.Permalink.prototype =
*/ */
updateLink: function() { updateLink: function() {
var center = this.map.getCenter(); var center = this.map.getCenter();
var zoom = this.map.getZoom(); var zoom = "zoom=" + this.map.getZoom();
var lat = Math.round(center.lat*100000)/100000; var lat = "lat=" + Math.round(center.lat*100000)/100000;
var lon = Math.round(center.lon*100000)/100000; var lon = "lon=" + Math.round(center.lon*100000)/100000;
this.element.href = this.base+"?lat="+lat+"&lon="+lon+"&zoom="+zoom;
var layers = "layers=";
for(var i=0; i< this.map.layers.length; i++) {
var layer = this.map.layers[i];
if (layer.isBaseLayer) {
layers += (layer == this.map.baseLayer) ? "B" : "0";
} else {
layers += (layer.getVisibility()) ? "T" : "F";
}
}
var href = this.base + "?" + lat + "&" + lon + "&" + zoom +
"&" + layers;
this.element.href = href;
}, },
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Control.Permalink" CLASS_NAME: "OpenLayers.Control.Permalink"
}); });

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
*/ */
OpenLayers.Control.Scale = Class.create(); OpenLayers.Control.Scale = OpenLayers.Class.create();
OpenLayers.Control.Scale.prototype = OpenLayers.Control.Scale.prototype =
Object.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type DOMElement */ /** @type DOMElement */
element: null, element: null,
@@ -31,12 +32,7 @@ OpenLayers.Control.Scale.prototype =
OpenLayers.Control.prototype.draw.apply(this, arguments); OpenLayers.Control.prototype.draw.apply(this, arguments);
if (!this.element) { if (!this.element) {
this.element = document.createElement("div"); this.element = document.createElement("div");
this.div.style.right = "3px"; this.div.className = "olControlScale";
this.div.style.bottom = "2em";
this.div.style.left = "";
this.div.style.top = "";
this.div.style.display = "block";
this.div.style.position = "absolute";
this.element.style.fontSize="smaller"; this.element.style.fontSize="smaller";
this.div.appendChild(this.element); this.div.appendChild(this.element);
} }

View File

@@ -1,11 +1,123 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
OpenLayers.Event = {
KEY_BACKSPACE: 8,
KEY_TAB: 9,
KEY_RETURN: 13,
KEY_ESC: 27,
KEY_LEFT: 37,
KEY_UP: 38,
KEY_RIGHT: 39,
KEY_DOWN: 40,
KEY_DELETE: 46,
element: function(event) {
return event.target || event.srcElement;
},
isLeftClick: function(event) {
return (((event.which) && (event.which == 1)) ||
((event.button) && (event.button == 1)));
},
pointerX: function(event) {
return event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft));
},
pointerY: function(event) {
return event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop));
},
stop: function(event) {
if (event.preventDefault) {
event.preventDefault();
event.stopPropagation();
} else {
event.returnValue = false;
event.cancelBubble = true;
}
},
// find the first node with the given tagName, starting from the
// node the event was triggered on; traverses the DOM upwards
findElement: function(event, tagName) {
var element = OpenLayers.Event.element(event);
while (element.parentNode && (!element.tagName ||
(element.tagName.toUpperCase() != tagName.toUpperCase())))
element = element.parentNode;
return element;
},
observers: false,
_observeAndCache: function(element, name, observer, useCapture) {
if (!this.observers) this.observers = [];
if (element.addEventListener) {
this.observers.push([element, name, observer, useCapture]);
element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
this.observers.push([element, name, observer, useCapture]);
element.attachEvent('on' + name, observer);
}
},
unloadCache: function() {
if (!OpenLayers.Event.observers) return;
for (var i = 0; i < OpenLayers.Event.observers.length; i++) {
OpenLayers.Event.stopObserving.apply(this, OpenLayers.Event.observers[i]);
OpenLayers.Event.observers[i][0] = null;
}
OpenLayers.Event.observers = false;
},
observe: function(elementParam, name, observer, useCapture) {
var element = $(elementParam);
useCapture = useCapture || false;
if (name == 'keypress' &&
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|| element.attachEvent))
name = 'keydown';
this._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(elementParam, name, observer, useCapture) {
var element = $(elementParam);
useCapture = useCapture || false;
if (name == 'keypress' &&
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|| element.detachEvent))
name = 'keydown';
if (element && element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element && element.detachEvent) {
element.detachEvent('on' + name, observer);
}
}
};
/* prevent memory leaks in IE */
OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false);
if (window.Event) {
OpenLayers.Util.extend(window.Event, OpenLayers.Event);
} else {
var Event = OpenLayers.Event;
}
/** /**
* @class * @class
*/ */
OpenLayers.Events = Class.create(); OpenLayers.Events = OpenLayers.Class.create();
OpenLayers.Events.prototype = { OpenLayers.Events.prototype = {
/** @final @type Array: supported events */ /** @final @type Array: supported events */
@@ -29,7 +141,6 @@ OpenLayers.Events.prototype = {
/** @type Array: list of support application events */ /** @type Array: list of support application events */
eventTypes: null, eventTypes: null,
/** /**
* @constructor * @constructor
* *
@@ -37,11 +148,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
@@ -69,11 +183,11 @@ OpenLayers.Events.prototype = {
this.listeners[eventType] = new Array(); this.listeners[eventType] = new Array();
// use Prototype to register the event cross-browser // use Prototype to register the event cross-browser
Event.observe(element, eventType, OpenLayers.Event.observe(element, eventType,
this.handleBrowserEvent.bindAsEventListener(this)); this.handleBrowserEvent.bindAsEventListener(this));
} }
// disable dragstart in IE so that mousedown/move/up works normally // disable dragstart in IE so that mousedown/move/up works normally
Event.observe(element, "dragstart", Event.stop); OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop);
}, },
/** /**
@@ -158,7 +272,10 @@ OpenLayers.Events.prototype = {
evt.element = this.element; evt.element = this.element;
// execute all callbacks registered for specified type // execute all callbacks registered for specified type
var listeners = this.listeners[type]; // get a clone of the listeners array to
// allow for splicing during callbacks
var listeners = (this.listeners[type]) ?
this.listeners[type].slice() : null;
if ((listeners != null) && (listeners.length > 0)) { 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];
@@ -176,7 +293,9 @@ OpenLayers.Events.prototype = {
} }
} }
// don't fall through to other DOM elements // don't fall through to other DOM elements
Event.stop(evt); if (!this.fallThrough) {
OpenLayers.Util.safeStopPropagation(evt);
}
} }
}, },
@@ -203,12 +322,18 @@ OpenLayers.Events.prototype = {
*/ */
getMousePosition: function (evt) { getMousePosition: function (evt) {
if (!this.element.offsets) { if (!this.element.offsets) {
this.element.offsets = Position.page(this.element); this.element.offsets = OpenLayers.Util.pagePosition(this.element);
this.element.offsets[0] += (document.documentElement.scrollLeft
|| document.body.scrollLeft);
this.element.offsets[1] += (document.documentElement.scrollTop
|| document.body.scrollTop);
} }
return new OpenLayers.Pixel( return new OpenLayers.Pixel(
(evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) - this.element.offsets[0], (evt.clientX + (document.documentElement.scrollLeft
(evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) - this.element.offsets[1] || document.body.scrollLeft)) - this.element.offsets[0],
); (evt.clientY + (document.documentElement.scrollTop
|| document.body.scrollTop)) - this.element.offsets[1]
);
}, },
/** @final @type String */ /** @final @type String */

View File

@@ -1,13 +1,14 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Util.js * @requires OpenLayers/Util.js
*/ */
OpenLayers.Feature = Class.create(); OpenLayers.Feature = OpenLayers.Class.create();
OpenLayers.Feature.prototype= { OpenLayers.Feature.prototype= {
/** @type OpenLayers.Events */ /** @type OpenLayers.Events */
@@ -63,20 +64,38 @@ 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) {
this.popup.destroy(); this.destroyPopup(this.popup);
this.popup = null; this.popup = null;
} }
}, },
/**
* @returns Whether or not the feature is currently visible on screen
* (based on its 'lonlat' property)
* @type Boolean
*/
onScreen:function() {
var onScreen = false;
if ((this.layer != null) && (this.layer.map != null)) {
var screenBounds = this.layer.map.getExtent();
onScreen = screenBounds.containsLonLat(this.lonlat);
}
return onScreen;
},
/** /**
* @returns A Marker Object created from the 'lonlat' and 'icon' properties * @returns A Marker Object created from the 'lonlat' and 'icon' properties
* set in this.data. If no 'lonlat' is set, returns null. If no * set in this.data. If no 'lonlat' is set, returns null. If no
* 'icon' is set, OpenLayers.Marker() will load the default image * 'icon' is set, OpenLayers.Marker() will load the default image.
*
* Note: this.marker is set to return value
*
* @type OpenLayers.Marker * @type OpenLayers.Marker
*/ */
createMarker: function() { createMarker: function() {
@@ -89,8 +108,24 @@ OpenLayers.Feature.prototype= {
return this.marker; return this.marker;
}, },
/** If user overrides the createMarker() function, s/he should be able
* to also specify an alternative function for destroying it
*/
destroyMarker: function() {
this.marker.destroy();
},
/** /**
* @returns A Popup Object created from the 'lonlat', 'popupSize',
* and 'popupContentHTML' properties set in this.data. It uses
* this.marker.icon as default anchor.
*
* If no 'lonlat' is set, returns null.
* If no this.marker has been created, no anchor is sent.
* *
* Note: this.popup is set to return value
*
* @type OpenLayers.Popup.AnchoredBubble
*/ */
createPopup: function() { createPopup: function() {
@@ -108,5 +143,13 @@ OpenLayers.Feature.prototype= {
return this.popup; return this.popup;
}, },
/** As with the marker, if user overrides the createPopup() function, s/he
* should also be able to override the destruction
*/
destroyPopup: function() {
this.popup.destroy()
},
CLASS_NAME: "OpenLayers.Feature" CLASS_NAME: "OpenLayers.Feature"
}; };

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Feature.js * @requires OpenLayers/Feature.js
*/ */
OpenLayers.Feature.WFS = Class.create(); OpenLayers.Feature.WFS = OpenLayers.Class.create();
OpenLayers.Feature.WFS.prototype = OpenLayers.Feature.WFS.prototype =
Object.extend( new OpenLayers.Feature(), { OpenLayers.Class.inherit( OpenLayers.Feature, {
/** /**
* @constructor * @constructor
@@ -19,16 +20,11 @@ OpenLayers.Feature.WFS.prototype =
*/ */
initialize: function(layer, xmlNode) { initialize: function(layer, xmlNode) {
var newArguments = arguments; var newArguments = arguments;
if (arguments.length > 0) { var data = this.processXMLNode(xmlNode);
var data = this.processXMLNode(xmlNode); newArguments = new Array(layer, data.lonlat, data)
newArguments = new Array(layer, data.lonlat, data)
}
OpenLayers.Feature.prototype.initialize.apply(this, newArguments); OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
this.createMarker();
if (arguments.length > 0) { this.layer.addMarker(this.marker);
this.createMarker();
this.layer.addMarker(this.marker);
}
}, },
destroy: function() { destroy: function() {
@@ -47,8 +43,8 @@ OpenLayers.Feature.WFS.prototype =
processXMLNode: function(xmlNode) { processXMLNode: function(xmlNode) {
//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 = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/gml", "gml", "Point");
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]); var text = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(point[0], "http://www.opengis.net/gml","gml", "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])),

View File

@@ -1,11 +1,12 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
*/ */
OpenLayers.Icon = Class.create(); OpenLayers.Icon = OpenLayers.Class.create();
OpenLayers.Icon.prototype = { OpenLayers.Icon.prototype = {
/** image url /** image url
@@ -39,8 +40,12 @@ OpenLayers.Icon.prototype = {
initialize: function(url, size, offset, calculateOffset) { initialize: function(url, size, offset, calculateOffset) {
this.url = url; this.url = url;
this.size = (size) ? size : new OpenLayers.Size(20,20); this.size = (size) ? size : new OpenLayers.Size(20,20);
this.offset = (offset) ? offset : new OpenLayers.Pixel(0,0); this.offset = offset;
this.calculateOffset = calculateOffset; this.calculateOffset = (calculateOffset) ? calculateOffset
: function(size) {
return new OpenLayers.Pixel(-(size.w/2),
-(size.h/2));
};
this.imageDiv = OpenLayers.Util.createAlphaImageDiv(); this.imageDiv = OpenLayers.Util.createAlphaImageDiv();
}, },
@@ -87,6 +92,16 @@ OpenLayers.Icon.prototype = {
return this.imageDiv; return this.imageDiv;
}, },
/** Change the icon's opacity
* @param {float} opacity
*/
setOpacity: function(opacity) {
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,
null, null, null, null, opacity);
},
/** /**
* @param {OpenLayers.Pixel} px * @param {OpenLayers.Pixel} px
*/ */
@@ -120,4 +135,4 @@ OpenLayers.Icon.prototype = {
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Icon" CLASS_NAME: "OpenLayers.Icon"
}; };

View File

@@ -1,11 +1,12 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
*/ */
OpenLayers.Layer = Class.create(); OpenLayers.Layer = OpenLayers.Class.create();
OpenLayers.Layer.prototype = { OpenLayers.Layer.prototype = {
/** @type String */ /** @type String */
@@ -36,6 +37,25 @@ OpenLayers.Layer.prototype = {
* @type boolean */ * @type boolean */
alpha: false, alpha: false,
/** should the layer's name appear in the layer switcher?
*
* @type boolean */
displayInLayerSwitcher: true,
/** Whether or not the layer should be displayed in the map
*
* @type Boolean
*/
visibility: true,
/** Whether or not the map's current resolution is within this layer's
* min/max range -- this is set in map's setCenter() whenever zoom
* changes
*
* @type Boolean
*/
inRange: false,
// OPTIONS // OPTIONS
/** @type Array */ /** @type Array */
@@ -73,6 +93,9 @@ OpenLayers.Layer.prototype = {
/** @type float */ /** @type float */
maxScale: null, maxScale: null,
/** @type Boolean */
displayOutsideMaxExtent: false,
/** /**
@@ -82,24 +105,21 @@ OpenLayers.Layer.prototype = {
* @param {Object} options Hashtable of extra options to tag onto the layer * @param {Object} options Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, options) { initialize: function(name, options) {
if (arguments.length > 0) { //store a copy of the custom options for later cloning
this.options = OpenLayers.Util.extend(new Object(), options);
//add options to layer
OpenLayers.Util.extend(this, this.options);
//store a copy of the custom options for later cloning this.name = name;
this.options = Object.extend(new Object(), options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
//add options to layer
Object.extend(this, this.options); if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.name = name; this.div.style.width = "100%";
this.div.style.height = "100%";
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); this.div.id = this.id;
if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.div.style.width = "100%";
this.div.style.height = "100%";
this.div.id = this.id;
}
} }
}, },
@@ -152,10 +172,10 @@ OpenLayers.Layer.prototype = {
addOptions: function (newOptions) { addOptions: function (newOptions) {
// update our copy for clone // update our copy for clone
Object.extend(this.options, newOptions); OpenLayers.Util.extend(this.options, newOptions);
// add new options to this // add new options to this
Object.extend(this, this.options); OpenLayers.Util.extend(this, newOptions);
}, },
/** /**
@@ -169,10 +189,14 @@ OpenLayers.Layer.prototype = {
* @param {OpenLayers.Bounds} bound * @param {OpenLayers.Bounds} bound
* @param {Boolean} zoomChanged tells when zoom has changed, as layers * @param {Boolean} zoomChanged tells when zoom has changed, as layers
* have to do some init work in that case. * have to do some init work in that case.
* @param {Boolean} minor * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, dragging) {
//this function can be implemented by subclasses. var display = this.visibility;
if (!this.isBaseLayer) {
display = display && this.inRange;
}
this.display(display);
}, },
/** Set the map property for the layer. This is done through an accessor /** Set the map property for the layer. This is done through an accessor
@@ -187,46 +211,48 @@ OpenLayers.Layer.prototype = {
setMap: function(map) { setMap: function(map) {
this.map = map; this.map = map;
var properties = new Array( // grab some essential layer data from the map if it hasn't already
'projection', 'units', // been set
'scales', 'resolutions', this.maxExtent = this.maxExtent || this.map.maxExtent;
'maxScale', 'minScale', this.projection = this.projection || this.map.projection;
'maxResolution', 'minResolution', this.units = this.units || this.map.units;
'minExtent', 'maxExtent',
'numZoomLevels' this.initResolutions();
);
if (this.map.maxZoomLevel && !this.numZoomLevels) { if (!this.isBaseLayer) {
this.numZoomLevels = this.map.maxZoomLevel + 1; this.inRange = this.calculateInRange();
}
for(var i=0; i < properties.length; i++) {
if (this[properties[i]] == null) {
this[properties[i]] = this.map[properties[i]];
}
}
if (this.isBaseLayer) {
this.initResolutions();
} }
}, },
/** /**
* @returns Whether or not the layer is visible * @returns Whether or not the layer should be displayed (if in range)
* @type Boolean * @type Boolean
*/ */
getVisibility: function() { getVisibility: function() {
return (this.div.style.display != "none"); return this.visibility;
}, },
/** /** Set the visibility flag for the layer and hide/show&redraw accordingly.
* @param {Boolean} visible * Fire event unless otherwise specified
*
* Note that visibility is no longer simply whether or not the layer's
* style.display is set to "block". Now we store a 'visibility' state
* property on the layer class, this allows us to remember whether or not
* we *desire* for a layer to be visible. In the case where the map's
* resolution is out of the layer's range, this desire may be subverted.
*
* @param {Boolean} visible Whether or not to display the layer
* (if in range)
* @param {Boolean} noEvent * @param {Boolean} noEvent
*/ */
setVisibility: function(visible, noEvent) { setVisibility: function(visibility, noEvent) {
if (visible != this.getVisibility()) { if (visibility != this.visibility) {
this.div.style.display = (visible) ? "block" : "none"; this.visibility = visibility;
if ((visible) && (this.map != null)) { this.display(visibility);
if (this.map != null) {
var extent = this.map.getExtent(); var extent = this.map.getExtent();
if (extent != null) { if (extent != null) {
this.moveTo(this.map.getExtent(), true); this.moveTo(extent, true);
} }
} }
if ((this.map != null) && if ((this.map != null) &&
@@ -235,7 +261,32 @@ OpenLayers.Layer.prototype = {
} }
} }
}, },
/** Hide or show the Layer
*
* @param {Boolean} display
*/
display: function(display) {
if (display != (this.div.style.display != "none")) {
this.div.style.display = (display) ? "block" : "none";
}
},
/**
* @returns Whether or not the layer is displayable at the current map's
* current resolution
* @type Boolean
*/
calculateInRange: function() {
var inRange = false;
if (this.map) {
var resolution = this.map.getResolution();
inRange = ( (resolution >= this.minResolution) &&
(resolution <= this.maxResolution) );
}
return inRange;
},
/** /**
* @param {Boolean} isBaseLayer * @param {Boolean} isBaseLayer
*/ */
@@ -267,62 +318,122 @@ OpenLayers.Layer.prototype = {
* @private * @private
*/ */
initResolutions: function() { initResolutions: function() {
if ((this.scales != null) || (this.resolutions != null)) { // These are the relevant options which are used for calculating
// resolutions information.
//
var props = new Array(
'projection', 'units',
'scales', 'resolutions',
'maxScale', 'minScale',
'maxResolution', 'minResolution',
'minExtent', 'maxExtent',
'numZoomLevels', 'maxZoomLevel'
);
// First we create a new object where we will store all of the
// resolution-related properties that we find in either the layer's
// 'options' array or from the map.
//
var confProps = new Object();
for(var i=0; i < props.length; i++) {
var property = props[i];
confProps[property] = this.options[property] || this.map[property];
}
// If numZoomLevels hasn't been set and the maxZoomLevel *has*,
// then use maxZoomLevel to calculate numZoomLevels
//
if ( (!confProps.numZoomLevels) && (confProps.maxZoomLevel) ) {
confProps.numZoomLevels = confProps.maxZoomLevel + 1;
}
// First off, we take whatever hodge-podge of values we have and
// calculate/distill them down into a resolutions[] array
//
if ((confProps.scales != null) || (confProps.resolutions != null)) {
//preset levels //preset levels
if (this.scales != null) { if (confProps.scales != null) {
this.resolutions = new Array(); confProps.resolutions = new Array();
for(var i = 0; i < this.scales.length; i++) { for(var i = 0; i < confProps.scales.length; i++) {
this.resolutions[i] = var scale = confProps.scales[i];
OpenLayers.Util.getResolutionFromScale(this.scales[i], confProps.resolutions[i] =
this.units); OpenLayers.Util.getResolutionFromScale(scale,
confProps.units);
} }
} }
this.numZoomLevels = this.resolutions.length; confProps.numZoomLevels = confProps.resolutions.length;
} else { } else {
//maxResolution and numZoomLevels //maxResolution and numZoomLevels based calculation
this.resolutions = new Array(); confProps.resolutions = new Array();
// determine maxResolution // determine maxResolution
if (this.minScale) { if (confProps.minScale) {
this.maxResolution = confProps.maxResolution =
OpenLayers.Util.getResolutionFromScale(this.minScale, OpenLayers.Util.getResolutionFromScale(confProps.minScale,
this.units); confProps.units);
} else if (this.maxResolution == "auto") { } else if (confProps.maxResolution == "auto") {
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
var wRes = this.maxExtent.getWidth() / viewSize.w; var wRes = confProps.maxExtent.getWidth() / viewSize.w;
var hRes = this.maxExtent.getHeight()/ viewSize.h; var hRes = confProps.maxExtent.getHeight()/ viewSize.h;
this.maxResolution = Math.max(wRes, hRes); confProps.maxResolution = Math.max(wRes, hRes);
} }
// determine minResolution // determine minResolution
if (this.maxScale != null) { if (confProps.maxScale != null) {
this.minResolution = confProps.minResolution =
OpenLayers.Util.getResolutionFromScale(this.maxScale); OpenLayers.Util.getResolutionFromScale(confProps.maxScale);
} else if ((this.minResolution == "auto") && } else if ( (confProps.minResolution == "auto") &&
(this.minExtent != null)){ (confProps.minExtent != null) ) {
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
var wRes = this.minExtent.getWidth() / viewSize.w; var wRes = confProps.minExtent.getWidth() / viewSize.w;
var hRes = this.minExtent.getHeight()/ viewSize.h; var hRes = confProps.minExtent.getHeight()/ viewSize.h;
this.minResolution = Math.max(wRes, hRes); confProps.minResolution = Math.max(wRes, hRes);
} }
// determine numZoomLevels // determine numZoomLevels
if (this.minResolution != null) { if (confProps.minResolution != null) {
var ratio = this.maxResolution / this.minResolution; var ratio = confProps.maxResolution / confProps.minResolution;
this.numZoomLevels = confProps.numZoomLevels =
Math.floor(Math.log(ratio) / Math.log(2)) + 1; Math.floor(Math.log(ratio) / Math.log(2)) + 1;
} }
// now we have numZoomLevels and maxResolution, // now we have numZoomLevels and maxResolution,
// we can populate the resolutions array // we can populate the resolutions array
for (var i=0; i < this.numZoomLevels; i++) { for (var i=0; i < confProps.numZoomLevels; i++) {
this.resolutions.push(this.maxResolution / Math.pow(2, i)); var res = confProps.maxResolution / Math.pow(2, i)
confProps.resolutions.push(res);
} }
} }
this.resolutions = this.resolutions.sort().reverse();
//sort resolutions array ascendingly
//
confProps.resolutions.sort( function(a, b) { return(b-a); } );
// now set our newly calculated values back to the layer
// Note: We specifically do *not* set them to layer.options, which we
// will preserve as it was when we added this layer to the map.
// this way cloned layers reset themselves to new map div
// dimensions)
//
this.resolutions = confProps.resolutions;
this.maxResolution = confProps.resolutions[0];
var lastIndex = confProps.resolutions.length - 1;
this.minResolution = confProps.resolutions[lastIndex];
this.scales = new Array();
for(var i = 0; i < confProps.resolutions.length; i++) {
this.scales[i] =
OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i],
confProps.units);
}
this.minScale = this.scales[0];
this.maxScale = this.scales[this.scales.length - 1];
this.numZoomLevels = confProps.numZoomLevels;
}, },
/** /**
@@ -335,35 +446,16 @@ OpenLayers.Layer.prototype = {
return this.resolutions[zoom]; return this.resolutions[zoom];
}, },
/** Calculates based on resolution, center, and mapsize /**
*
* @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(resolution) { getExtent: function() {
var extent = null; // just use stock map calculateBounds function -- passing no arguments
// means it will user map's current center & resolution
var center = this.map.getCenter(); //
if (center != null) { return this.map.calculateBounds();
if (resolution == null) {
resolution = this.getResolution();
}
var size = this.map.getSize();
var w_deg = size.w * resolution;
var h_deg = size.h * resolution;
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;
}, },
/** /**
@@ -394,7 +486,7 @@ OpenLayers.Layer.prototype = {
*/ */
getZoomForResolution: function(resolution) { getZoomForResolution: function(resolution) {
for(var i=1; i <= this.resolutions.length; i++) { for(var i=1; i < this.resolutions.length; i++) {
if ( this.resolutions[i] < resolution) { if ( this.resolutions[i] < resolution) {
break; break;
} }
@@ -410,15 +502,19 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.LonLat * @type OpenLayers.LonLat
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { getLonLatFromViewPortPx: function (viewPortPx) {
var size = this.map.getSize(); var lonlat = null;
var center = this.map.getCenter(); if (viewPortPx != null) {
var res = this.map.getResolution(); var size = this.map.getSize();
var center = this.map.getCenter();
var delta_x = viewPortPx.x - (size.w / 2); var res = this.map.getResolution();
var delta_y = viewPortPx.y - (size.h / 2);
return new OpenLayers.LonLat(center.lon + delta_x * res , var delta_x = viewPortPx.x - Math.ceil(size.w / 2);
center.lat - delta_y * res); var delta_y = viewPortPx.y - Math.ceil(size.h / 2);
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);
}
return lonlat;
}, },
/** /**
@@ -429,12 +525,16 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.Pixel * @type OpenLayers.Pixel
*/ */
getViewPortPxFromLonLat: function (lonlat) { getViewPortPxFromLonLat: function (lonlat) {
var resolution = this.map.getResolution(); var px = null;
var extent = this.map.getExtent(); if (lonlat != null) {
return new OpenLayers.Pixel( var resolution = this.map.getResolution();
Math.round(1/resolution * (lonlat.lon - extent.left)), var extent = this.map.getExtent();
Math.round(1/resolution * (extent.top - lonlat.lat)) px = new OpenLayers.Pixel(
); Math.round(1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat))
);
}
return px;
}, },
/** /**
@@ -445,10 +545,19 @@ OpenLayers.Layer.prototype = {
this.opacity = opacity; this.opacity = opacity;
for(var i=0; i<this.div.childNodes.length; ++i) { for(var i=0; i<this.div.childNodes.length; ++i) {
var element = this.div.childNodes[i]; var element = this.div.childNodes[i];
OpenLayers.Util.setOpacity(element, opacity); OpenLayers.Util.modifyDOMElement(element, null, null, null,
null, null, null, opacity);
} }
}, },
/**
* @param {int} zIdx
* @private
*/
setZIndex: function (zIdx) {
this.div.style.zIndex = zIdx;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer" CLASS_NAME: "OpenLayers.Layer"
}; };

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,9 +9,9 @@
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
* @requires OpenLayers/Layer/Markers.js * @requires OpenLayers/Layer/Markers.js
*/ */
OpenLayers.Layer.Boxes = Class.create(); OpenLayers.Layer.Boxes = OpenLayers.Class.create();
OpenLayers.Layer.Boxes.prototype = OpenLayers.Layer.Boxes.prototype =
Object.extend( new OpenLayers.Layer.Markers(), { OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
initialize: function () { initialize: function () {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
@@ -33,7 +34,8 @@ OpenLayers.Layer.Boxes.prototype =
marker.display(false); marker.display(false);
} else { } else {
var sz = new OpenLayers.Size( var sz = new OpenLayers.Size(
botright.x - topleft.x, botright.y - topleft.y); Math.max(1, botright.x - topleft.x),
Math.max(1, botright.y - topleft.y));
var markerDiv = marker.draw(topleft, sz); var markerDiv = marker.draw(topleft, sz);
if (!marker.drawn) { if (!marker.drawn) {
this.div.appendChild(markerDiv); this.div.appendChild(markerDiv);

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
*/ */
OpenLayers.Layer.Canvas = Class.create(); OpenLayers.Layer.Canvas = OpenLayers.Class.create();
OpenLayers.Layer.Canvas.prototype = OpenLayers.Layer.Canvas.prototype =
Object.extend( new OpenLayers.Layer(), { OpenLayers.Class.inherit( OpenLayers.Layer, {
/** Canvas layer is never a base layer. /** Canvas layer is never a base layer.
* *
@@ -46,10 +47,12 @@ OpenLayers.Layer.Canvas.prototype =
/** /**
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged * @param {Boolean} zoomChanged
* @param {Boolean} minor * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, dragging) {
this.redraw(); OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
this.redraw();
}, },
setStrokeColor: function(color) { setStrokeColor: function(color) {

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,9 +9,9 @@
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
* @requires OpenLayers/Util.js * @requires OpenLayers/Util.js
*/ */
OpenLayers.Layer.EventPane = Class.create(); OpenLayers.Layer.EventPane = OpenLayers.Class.create();
OpenLayers.Layer.EventPane.prototype = OpenLayers.Layer.EventPane.prototype =
Object.extend(new OpenLayers.Layer, { OpenLayers.Class.inherit( OpenLayers.Layer, {
/** EventPaned layers are always base layers, by necessity. /** EventPaned layers are always base layers, by necessity.
* *
@@ -25,6 +26,15 @@ OpenLayers.Layer.EventPane.prototype =
/** @type DOMElement */ /** @type DOMElement */
pane: null, pane: null,
/** This is the object which will be used to load the 3rd party library
* in the case of the google layer, this will be of type GMap,
* in the case of the ve layer, this will be of type VEMap
*
* @type Object */
mapObject: null,
/** /**
* @constructor * @constructor
* *
@@ -33,14 +43,20 @@ OpenLayers.Layer.EventPane.prototype =
*/ */
initialize: function(name, options) { initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments); OpenLayers.Layer.prototype.initialize.apply(this, arguments);
if (this.pane == null) {
if (arguments.length > 0) { this.pane = OpenLayers.Util.createDiv(this.div.id + "_EventPane");
if (this.pane == null) {
this.pane = OpenLayers.Util.createDiv();
}
} }
}, },
/**
*
*/
destroy: function() {
this.mapObject = null;
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/** Set the map property for the layer. This is done through an accessor /** Set the map property for the layer. This is done through an accessor
* 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.
@@ -63,17 +79,234 @@ OpenLayers.Layer.EventPane.prototype =
} else { } else {
this.map.layerContainerDiv.appendChild(this.pane); this.map.layerContainerDiv.appendChild(this.pane);
} }
// once our layer has been added to the map, we can load it
this.loadMapObject();
// if map didn't load, display warning
if (this.mapObject == null) {
this.loadWarningMessage();
}
}, },
/** /** If we can't load the GMap, then display an error message to the
* @param {Boolean} visible * user and tell them where to go for help.
* @param {Boolean} noEvent *
* @private
*
*/ */
setVisibility: function(visible, noEvent) { loadWarningMessage:function() {
OpenLayers.Layer.prototype.setVisibility.apply(this, arguments);
this.div.style.backgroundColor = "darkblue";
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(this.name + "_warning",
topLeft,
size,
null,
null,
null,
"auto");
div.style.padding = "7px";
div.style.backgroundColor = "yellow";
div.innerHTML = this.getWarningHTML();
this.div.appendChild(div);
},
/**
* @param {Boolean} display
*/
display: function(display) {
OpenLayers.Layer.prototype.display.apply(this, arguments);
this.pane.style.display = this.div.style.display; this.pane.style.display = this.div.style.display;
}, },
/**
* @param {int} zIndex
*/
setZIndex: function (zIndex) {
OpenLayers.Layer.prototype.setZIndex.apply(this, arguments);
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
if (this.mapObject != null) {
var newCenter = this.map.getCenter();
var newZoom = this.map.getZoom();
if (newCenter != null) {
var moOldCenter = this.getMapObjectCenter();
var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter);
var moOldZoom = this.getMapObjectZoom();
var oldZoom= this.getOLZoomFromMapObjectZoom(moOldZoom);
if ( !(newCenter.equals(oldCenter)) ||
!(newZoom == oldZoom) ) {
var center = this.getMapObjectLonLatFromOLLonLat(newCenter);
var zoom = this.getMapObjectZoomFromOLZoom(newZoom);
this.setMapObjectCenter(center, zoom);
}
}
}
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if ( (this.mapObject != null) &&
(this.getMapObjectCenter() != null) ) {
var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);
var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel)
lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);
}
return lonlat;
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null;
if ( (this.mapObject != null) &&
(this.getMapObjectCenter() != null) ) {
var moLonLat = this.getMapObjectLonLatFromOLLonLat(lonlat);
var moPixel = this.getMapObjectPixelFromMapObjectLonLat(moLonLat)
viewPortPx = this.getOLPixelFromMapObjectPixel(moPixel);
}
return viewPortPx;
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate Map Object and */
/* OL formats for Pixel, LonLat */
/* */
/********************************************************/
//
// TRANSLATION: MapObject LatLng <-> OpenLayers.LonLat
//
/**
* @param {Object} moLonLat
*
* @returns An OpenLayers.LonLat, translated from the passed in
* MapObject LonLat
* Returns null if null value is passed in
* @type OpenLayers.LonLat
*/
getOLLonLatFromMapObjectLonLat: function(moLonLat) {
var olLonLat = null;
if (moLonLat != null) {
var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);
var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);
olLonLat = new OpenLayers.LonLat(lon, lat);
}
return olLonLat;
},
/**
* @param {OpenLayers.LonLat} olLonLat
*
* @returns A MapObject LonLat, translated from the passed in
* OpenLayers.LonLat
* Returns null if null value is passed in
* @type Object
*/
getMapObjectLonLatFromOLLonLat: function(olLonLat) {
var moLatLng = null;
if (olLonLat != null) {
moLatLng = this.getMapObjectLonLatFromLonLat(olLonLat.lon,
olLonLat.lat);
}
return moLatLng;
},
//
// TRANSLATION: MapObject Pixel <-> OpenLayers.Pixel
//
/**
* @param {Object} moPixel
*
* @returns An OpenLayers.Pixel, translated from the passed in
* MapObject Pixel
* Returns null if null value is passed in
* @type OpenLayers.Pixel
*/
getOLPixelFromMapObjectPixel: function(moPixel) {
var olPixel = null;
if (moPixel != null) {
var x = this.getXFromMapObjectPixel(moPixel);
var y = this.getYFromMapObjectPixel(moPixel);
olPixel = new OpenLayers.Pixel(x, y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A MapObject Pixel, translated from the passed in
* OpenLayers.Pixel
* Returns null if null value is passed in
* @type Object
*/
getMapObjectPixelFromOLPixel: function(olPixel) {
var moPixel = null;
if (olPixel != null) {
moPixel = this.getMapObjectPixelFromXY(olPixel.x, olPixel.y);
}
return moPixel;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.EventPane" CLASS_NAME: "OpenLayers.Layer.EventPane"

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
@@ -44,7 +45,7 @@
* *
* @class * @class
*/ */
OpenLayers.Layer.FixedZoomLevels = Class.create(); OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class.create();
OpenLayers.Layer.FixedZoomLevels.prototype = { OpenLayers.Layer.FixedZoomLevels.prototype = {
/********************************************************/ /********************************************************/
@@ -67,9 +68,46 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
// do want to put some functionality or state in here. // do want to put some functionality or state in here.
}, },
/**
*
*/
initResolutions: function() { initResolutions: function() {
// resolutions are set automatically in the black-box. this is the
// definition of a fixed-zoom-levels layer var props = new Array('minZoomLevel', 'maxZoomLevel', 'numZoomLevels');
for(var i=0; i < props.length; i++) {
var property = props[i];
this[property] = (this.options[property] != null)
? this.options[property]
: this.map[property];
}
if ( (this.minZoomLevel == null) ||
(this.minZoomLevel < this.MIN_ZOOM_LEVEL) ){
this.minZoomLevel = this.MIN_ZOOM_LEVEL;
}
var limitZoomLevels = this.MAX_ZOOM_LEVEL - this.minZoomLevel + 1;
if (this.numZoomLevels != null) {
this.numZoomLevels = Math.min(this.numZoomLevels, limitZoomLevels);
} else {
if (this.maxZoomLevel != null) {
var zoomDiff = this.maxZoomLevel - this.minZoomLevel + 1;
this.numZoomLevels = Math.min(zoomDiff, limitZoomLevels);
} else {
this.numZoomLevels = limitZoomLevels;
}
}
this.maxZoomLevel = this.minZoomLevel + this.numZoomLevels - 1;
if (this.RESOLUTIONS != null) {
var resolutionsIndex = 0;
this.resolutions = [];
for(var i= this.minZoomLevel; i < this.numZoomLevels; i++) {
this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];
}
}
}, },
/** /**
@@ -77,12 +115,23 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
* @type float * @type float
*/ */
getResolution: function() { getResolution: function() {
var viewSize = this.map.getSize();
var extent = this.getExtent(); if (this.resolutions != null) {
return Math.max( extent.getWidth() / viewSize.w, return OpenLayers.Layer.prototype.getResolution.apply(this, arguments);
extent.getHeight() / viewSize.h ); } else {
}, var resolution = null;
var viewSize = this.map.getSize();
var extent = this.getExtent();
if ((viewSize != null) && (extent != null)) {
resolution = Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
}
return resolution;
}
},
/** Calculates using px-> lonlat translation functions on tl and br /** Calculates using px-> lonlat translation functions on tl and br
* corners of viewport * corners of viewport
* *
@@ -121,12 +170,64 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
*/ */
getZoomForResolution: function(resolution) { getZoomForResolution: function(resolution) {
var extent = OpenLayers.Layer.prototype.getExtent.apply(this, if (this.resolutions != null) {
[resolution]); return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments);
} else {
return this.getZoomForExtent(extent); var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
[resolution]);
return this.getZoomForExtent(extent);
}
}, },
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
//
/**
* @param {int} gZoom
*
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromMapObjectZoom: function(moZoom) {
var zoom = null;
if (moZoom != null) {
zoom = moZoom - this.minZoomLevel;
}
return zoom;
},
/**
* @param {int} olZoom
*
* @returns A MapObject level, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getMapObjectZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
}
return zoom;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "FixedZoomLevels.js" CLASS_NAME: "FixedZoomLevels.js"
}; };

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/Markers.js * @requires OpenLayers/Layer/Markers.js
*/ */
OpenLayers.Layer.GeoRSS = Class.create(); OpenLayers.Layer.GeoRSS = OpenLayers.Class.create();
OpenLayers.Layer.GeoRSS.prototype = OpenLayers.Layer.GeoRSS.prototype =
Object.extend( new OpenLayers.Layer.Markers(), { OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
/** store url of text file /** store url of text file
* @type str */ * @type str */
@@ -44,15 +45,40 @@ OpenLayers.Layer.GeoRSS.prototype =
}, },
/** /**
* @param {?} ajaxRequest * @param {XMLHttpRequest} ajaxRequest
*/ */
parseData: function(ajaxRequest) { parseData: function(ajaxRequest) {
var doc = ajaxRequest.responseXML; var doc = ajaxRequest.responseXML;
if (!doc || ajaxRequest.fileType!="XML") { if (!doc || ajaxRequest.fileType!="XML") {
doc = OpenLayers.parseXMLString(ajaxRequest.responseText); doc = OpenLayers.parseXMLString(ajaxRequest.responseText);
} }
this.name = doc.getElementsByTagName("title")[0].firstChild.nodeValue;
var itemlist = doc.getElementsByTagName('item'); this.name = null;
try {
this.name = doc.getElementsByTagNameNS('*', 'title')[0].firstChild.nodeValue;
}
catch (e) {
this.name = doc.getElementsByTagName('title')[0].firstChild.nodeValue;
}
/* Try RSS items first, then Atom entries */
var itemlist = null;
try {
itemlist = doc.getElementsByTagNameNS('*', 'item');
}
catch (e) {
itemlist = doc.getElementsByTagName('item');
}
if (itemlist.length == 0) {
try {
itemlist = doc.getElementsByTagNameNS('*', 'entry');
}
catch(e) {
itemlist = doc.getElementsByTagName('entry');
}
}
for (var i = 0; i < itemlist.length; i++) { for (var i = 0; i < itemlist.length; i++) {
var data = {}; var data = {};
var point = OpenLayers.Util.getNodes(itemlist[i], 'georss:point'); var point = OpenLayers.Util.getNodes(itemlist[i], 'georss:point');
@@ -72,44 +98,52 @@ OpenLayers.Layer.GeoRSS.prototype =
location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0])); location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0]));
/* Provide defaults for title and description */ /* Provide defaults for title and description */
var title = "No title"; var title = "Untitled";
try { try {
title = OpenLayers.Util.getNodes(itemlist[i], title = OpenLayers.Util.getNodes(itemlist[i],
"title")[0].firstChild.nodeValue; "title")[0].firstChild.nodeValue;
} }
catch (e) { alert(e); } catch (e) { title="Untitled"; }
var description = "No description"; /* First try RSS descriptions, then Atom summaries */
var descr_nodes = null;
try { try {
description = OpenLayers.Util.getNodes(itemlist[i], descr_nodes = itemlist[i].getElementsByTagNameNS("*",
"description")[0].firstChild.nodeValue; "description");
} }
catch (e) { alert(e); } catch (e) {
descr_nodes = itemlist[i].getElementsByTagName("description");
}
if (descr_nodes.length == 0) {
try {
descr_nodes = itemlist[i].getElementsByTagNameNS("*",
"summary");
}
catch (e) {
descr_nodes = itemlist[i].getElementsByTagName("summary");
}
}
var description = "No description.";
try {
description = descr_nodes[0].firstChild.nodeValue;
}
catch (e) { description="No description."; }
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, 120);
if ((title != null) && (description != null)) { if ((title != null) && (description != null)) {
contentHTML = "<br />"; contentHTML = '<div class="olLayerGeoRSSClose">[x]</div>';
contentHTML += "<div style='margin: -0.5em 0.5em 0.5em 0.5em'>" contentHTML += '<div class="olLayerGeoRSSTitle">';
if (link) contentHTML += '<a class="link" href="'+link+'" target="_blank">';
contentHTML += "<div style='height: 1.3em; overflow: hidden'>"; contentHTML += title;
contentHTML += "<span style='font-size: 1.2em; font-weight: bold'>"; if (link) contentHTML += '</a>';
if (link) contentHTML += "<a href='"+link+"' target='_blank'>"; contentHTML += '</div>';
contentHTML += title; contentHTML += '<div style="" class="olLayerGeoRSSDescription">';
if (link) contentHTML += "</a>";
contentHTML += "</span>";
contentHTML += "</div>";
contentHTML += "<span style='font-size: 0.7em; align:center'>";
contentHTML += description; contentHTML += description;
contentHTML += "</span>"; contentHTML += '</div>';
data['popupContentHTML'] = contentHTML;
contentHTML += "</div>"
data['popupContentHTML'] = contentHTML;
//data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
} }
var feature = new OpenLayers.Feature(this, location, data); var feature = new OpenLayers.Feature(this, location, data);
this.features.push(feature); this.features.push(feature);
@@ -130,7 +164,7 @@ OpenLayers.Layer.GeoRSS.prototype =
} }
if (!sameMarkerClicked) { if (!sameMarkerClicked) {
var popup = this.createPopup(); var popup = this.createPopup();
Event.observe(popup.div, "click", OpenLayers.Event.observe(popup.div, "click",
function() { function() {
for(var i=0; i < this.layer.map.popups.length; i++) { for(var i=0; i < this.layer.map.popups.length; i++) {
this.layer.map.removePopup(this.layer.map.popups[i]); this.layer.map.removePopup(this.layer.map.popups[i]);
@@ -138,7 +172,7 @@ OpenLayers.Layer.GeoRSS.prototype =
}.bindAsEventListener(this)); }.bindAsEventListener(this));
this.layer.map.addPopup(popup); this.layer.map.addPopup(popup);
} }
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/** /**
@@ -148,7 +182,7 @@ OpenLayers.Layer.GeoRSS.prototype =
if (this.features != null) { if (this.features != null) {
while(this.features.length > 0) { while(this.features.length > 0) {
var feature = this.features[0]; var feature = this.features[0];
this.features.remove(feature); OpenLayers.Util.removeItem(this.features, feature);
feature.destroy(); feature.destroy();
} }
} }

View File

@@ -1,38 +1,34 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/EventPane.js * @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
*/ */
OpenLayers.Layer.Google = Class.create(); OpenLayers.Layer.Google = OpenLayers.Class.create();
OpenLayers.Layer.Google.prototype = OpenLayers.Layer.Google.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), { OpenLayers.Layer.FixedZoomLevels, {
/** @type Boolean */ /** @final @type int */
isFixed: true, MIN_ZOOM_LEVEL: 0,
/** @final @type int */
MAX_ZOOM_LEVEL: 17,
/** @type GMap2 gmap stores the Google Map element */ /** Hardcode these resolutions so that they are more closely
gmap:null, * tied with the standard wms projection
*
* @final @type Array(float) */
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
/** @type GMapType */ /** @type GMapType */
type: null, type: null,
// OPTIONS
/** @type int */
minZoomLevel: 0,
/** @type int */
maxZoomLevel: 16,
/** /**
* @constructor * @constructor
* *
@@ -42,90 +38,68 @@ OpenLayers.Layer.Google.prototype =
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments); OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments); arguments);
if (this.maxExtent == null) { this.addContainerPxFunction();
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
}
this.addContainerPxFunction();
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
}, },
/**
*
*/
destroy: function() {
this.gmap = null;
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
},
/**
* @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 it
this.loadGMap();
},
/** Assuming we are not dragging (in which case GMaps is moving itself,
* and the dragging flag is set) we need to move the gmap to the
* new center/zoom
*
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} minor
*/
moveTo:function(bounds, zoomChanged, minor) {
if ((this.gmap != null) && (!this.dragging)) {
var newOLCenter = this.map.getCenter();
var newOLZoom = this.map.getZoom();
if (newOLCenter != null) {
var oldGCenter = this.gmap.getCenter();
var oldOLCenter = this.getOLLonLatFromGLatLng(oldGCenter);
var oldGZoom = this.gmap.getZoom();
var oldOLZoom = this.getOLZoomFromGZoom(oldGZoom);
if ( !(newOLCenter.equals(oldOLCenter)) ||
!(newOLZoom == oldOLZoom) ) {
var newGCenter = this.getGLatLngFromOLLonLat(newOLCenter);
var newGZoom = this.getGZoomFromOLZoom(newOLZoom);
this.gmap.setCenter(newGCenter, newGZoom);
if (this.type != null) {
this.gmap.setMapType(this.type);
this.type = null;
}
}
}
}
},
/** Load the GMap and register appropriate event listeners. If we can't /** Load the GMap and register appropriate event listeners. If we can't
* load GMap2, then display a warning message. * load GMap2, then display a warning message.
* *
* @private * @private
*
*/ */
loadGMap:function() { loadMapObject:function() {
//has gmaps library has been loaded? //has gmaps library has been loaded?
try { try {
// create GMap, hide nav controls // create GMap, hide nav controls
this.gmap = new GMap2( this.div ); this.mapObject = new GMap2( this.div );
this.gmap.disableDragging();
// move the ToS and branding stuff up to the pane
// this causes the GMap to set itself to Map's center/zoom // thanks a *mil* Erik for thinking of this
this.moveTo(); var poweredBy = this.div.lastChild;
this.div.removeChild(poweredBy);
this.pane.appendChild(poweredBy);
poweredBy.className = "olLayerGooglePoweredBy gmnoprint";
poweredBy.style.left = "";
poweredBy.style.bottom = "";
var termsOfUse = this.div.lastChild;
this.div.removeChild(termsOfUse);
this.pane.appendChild(termsOfUse);
termsOfUse.className = "olLayerGoogleCopyright";
termsOfUse.style.right = "";
termsOfUse.style.bottom = "";
} catch (e) { } catch (e) {
this.loadWarningMessage(); // do not crash
}
},
/** Overridden from EventPane because if a map type has been specified,
* we need to attach a listener for the first moveend -- this is how
* we will know that the map has been centered. Only once the map has
* been centered is it safe to change the gmap object's map type.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
if (this.type != null) {
this.map.events.register("moveend", this, this.setMapType);
}
},
/** The map has been centered, and a map type was specified, so we
* set the map type on the gmap object, then unregister the listener
* so that we dont keep doing this every time the map moves.
*
* @private
*/
setMapType: function() {
if (this.mapObject.getCenter() != null) {
this.mapObject.setMapType(this.type);
this.map.events.unregister("moveend", this, this.setMapType);
} }
}, },
@@ -133,106 +107,7 @@ OpenLayers.Layer.Google.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
onMapResize: function() { onMapResize: function() {
this.gmap.checkResize(); this.mapObject.checkResize();
},
/** If we can't load the GMap, 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 Google Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the Google Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Google Maps library";
html += " script was either not included, or does not contain the";
html += " correct API key for your site.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/GoogleMapsLayer' "
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("gmapsWarning",
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 GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gPoint = this.getGPointFromOLPixel(viewPortPx);
var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint)
lonlat = this.getOLLonLatFromGLatLng(gLatLng);
}
return lonlat;
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null;
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
// note we use special hacked function here
var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng);
viewPortPx = this.getOLPixelFromGPoint(gPoint);
}
return viewPortPx;
}, },
@@ -240,152 +115,43 @@ OpenLayers.Layer.Google.prototype =
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* *
* @returns Corresponding zoom level for a specified Bounds. * @returns Corresponding zoom level for a specified Bounds.
* If gmap is not loaded or not centered, returns null * If mapObject is not loaded or not centered, returns null
* @type int * @type int
*/ *
getZoomForExtent: function (bounds) { getZoomForExtent: function (bounds) {
var zoom = null; var zoom = null;
if ((this.gmap != null) && (this.gmap.getCenter() != null)) { if (this.mapObject != null) {
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); var moBounds = this.getMapObjectBoundsFromOLBounds(bounds);
var gZoom = this.gmap.getBoundsZoomLevel(gBounds); var moZoom = this.getMapObjectZoomFromMapObjectBounds(moBounds);
//make sure zoom is within bounds //make sure zoom is within bounds
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel), var moZoom = Math.min(Math.max(moZoom, this.minZoomLevel),
this.maxZoomLevel); this.maxZoomLevel);
zoom = this.getOLZoomFromGZoom(gZoom); zoom = this.getOLZoomFromMapObjectZoom(moZoom);
} }
return zoom; return zoom;
}, },
/********************************************************/ */
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
/**
* @param {int} gZoom
*
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromGZoom: function(gZoom) {
var zoom = null;
if (gZoom != null) {
zoom = gZoom - this.minZoomLevel;
}
return zoom;
},
/**
* @param {int} olZoom
*
* @returns A GZoom level, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getGZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
}
return zoom;
},
// //
// TRANSLATION: GLatLng <-> LonLat // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds
// //
/** /**
* @param {GLatLng} gLatLng * @param {Object} moBounds
* *
* @returns An OpenLayers.LonLat, translated from the passed in GLatLng * @returns An OpenLayers.Bounds, translated from the passed-in
* Returns null if null value is passed in * MapObject Bounds
* @type OpenLayers.LonLat
*/
getOLLonLatFromGLatLng: function(gLatLng) {
var olLonLat = null;
if (gLatLng != null) {
olLonLat = new OpenLayers.LonLat(gLatLng.lng(), gLatLng.lat());
}
return olLonLat;
},
/**
* @param {OpenLayers.LonLat} olLonLat
*
* @returns A GLatLng, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type GLatLng
*/
getGLatLngFromOLLonLat: function(olLonLat) {
var gLatLng = null;
if (olLonLat != null) {
gLatLng = new GLatLng(olLonLat.lat, olLonLat.lon);
}
return gLatLng;
},
//
// TRANSLATION: GPoint <-> OpenLayers.Pixel
//
/**
* @param {GPoint} gPoint
*
* @returns An OpenLayers.Pixel, translated from the passed in GPoint
* Returns null if null value is passed in
* @type OpenLayers.Pixel
*/
getOLPixelFromGPoint: function(gPoint) {
var olPixel = null;
if (gPoint != null) {
olPixel = new OpenLayers.Pixel(gPoint.x, gPoint.y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A GPoint, translated from the passed in OpenLayers.Pixel
* Returns null if null value is passed in
* @type GPoint
*/
getGPointFromOLPixel: function(olPixel) {
var gPoint = null;
if (olPixel != null) {
gPoint = new GPoint(olPixel.x, olPixel.y);
}
return gPoint;
},
//
// TRANSLATION: GLatLngBounds <-> OpenLayers.Bounds
//
/**
* @param {GLatLngBounds} gLatLngBounds
*
* @returns An OpenLayers.Bounds, translated from gLatLngBounds
* Returns null if null value is passed in * Returns null if null value is passed in
* @type OpenLayers.Bounds * @type OpenLayers.Bounds
*/ */
getOLBoundsFromGLatLngBounds: function(gLatLngBounds) { getOLBoundsFromMapObjectBounds: function(moBounds) {
var olBounds = null; var olBounds = null;
if (gLatLngBounds != null) { if (moBounds != null) {
var sw = gLatLngBounds.getSouthWest(); var sw = moBounds.getSouthWest();
var ne = gLatLngBounds.getNorthEast(); var ne = moBounds.getNorthEast();
olBounds = new OpenLayers.Bounds(sw.lng(), olBounds = new OpenLayers.Bounds(sw.lng(),
sw.lat(), sw.lat(),
ne.lng(), ne.lng(),
@@ -397,47 +163,222 @@ OpenLayers.Layer.Google.prototype =
/** /**
* @param {OpenLayers.Bounds} olBounds * @param {OpenLayers.Bounds} olBounds
* *
* @returns A GLatLngBounds, translated from olBounds * @returns A MapObject Bounds, translated from olBounds
* Returns null if null value is passed in * Returns null if null value is passed in
* @type GLatLngBounds * @type Object
*/ */
getGLatLngBoundsFromOLBounds: function(olBounds) { getMapObjectBoundsFromOLBounds: function(olBounds) {
var gLatLngBounds = null; var moBounds = null;
if (olBounds != null) { if (olBounds != null) {
var sw = new GLatLng(olBounds.bottom, olBounds.left); var sw = new GLatLng(olBounds.bottom, olBounds.left);
var ne = new GLatLng(olBounds.top, olBounds.right); var ne = new GLatLng(olBounds.top, olBounds.right);
gLatLngBounds = new GLatLngBounds(sw, ne); moBounds = new GLatLngBounds(sw, ne);
} }
return gLatLngBounds; return moBounds;
}, },
/** 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
*/
addContainerPxFunction: function() { addContainerPxFunction: function() {
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) { if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
/** Hack-on function because GMAPS does not give it to us GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel" // first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng); var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div // locate the sliding "Div" div
// it seems like "b" is the main div // it seems like "b" is the main div
var div = this.b.firstChild.firstChild; var div = this.b.firstChild.firstChild;
// adjust by the offset of "Div" and voila! // adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft; gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop; gPoint.y += div.offsetTop;
return gPoint; return gPoint;
}; };
} }
}, },
/**
* @return String with information on why layer is broken, how to get
* it working.
* @type String
*/
getWarningHTML:function() {
var html = "";
html += "The Google Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, select a new BaseLayer "
html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Google Maps library";
html += " script was either not included, or does not contain the";
html += " correct API key for your site.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/Google' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
return html;
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
*
* @param {Object} center MapObject LonLat format
* @param {int} zoom MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.setCenter(center, zoom);
},
/**
* @returns the mapObject's current center in Map Object format
* @type Object
*/
getMapObjectCenter: function() {
return this.mapObject.getCenter();
},
/**
* @returns the mapObject's current zoom, in Map Object format
* @type int
*/
getMapObjectZoom: function() {
return this.mapObject.getZoom();
},
// LonLat - Pixel Translation
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject LonLat translated from MapObject Pixel
* @type Object
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
return this.mapObject.fromContainerPixelToLatLng(moPixel);
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject Pixel translated from MapObject LonLat
* @type Object
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.fromLatLngToContainerPixel(moLonLat);
},
// Bounds
/**
* @param {Object} moBounds MapObject Bounds format
*
* @returns MapObject Zoom for specified MapObject Bounds
* @type Object
*/
getMapObjectZoomFromMapObjectBounds: function(moBounds) {
return this.mapObject.getBoundsZoomLevel(moBounds);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Longitude of the given MapObject LonLat
* @type float
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lng();
},
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Latitude of the given MapObject LonLat
* @type float
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lat();
},
/**
* @param {int} lon float
* @param {int} lat float
*
* @returns MapObject LonLat built from lon and lat params
* @type Object
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
return new GLatLng(lat, lon);
},
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns Y value of the MapObject Pixel
* @type int
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {int} x
* @param {int} y
*
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getMapObjectPixelFromXY: function(x, y) {
return new GPoint(x, y);
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google" CLASS_NAME: "OpenLayers.Layer.Google"
})); });

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/HTTPRequest.js * @requires OpenLayers/Layer/HTTPRequest.js
*/ */
OpenLayers.Layer.Grid = Class.create(); OpenLayers.Layer.Grid = OpenLayers.Class.create();
OpenLayers.Layer.Grid.prototype = OpenLayers.Layer.Grid.prototype =
Object.extend( new OpenLayers.Layer.HTTPRequest(), { OpenLayers.Class.inherit( OpenLayers.Layer.HTTPRequest, {
/** @type OpenLayers.Size */ /** @type OpenLayers.Size */
tileSize: null, tileSize: null,
@@ -69,8 +70,8 @@ OpenLayers.Layer.Grid.prototype =
obj.tileSize = this.tileSize.clone(); obj.tileSize = this.tileSize.clone();
} }
// we do not want to copy reference to grid. that should stay at null // we do not want to copy reference to grid, so we make a new array
obj.grid = null; obj.grid = new Array();
return obj; return obj;
}, },
@@ -96,6 +97,8 @@ OpenLayers.Layer.Grid.prototype =
* @param {Boolean} dragging * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, dragging) { moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);
if (bounds == null) { if (bounds == null) {
bounds = this.map.getExtent(); bounds = this.map.getExtent();
} }
@@ -104,21 +107,33 @@ OpenLayers.Layer.Grid.prototype =
|| !this.getGridBounds().containsBounds(bounds, true)) { || !this.getGridBounds().containsBounds(bounds, true)) {
this._initTiles(); this._initTiles();
} else { } else {
var buffer = (this.buffer) ? this.buffer*1.5 : 1;
while (true) { while (true) {
var tlLayer = this.grid[0][0].position; var tlLayer = this.grid[0][0].position;
var tlViewPort = var tlViewPort =
this.map.getViewPortPxFromLayerPx(tlLayer); this.map.getViewPortPxFromLayerPx(tlLayer);
if (tlViewPort.x > -this.tileSize.w * (this.buffer - 1)) { if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) {
this.shiftColumn(true); this.shiftColumn(true);
} else if (tlViewPort.x < -this.tileSize.w * this.buffer) { } else if (tlViewPort.x < -this.tileSize.w * buffer) {
this.shiftColumn(false); this.shiftColumn(false);
} else if (tlViewPort.y > -this.tileSize.h * (this.buffer - 1)) { } else if (tlViewPort.y > -this.tileSize.h * (buffer - 1)) {
this.shiftRow(true); this.shiftRow(true);
} else if (tlViewPort.y < -this.tileSize.h * this.buffer) { } else if (tlViewPort.y < -this.tileSize.h * buffer) {
this.shiftRow(false); this.shiftRow(false);
} else { } else {
break; break;
} }
};
if (this.buffer == 0) {
for (var r=0, rl=this.grid.length; r<rl; r++) {
var row = this.grid[r];
for (var c=0, cl=row.length; c<cl; c++) {
var tile = row[c];
if (!tile.drawn && tile.bounds.intersectsBounds(bounds, false)) {
tile.draw();
}
}
}
} }
} }
} }
@@ -150,7 +165,13 @@ OpenLayers.Layer.Grid.prototype =
* @private * @private
*/ */
_initTiles:function() { _initTiles:function() {
// work out mininum number of rows and columns; this is the number of
// tiles required to cover the viewport plus one for panning
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
var minRows = Math.ceil(viewSize.h/this.tileSize.h) + 1;
var minCols = Math.ceil(viewSize.w/this.tileSize.w) + 1;
var bounds = this.map.getExtent(); var bounds = this.map.getExtent();
var extent = this.map.getMaxExtent(); var extent = this.map.getMaxExtent();
var resolution = this.map.getResolution(); var resolution = this.map.getResolution();
@@ -213,12 +234,31 @@ OpenLayers.Layer.Grid.prototype =
tileoffsetlon += tilelon; tileoffsetlon += tilelon;
tileoffsetx += this.tileSize.w; tileoffsetx += this.tileSize.w;
} while (tileoffsetlon <= bounds.right + tilelon * this.buffer) } while ((tileoffsetlon <= bounds.right + tilelon * this.buffer)
|| colidx < minCols)
tileoffsetlat -= tilelat; tileoffsetlat -= tilelat;
tileoffsety += this.tileSize.h; tileoffsety += this.tileSize.h;
} while(tileoffsetlat >= bounds.bottom - tilelat * this.buffer) } while((tileoffsetlat >= bounds.bottom - tilelat * this.buffer)
|| rowidx < minRows)
// remove extra rows
while (this.grid.length > rowidx) {
var row = this.grid.pop();
for (var i=0, l=row.length; i<l; i++) {
row[i].destroy();
}
}
// remove extra columns
while (this.grid[0].length > colidx) {
for (var i=0, l=this.grid.length; i<l; i++) {
var row = this.grid[i];
var tile = row.pop();
tile.destroy();
}
}
//now actually draw the tiles //now actually draw the tiles
this.spiralTileLoad(); this.spiralTileLoad();
}, },
@@ -241,7 +281,7 @@ OpenLayers.Layer.Grid.prototype =
var iRow = 0; var iRow = 0;
var iCell = -1; var iCell = -1;
var direction = directions.indexOf("right"); var direction = OpenLayers.Util.indexOf(directions, "right");
var directionsTried = 0; var directionsTried = 0;
while( directionsTried < directions.length) { while( directionsTried < directions.length) {
@@ -322,8 +362,9 @@ OpenLayers.Layer.Grid.prototype =
for(var iRow=0; iRow < this.grid.length; iRow++) { for(var iRow=0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow]; var row = this.grid[iRow];
for(var iCol=0; iCol < row.length; iCol++) { for(var iCol=0; iCol < row.length; iCol++) {
row[iCol].clear(); row[iCol].destroy();
} }
this.grid = [];
} }
} }
}, },

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
*/ */
OpenLayers.Layer.HTTPRequest = Class.create(); OpenLayers.Layer.HTTPRequest = OpenLayers.Class.create();
OpenLayers.Layer.HTTPRequest.prototype = OpenLayers.Layer.HTTPRequest.prototype =
Object.extend( new OpenLayers.Layer(), { OpenLayers.Class.inherit( OpenLayers.Layer, {
/** @type String */ /** @type String */
url: null, url: null,
@@ -17,6 +18,15 @@ OpenLayers.Layer.HTTPRequest.prototype =
/** Hashtable of key/value parameters /** Hashtable of key/value parameters
* @type Object */ * @type Object */
params: null, params: null,
/** Whether layer should reproject itself based on base layer locations.
* This allows reprojection onto commercial layers. Default is false:
* Most layers can't reproject, but layers which can create non-square
* geographic pixels can, like WMS.
*
* @type Boolean
*/
reproject: false,
/** /**
* @constructor * @constructor
@@ -28,12 +38,10 @@ OpenLayers.Layer.HTTPRequest.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = arguments; var newArguments = arguments;
if (arguments.length > 0) { newArguments = [name, options];
newArguments = [name, options];
}
OpenLayers.Layer.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
this.url = url; this.url = url;
this.params = Object.extend( new Object(), params); this.params = OpenLayers.Util.extend( new Object(), params);
}, },
/** /**
@@ -79,7 +87,7 @@ OpenLayers.Layer.HTTPRequest.prototype =
* @param {Object} newParams * @param {Object} newParams
*/ */
mergeNewParams:function(newParams) { mergeNewParams:function(newParams) {
this.params = Object.extend(this.params, newParams); this.params = OpenLayers.Util.extend(this.params, newParams);
}, },
@@ -101,21 +109,34 @@ OpenLayers.Layer.HTTPRequest.prototype =
// use layer's url unless altUrl passed in // use layer's url unless altUrl passed in
var url = (altUrl == null) ? this.url : altUrl; var url = (altUrl == null) ? this.url : altUrl;
// if url is not a string, it should be an array of strings,
// in which case we will randomly select one of them in order
// to evenly distribute requests to different urls.
if (typeof url == "object") {
url = url[Math.floor(Math.random()*url.length)];
}
// requestString always starts with url // requestString always starts with url
var requestString = url; var requestString = url;
// create a new params hashtable with all the layer params and the // create a new params hashtable with all the layer params and the
// new params together. then convert to string // new params together. then convert to string
var allParams = Object.extend(new Object(), this.params); var allParams = OpenLayers.Util.extend(new Object(), this.params);
var allParams = Object.extend(allParams, newParams); allParams = OpenLayers.Util.extend(allParams, newParams);
// ignore parameters that are already in the url search string
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getArgs(url));
for(var key in allParams) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
var paramsString = OpenLayers.Util.getParameterString(allParams); var paramsString = OpenLayers.Util.getParameterString(allParams);
if (paramsString != "") { if (paramsString != "") {
var lastServerChar = this.url.charAt(this.url.length - 1); var lastServerChar = url.charAt(url.length - 1);
if ((lastServerChar == "&") || (lastServerChar == "?")) { if ((lastServerChar == "&") || (lastServerChar == "?")) {
requestString += paramsString; requestString += paramsString;
} else { } else {
if (this.url.indexOf('?') == -1) { if (url.indexOf('?') == -1) {
//serverPath has no ? -- add one //serverPath has no ? -- add one
requestString += '?' + paramsString; requestString += '?' + paramsString;
} else { } else {

View File

@@ -0,0 +1,161 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @fileoverview Image Layer
* @author Tim Schaub
*/
/**
* @class
*
* @requires OpenLayers/Layer.js
*/
OpenLayers.Layer.Image = OpenLayers.Class.create();
OpenLayers.Layer.Image.prototype =
OpenLayers.Class.inherit(OpenLayers.Layer, {
/** By default, Layer.Image will be a baselayer
*
* @type Boolean */
isBaseLayer: true,
/** @type String */
url: null,
/** @type OpenLayers.Bounds */
extent: null,
/** @type OpenLayers.Size */
size: null,
/** @type OpenLayers.Tile.Image */
tile: null,
/** The ratio of height/width represented by a single pixel in the graphic
*
* @type Float */
aspectRatio: null,
/**
* @constructor
*
* @param {String} name
* @param {String} url Relative or absolute path to the image
* @param {OpenLayers.Bounds} extent The extent represented by the image
* @param {OpenLayers.Size} size The size (in pixels) of the image
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, extent, size, options) {
this.url = url;
this.extent = extent;
this.size = size;
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
this.aspectRatio = (this.extent.getHeight() / this.size.h) /
(this.extent.getWidth() / this.size.w);
},
/**
*
*/
destroy: function() {
this.tile.destroy();
this.tile = null;
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.Image
* @type OpenLayers.Layer.Image
*/
clone: function(obj) {
if(obj == null) {
obj = new OpenLayers.Layer.Image(this.name,
this.url,
this.extent,
this.size,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
return obj;
},
/**
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
// If nothing to do with resolutions has been set, assume a single
// resolution determined by extent/size
if( this.options.maxResolution == null ) {
this.options.maxResolution = this.extent.getWidth() / this.size.w;
}
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
},
/** Create the tile for the image or resize it for the new resolution
*
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
var firstRendering = (this.tile == null);
if(zoomChanged || firstRendering) {
//determine new tile size
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() /
(this.map.getResolution() * this.aspectRatio);
var tileSize = new OpenLayers.Size(tileWidth, tileHeight);
//determine new position (upper left corner of new bounds)
var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top);
var ulPx = this.map.getLayerPxFromLonLat(ul);
if(firstRendering) {
//create the new tile
this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent,
this.url, tileSize);
} else {
//just resize the tile and set it's new position
this.tile.size = tileSize.clone();
this.tile.position = ulPx.clone();
}
this.tile.draw();
}
},
/**
* @param {String} newUrl
*/
setUrl: function(newUrl) {
this.url = newUrl;
this.draw();
},
/** The url we return is always the same (the image itself never changes)
* so we can ignore the bounds parameter (it will always be the same,
* anyways)
*
* @param {OpenLayers.Bounds} bounds
*/
getURL: function(bounds) {
return this.url;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Image"
});

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/Grid.js * @requires OpenLayers/Layer/Grid.js
*/ */
OpenLayers.Layer.KaMap = Class.create(); OpenLayers.Layer.KaMap = OpenLayers.Class.create();
OpenLayers.Layer.KaMap.prototype = OpenLayers.Layer.KaMap.prototype =
Object.extend( new OpenLayers.Layer.Grid(), { OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
/** KaMap Layer is always a base layer /** KaMap Layer is always a base layer
* *
@@ -31,7 +32,7 @@ OpenLayers.Layer.KaMap.prototype =
newArguments.push(name, url, params, options); 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 (params) {
OpenLayers.Util.applyDefaults( OpenLayers.Util.applyDefaults(
this.params, this.params,
this.DEFAULT_PARAMS this.DEFAULT_PARAMS

View File

@@ -0,0 +1,101 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
// @requires OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.MapServer = OpenLayers.Class.create();
OpenLayers.Layer.MapServer.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
/** @final @type hash */
DEFAULT_PARAMS: {
mode: "map",
map_imagetype: "png"
},
/**
* @constructor
*
* @param {str} name
* @param {str} url
* @param {hash} params
*/
initialize: function(name, url, params) {
var newArguments = new Array();
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) {
OpenLayers.Util.applyDefaults(
this.params,
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
},
/**
* @type Boolean
*/
isBaseLayer: function() {
return (this.params.TRANSPARENT != 'true');
},
/**
* @param {String} name
* @param {hash} params
*
* @returns A clone of this OpenLayers.Layer.MapServer, with the passed-in
* parameters merged in.
* @type OpenLayers.Layer.MapServer
*/
clone: function (name, params) {
var mergedParams = {};
OpenLayers.Util.extend(mergedParams, this.params);
OpenLayers.Util.extend(mergedParams, params);
var obj = new OpenLayers.Layer.MapServer(name, this.url, mergedParams);
obj.setTileSize(this.tileSize);
return obj;
},
/**
* addTile creates a tile, initializes it (via 'draw' in this case), and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
var url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds, url, this.tileSize);
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getURL: function (bounds) {
var url = this.getFullRequestString(
{mapext:bounds.toBBOX().replace(/,/g,"+"),
imgext:bounds.toBBOX().replace(/,/g,"+"),
map_size:this.tileSize.w+'+'+this.tileSize.h,
imgx: this.tileSize.w/2,
imgy: this.tileSize.h/2,
imgxy: this.tileSize.w+"+"+this.tileSize.h
});
return url;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MapServer"
});

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
*/ */
OpenLayers.Layer.Markers = Class.create(); OpenLayers.Layer.Markers = OpenLayers.Class.create();
OpenLayers.Layer.Markers.prototype = OpenLayers.Layer.Markers.prototype =
Object.extend( new OpenLayers.Layer(), { OpenLayers.Class.inherit( OpenLayers.Layer, {
/** Markers layer is never a base layer. /** Markers layer is never a base layer.
* *
@@ -45,9 +46,11 @@ OpenLayers.Layer.Markers.prototype =
/** /**
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged * @param {Boolean} zoomChanged
* @param {Boolean} minor * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
if (zoomChanged) { if (zoomChanged) {
this.redraw(); this.redraw();
} }
@@ -68,7 +71,7 @@ OpenLayers.Layer.Markers.prototype =
* @param {OpenLayers.Marker} marker * @param {OpenLayers.Marker} marker
*/ */
removeMarker: function(marker) { removeMarker: function(marker) {
this.markers.remove(marker); OpenLayers.Util.removeItem(this.markers, marker);
if ((marker.icon != null) && (marker.icon.imageDiv != null) && if ((marker.icon != null) && (marker.icon.imageDiv != null) &&
(marker.icon.imageDiv.parentNode == this.div) ) { (marker.icon.imageDiv.parentNode == this.div) ) {
this.div.removeChild(marker.icon.imageDiv); this.div.removeChild(marker.icon.imageDiv);

View File

@@ -1,338 +1,214 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/EventPane.js * @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
*/ */
OpenLayers.Layer.MultiMap = Class.create(); OpenLayers.Layer.MultiMap = OpenLayers.Class.create();
OpenLayers.Layer.MultiMap.prototype = OpenLayers.Layer.MultiMap.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), { OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type MMMap */
multimap: null,
/** @type int */ /** @final @type int */
minZoomLevel: 1, MIN_ZOOM_LEVEL: 1,
/** @type int */
maxZoomLevel: 17,
/** /** @final @type int */
MAX_ZOOM_LEVEL: 17,
/** Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*
* @final @type Array(float) */
RESOLUTIONS: [9, 1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
/** @type VEMapType */
type: null,
/**
* @constructor * @constructor
* *
* @param {String} name * @param {String} name
*/ */
initialize:function(name) { 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,
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; arguments);
}, },
/**
* @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() { loadMapObject:function() {
try { //crash proofing
try { this.mapObject = new MultimapViewer(this.div);
// create MMMap, hide nav controls } catch (e) { }
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. * @return String with information on why layer is broken, how to get
* * it working.
* @private * @type String
*
*/ */
loadWarningMessage:function() { getWarningHTML:function() {
this.div.style.backgroundColor = "darkblue";
var html = ""; var html = "";
html += "The MM Layer was unable to load correctly.<br>"; html += "The MM Layer was unable to load correctly.<br>";
html += "<br>"; html += "<br>";
html += "To get rid of this message, click on the MM Layer's " html += "To get rid of this message, select a new BaseLayer "
html += "tab in the layer switcher in the upper-right corner.<br>"; html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>"; html += "<br>";
html += "Most likely, this is because the MM library"; html += "Most likely, this is because the MM library";
html += " script was either not correctly included.<br>"; html += " script was either not correctly included.<br>";
html += "<br>"; html += "<br>";
html += "Demmlopers: For help getting this working correctly, "; html += "Demmlopers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/MultiMapLayer' " html += "<a href='http://trac.openlayers.org/wiki/MultiMap' "
html += "target='_blank'>"; html += "target='_blank'>";
html += "click here"; html += "click here";
html += "</a>"; 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); return html;
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 * *
* * MapObject Interface Controls *
* @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
// Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
*
* @param {Object} center MapObject LonLat format
* @param {int} zoom MapObject zoom format
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { setMapObjectCenter: function(center, zoom) {
var lonlat = null; this.mapObject.goToPosition(center, zoom);
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 the mapObject's current center in Map Object format
* * @type Object
* @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) { getMapObjectCenter: function() {
var viewPortPx = null; return this.mapObject.getCurrentPosition();
if (this.multimap != null) {
var mmLatLong = this.getMMLatLongFromOLLonLat(lonlat);
var pixel = this.multimap.geoPosToContainerPixels(mmLatLong);
viewPortPx = this.getOLPixelFromPixel(pixel);
}
return viewPortPx;
}, },
/**
/** * @returns the mapObject's current zoom, in Map Object format
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom lemml for a specified Bounds.
* If multimap is not loaded, returns null.
* @type int * @type int
*/ */
getZoomForExtent: function (bounds) { getMapObjectZoom: function() {
return this.mapObject.getZoomFactor();
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 // LonLat - Pixel Translation
//
/** /**
* @param {int} mmZoom * @param {Object} moPixel MapObject Pixel format
* *
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom * @returns MapObject LonLat translated from MapObject Pixel
* Returns null if null value is passed in * @type Object
* @type int
*/ */
getOLZoomFromMMZoom: function(mmZoom) { getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
if (mmZoom) return mmZoom - 1; moPixel.x = moPixel.x - (this.map.getSize().w/2);
return null; moPixel.y = moPixel.y - (this.map.getSize().h/2);
return this.mapObject.getMapPositionAt(moPixel);
}, },
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject Pixel translated from MapObject LonLat
* @type Object
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.geoPosToContainerPixels(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/** /**
* @param {int} olZoom * @param {Object} moLonLat MapObject LonLat format
* *
* @returns A MMZoom lemml, translated from the passed in olZoom * @returns Longitude of the given MapObject LonLat
* Returns null if null value is passed in * @type float
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lon;
},
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Latitude of the given MapObject LonLat
* @type float
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lat;
},
/**
* @param {int} lon float
* @param {int} lat float
*
* @returns MapObject LonLat built from lon and lat params
* @type Object
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
return new MMLatLon(lat, lon);
},
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int * @type int
*/ */
getMMZoomFromOLZoom: function(olZoom) { getXFromMapObjectPixel: function(moPixel) {
if (olZoom) return olZoom + 1; return moPixel.x;
return null;
}, },
// /**
// TRANSLATION: MMLatLong <-> LonLat * @param {Object} moPixel MapObject Pixel format
//
/**
* @param {MMLatLong} mmLatLong
* *
* @returns An OpenLayers.LonLat, translated from the passed in MMLatLong * @returns Y value of the MapObject Pixel
* Returns null if null value is passed in * @type int
* @type OpenLayers.LonLat
*/ */
getOLLonLatFromMMLatLong: function(mmLatLong) { getYFromMapObjectPixel: function(moPixel) {
var olLonLat = null; return moPixel.y;
if (mmLatLong != null) {
olLonLat = new OpenLayers.LonLat(mmLatLong.lon,
mmLatLong.lat);
}
return olLonLat;
}, },
/** /**
* @param {OpenLayers.LonLat} olLonLat * @param {int} x
* @param {int} y
* *
* @returns A MMLatLong, translated from the passed in OpenLayers.LonLat * @returns MapObject Pixel from x and y parameters
* Returns null if null value is passed in * @type Object
* @type MMLatLong
*/ */
getMMLatLongFromOLLonLat: function(olLonLat) { getMapObjectPixelFromXY: function(x, y) {
var mmLatLong = null; return new MMPoint(x, y);
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 */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MultiMap" CLASS_NAME: "OpenLayers.Layer.MultiMap"
}); });

112
lib/OpenLayers/Layer/TMS.js Normal file
View File

@@ -0,0 +1,112 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD licence.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer/Grid.js
*/
OpenLayers.Layer.TMS = OpenLayers.Class.create();
OpenLayers.Layer.TMS.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
reproject: false,
isBaseLayer: true,
tileOrigin: null,
/**
* @constructor
*
* @param {String} name
* @param {String} url
* @param {Object} params
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, options) {
var newArguments = new Array();
newArguments.push(name, url, {}, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
},
/**
*
*/
destroy: function() {
// for now, nothing special to do here.
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.TMS
* @type OpenLayers.Layer.TMS
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.TMS(this.name,
this.url,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
return obj;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns A string with the layer's url and parameters and also the
* passed-in bounds and appropriate tile size specified as
* parameters
* @type String
*/
getURL: function (bounds) {
var res = this.map.getResolution();
var x = (bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w);
var y = (bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h);
var z = this.map.getZoom();
return this.url + "1.0.0" + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
},
/**
* addTile creates a tile, initializes it, and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.Image
* @type OpenLayers.Tile.Image
*/
addTile:function(bounds,position) {
var url = this.getURL(bounds);
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
},
/** When the layer is added to a map, then we can fetch our origin
* (if we don't have one.)
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);
if (!this.tileOrigin) {
this.tileOrigin = new OpenLayers.LonLat(this.map.maxExtent.left,
this.map.maxExtent.bottom);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.TMS"
});

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/Markers.js * @requires OpenLayers/Layer/Markers.js
*/ */
OpenLayers.Layer.Text = Class.create(); OpenLayers.Layer.Text = OpenLayers.Class.create();
OpenLayers.Layer.Text.prototype = OpenLayers.Layer.Text.prototype =
Object.extend( new OpenLayers.Layer.Markers(), { OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
/** 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
@@ -48,7 +49,7 @@ OpenLayers.Layer.Text.prototype =
/** /**
* @param {?} ajaxRequest * @param {XMLHttpRequest} ajaxRequest
*/ */
parseData: function(ajaxRequest) { parseData: function(ajaxRequest) {
var text = ajaxRequest.responseText; var text = ajaxRequest.responseText;
@@ -145,7 +146,7 @@ OpenLayers.Layer.Text.prototype =
if (!sameMarkerClicked) { if (!sameMarkerClicked) {
this.layer.map.addPopup(this.createPopup()); this.layer.map.addPopup(this.createPopup());
} }
Event.stop(evt); OpenLayers.Event.stop(evt);
}, },
/** /**
@@ -155,14 +156,14 @@ OpenLayers.Layer.Text.prototype =
if (this.features != null) { if (this.features != null) {
while(this.features.length > 0) { while(this.features.length > 0) {
var feature = this.features[0]; var feature = this.features[0];
this.features.remove(feature); OpenLayers.Util.removeItem(this.features, feature);
feature.destroy(); feature.destroy();
} }
} }
}, },
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Text" CLASS_NAME: "OpenLayers.Layer.Text"
}); });

View File

@@ -1,77 +1,49 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/EventPane.js * @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
*/ */
OpenLayers.Layer.VirtualEarth = Class.create(); OpenLayers.Layer.VirtualEarth = OpenLayers.Class.create();
OpenLayers.Layer.VirtualEarth.prototype = OpenLayers.Layer.VirtualEarth.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), { OpenLayers.Layer.FixedZoomLevels, {
/** @type VEMap */
vemap: null,
/** @type int */ /** @final @type int */
minZoomLevel: 1, MIN_ZOOM_LEVEL: 1,
/** @final @type int */
MAX_ZOOM_LEVEL: 17,
/** @type int */ /** Hardcode these resolutions so that they are more closely
maxZoomLevel: 17, * tied with the standard wms projection
*
/** * @final @type Array(float) */
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
/** @type VEMapType */
type: null,
/**
* @constructor * @constructor
* *
* @param {String} name * @param {String} name
*/ */
initialize:function(name) { 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, OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments); 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 vemap
this.loadVEMap();
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} minor
*/
moveTo:function(bounds, zoomChanged, minor) {
if (this.vemap != null) {
var olCenter = this.map.getCenter();
var veCenter = this.getVELatLongFromOLLonLat(olCenter);
if (zoomChanged) {
var olZoom = this.map.getZoom();
var veZoom = this.getVEZoomFromOLZoom(olZoom);
this.vemap.SetCenterAndZoom(veCenter, veZoom);
} else {
this.vemap.PanToLatLong(veCenter);
}
}
},
/** /**
* *
*/ */
loadVEMap:function() { loadMapObject:function() {
// create div and set to same size as map // create div and set to same size as map
var veDiv = OpenLayers.Util.createDiv(this.name); var veDiv = OpenLayers.Util.createDiv(this.name);
@@ -80,279 +52,177 @@ OpenLayers.Layer.VirtualEarth.prototype =
veDiv.style.height = sz.h; veDiv.style.height = sz.h;
this.div.appendChild(veDiv); this.div.appendChild(veDiv);
try { try { // crash prevention
this.mapObject = new VEMap(this.name);
} catch (e) { }
// create VEMap, hide nav controls if (this.mapObject != null) {
this.vemap = new VEMap(this.name); try { // this is to catch a Mozilla bug without falling apart
} catch (e) { this.mapObject.LoadMap(null, null, this.type);
// do nothing this is to keep from crashing } catch (e) { }
// if the VE library was not loaded. this.mapObject.HideDashboard();
} }
if (this.vemap == null) {
this.loadWarningMessage();
} else {
try {
this.vemap.LoadMap();
} catch (e) {
// this is to catch a Mozilla bug without falling apart
}
this.vemap.HideDashboard();
}
}, },
/** If we can't load the vemap, then display an error message to the /**
* user and tell them where to go for help. * @return String with information on why layer is broken, how to get
* * it working.
* @private * @type String
*
*/ */
loadWarningMessage:function() { getWarningHTML:function() {
this.div.style.backgroundColor = "darkblue";
var html = ""; var html = "";
html += "The VE Layer was unable to load correctly.<br>"; html += "The VE Layer was unable to load correctly.<br>";
html += "<br>"; html += "<br>";
html += "To get rid of this message, click on the VE Layer's " html += "To get rid of this message, select a new BaseLayer "
html += "tab in the layer switcher in the upper-right corner.<br>"; html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>"; html += "<br>";
html += "Most likely, this is because the VE library"; html += "Most likely, this is because the VE library";
html += " script was either not correctly included.<br>"; html += " script was either not correctly included.<br>";
html += "<br>"; html += "<br>";
html += "Developers: For help getting this working correctly, "; html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/VirtualEarthLayer' " html += "<a href='http://trac.openlayers.org/wiki/VirtualEarth' "
html += "target='_blank'>"; html += "target='_blank'>";
html += "click here"; html += "click here";
html += "</a>"; 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); return html;
var topLeft = centerPx.add(-size.w/2, -size.h/2);
var div = OpenLayers.Util.createDiv("veWarning",
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 * *
* * MapObject Interface Controls *
* @returns An OpenLayers.LonLat which is the passed-in view port * *
* OpenLayers.Pixel, translated into lon/lat by VE ************************************/
* If vemap is not loaded, returns null.
* @type OpenLayers.LonLat
// Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
*
* @param {Object} center MapObject LonLat format
* @param {int} zoom MapObject zoom format
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { setMapObjectCenter: function(center, zoom) {
var lonlat = null; this.mapObject.SetCenterAndZoom(center, zoom);
if (this.vemap != null) {
var pixel = this.getPixelFromOLPixel(viewPortPx);
var zoom = this.vemap.GetZoomLevel();
var veLatLong = this.vemap.PixelToLatLong(pixel.x, pixel.y, zoom);
lonlat = this.getOLLonLatFromVELatLong(veLatLong);
}
return lonlat;
}, },
/** /**
* @param {OpenLayers.LonLat} lonlat * @returns the mapObject's current center in Map Object format
* * @type Object
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY VE
* If vemap is not loaded, returns null.
* @type OpenLayers.Pixel
*/ */
getViewPortPxFromLonLat: function (lonlat) { getMapObjectCenter: function() {
var viewPortPx = null; return this.mapObject.GetCenter();
if (this.vemap != null) {
var veLatLong = this.getVELatLongFromOLLonLat(lonlat);
var pixel = this.vemap.LatLongToPixel(veLatLong);
viewPortPx = this.getOLPixelFromPixel(pixel);
}
return viewPortPx;
}, },
/**
/** * @returns the mapObject's current zoom, in Map Object format
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom level for a specified Bounds.
* If vemap is not loaded, returns null.
* @type int * @type int
*/ */
getZoomForExtent: function (bounds) { getMapObjectZoom: function() {
return this.mapObject.GetZoomLevel();
var zoom = null;
if (this.vemap != 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 veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
//make sure zoom is within bounds
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromVEZoom(veZoom);
}
return zoom;
}, },
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom // LonLat - Pixel Translation
//
/** /**
* @param {int} veZoom * @param {Object} moPixel MapObject Pixel format
* *
* @returns An OpenLayers Zoom level, translated from the passed in veZoom * @returns MapObject LonLat translated from MapObject Pixel
* Returns null if null value is passed in * @type Object
* @type int
*/ */
getOLZoomFromVEZoom: function(veZoom) { getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
var zoom = null; return this.mapObject.PixelToLatLong(moPixel.x, moPixel.y);
if (veZoom != null) {
zoom = veZoom - this.minZoomLevel;
}
return zoom;
}, },
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject Pixel translated from MapObject LonLat
* @type Object
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.LatLongToPixel(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/** /**
* @param {int} olZoom * @param {Object} moLonLat MapObject LonLat format
* *
* @returns A VEZoom level, translated from the passed in olZoom * @returns Longitude of the given MapObject LonLat
* Returns null if null value is passed in * @type float
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.Longitude;
},
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Latitude of the given MapObject LonLat
* @type float
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.Latitude;
},
/**
* @param {int} lon float
* @param {int} lat float
*
* @returns MapObject LonLat built from lon and lat params
* @type Object
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
return new VELatLong(lat, lon);
},
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int * @type int
*/ */
getVEZoomFromOLZoom: function(olZoom) { getXFromMapObjectPixel: function(moPixel) {
var zoom = null; return moPixel.x;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
}
return zoom;
}, },
// /**
// TRANSLATION: VELatLong <-> LonLat * @param {Object} moPixel MapObject Pixel format
//
/**
* @param {VELatLong} veLatLong
* *
* @returns An OpenLayers.LonLat, translated from the passed in VELatLong * @returns Y value of the MapObject Pixel
* Returns null if null value is passed in * @type int
* @type OpenLayers.LonLat
*/ */
getOLLonLatFromVELatLong: function(veLatLong) { getYFromMapObjectPixel: function(moPixel) {
var olLonLat = null; return moPixel.y;
if (veLatLong != null) {
olLonLat = new OpenLayers.LonLat(veLatLong.Longitude,
veLatLong.Latitude);
}
return olLonLat;
}, },
/** /**
* @param {OpenLayers.LonLat} olLonLat * @param {int} x
* @param {int} y
* *
* @returns A VELatLong, translated from the passed in OpenLayers.LonLat * @returns MapObject Pixel from x and y parameters
* Returns null if null value is passed in * @type Object
* @type VELatLong
*/ */
getVELatLongFromOLLonLat: function(olLonLat) { getMapObjectPixelFromXY: function(x, y) {
var veLatLong = null; return new Msn.VE.Pixel(x, y);
if (olLonLat != null) {
veLatLong = new VELatLong(olLonLat.lat, olLonLat.lon);
}
return veLatLong;
}, },
//
// 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
* VE-compatible Pixel is an x & y property, which every
* OpenLayers.Pixel has by default. So just leave it as-is.
*
* @type Pixel
*/
getPixelFromOLPixel: function(olPixel) {
var pixel = null;
if (olPixel != null) {
pixel = new Msn.VE.Pixel(olPixel.x, olPixel.y);
}
return pixel;
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.VirtualEarth" CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
})); });

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,10 +9,10 @@
* @requires OpenLayers/Layer/Grid.js * @requires OpenLayers/Layer/Grid.js
* @requires OpenLayers/Layer/Markers.js * @requires OpenLayers/Layer/Markers.js
*/ */
OpenLayers.Layer.WFS = Class.create(); OpenLayers.Layer.WFS = OpenLayers.Class.create();
OpenLayers.Layer.WFS.prototype = OpenLayers.Layer.WFS.prototype =
Object.extend(new OpenLayers.Layer.Grid(), OpenLayers.Class.inherit( OpenLayers.Layer.Grid,
Object.extend(new OpenLayers.Layer.Markers(), { OpenLayers.Layer.Markers, {
/** WFS layer is never a base layer. /** WFS layer is never a base layer.
* *
@@ -52,26 +53,20 @@ OpenLayers.Layer.WFS.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params newArguments.push(name, options);
newArguments.push(name, options);
}
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) { OpenLayers.Util.applyDefaults(
OpenLayers.Util.applyDefaults( this.params,
this.params, OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) );
);
}
}, },
@@ -94,9 +89,9 @@ OpenLayers.Layer.WFS.prototype =
/** /**
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged * @param {Boolean} zoomChanged
* @param {Boolean} minor * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments); OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments); OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
}, },
@@ -227,6 +222,4 @@ OpenLayers.Layer.WFS.prototype =
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WFS" CLASS_NAME: "OpenLayers.Layer.WFS"
} });
)
);

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/Grid.js * @requires OpenLayers/Layer/Grid.js
*/ */
OpenLayers.Layer.WMS = Class.create(); OpenLayers.Layer.WMS = OpenLayers.Class.create();
OpenLayers.Layer.WMS.prototype = OpenLayers.Layer.WMS.prototype =
Object.extend( new OpenLayers.Layer.Grid(), { OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
/** Hashtable of default parameter key/value pairs /** Hashtable of default parameter key/value pairs
* @final @type Object */ * @final @type Object */
@@ -20,6 +21,8 @@ OpenLayers.Layer.WMS.prototype =
exceptions: "application/vnd.ogc.se_inimage", exceptions: "application/vnd.ogc.se_inimage",
format: "image/jpeg" format: "image/jpeg"
}, },
reproject: true,
/** /**
* @constructor * @constructor
@@ -31,23 +34,18 @@ OpenLayers.Layer.WMS.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
OpenLayers.Util.applyDefaults(
if (arguments.length > 0) { this.params,
OpenLayers.Util.applyDefaults( OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
this.params, );
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
// unless explicitly set in options, if the layer is transparent, // unless explicitly set in options, if the layer is transparent,
// it will be an overlay // it will be an overlay
if ((options == null) || !(options.isBaseLayer)) { 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));
} }

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,9 +9,9 @@
* @requires OpenLayers/Layer/HTTPRequest.js * @requires OpenLayers/Layer/HTTPRequest.js
* @requires OpenLayers/Layer/WMS.js * @requires OpenLayers/Layer/WMS.js
*/ */
OpenLayers.Layer.WMS.Untiled = Class.create(); OpenLayers.Layer.WMS.Untiled = OpenLayers.Class.create();
OpenLayers.Layer.WMS.Untiled.prototype = OpenLayers.Layer.WMS.Untiled.prototype =
Object.extend( new OpenLayers.Layer.HTTPRequest(), { OpenLayers.Class.inherit( OpenLayers.Layer.HTTPRequest, {
/** Hashtable of default parameter key/value pairs /** Hashtable of default parameter key/value pairs
* @final @type Object */ * @final @type Object */
@@ -21,9 +22,14 @@ OpenLayers.Layer.WMS.Untiled.prototype =
exceptions: "application/vnd.ogc.se_inimage", exceptions: "application/vnd.ogc.se_inimage",
format: "image/jpeg" format: "image/jpeg"
}, },
reproject: true,
/** @type DOMElement */ /** the ratio of image/tile size to map size (this is the untiled buffer)
imgDiv: null, * @type int */
ratio: 2,
/** @type OpenLayers.Tile.Image */
tile: null,
/** /**
@@ -35,20 +41,15 @@ OpenLayers.Layer.WMS.Untiled.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this, OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
newArguments); newArguments);
OpenLayers.Util.applyDefaults(
if (arguments.length > 0) { this.params,
OpenLayers.Util.applyDefaults( OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
this.params, );
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
// unless explicitly set in options, if the layer is transparent, // unless explicitly set in options, if the layer is transparent,
// it will be an overlay // it will be an overlay
@@ -62,7 +63,8 @@ OpenLayers.Layer.WMS.Untiled.prototype =
* *
*/ */
destroy: function() { destroy: function() {
this.imgDiv = null; this.tile.destroy();
this.tile = null;
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments); OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
}, },
@@ -96,72 +98,83 @@ OpenLayers.Layer.WMS.Untiled.prototype =
*/ */
setMap: function(map) { setMap: function(map) {
OpenLayers.Layer.HTTPRequest.prototype.setMap.apply(this, arguments); OpenLayers.Layer.HTTPRequest.prototype.setMap.apply(this, arguments);
this.loadImageDiv();
}, },
/** When it is not a minor move (ie when panning or when done dragging) /** When it is not a dragging move (ie when done dragging)
* reload and recenter the div. * reload and recenter the div.
* *
* @param {OpenLayers.Bounds} bounds * @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged * @param {Boolean} zoomChanged
* @param {Boolean} minor * @param {Boolean} dragging
*/ */
moveTo:function(bounds, zoomChanged, minor) { moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this,arguments);
if (!minor) {
if (bounds == null) { if (bounds == null) {
bounds = this.map.getExtent(); bounds = this.map.getExtent();
}
var firstRendering = (this.tile == null);
//does the new bounds to which we need to move fall outside of the
// current tile's bounds?
var outOfBounds = (!firstRendering &&
!this.tile.bounds.containsBounds(bounds));
if ( zoomChanged || firstRendering || (!dragging && outOfBounds) ) {
//clear out the old tile
if (this.tile) {
this.tile.clear();
} }
var size = this.map.getSize().clone();
// get the url //determine new tile bounds
var url = this.getFullRequestString( {BBOX: bounds.toBBOX(), var center = bounds.getCenterLonLat();
WIDTH: size.w, var tileWidth = bounds.getWidth() * this.ratio;
HEIGHT: size.h} ); var tileHeight = bounds.getHeight() * this.ratio;
var tileBounds =
new OpenLayers.Bounds(center.lon - (tileWidth / 2),
center.lat - (tileHeight / 2),
center.lon + (tileWidth / 2),
center.lat + (tileHeight / 2));
// always position at upper left corner of current viewspace //determine new tile size
var tl = new OpenLayers.Pixel(0,0); var tileSize = this.map.getSize();
var pos = this.map.getLayerPxFromViewPortPx(tl); tileSize.w = tileSize.w * this.ratio;
tileSize.h = tileSize.h * this.ratio;
// first hide before all modifications //formulate request url string
Element.hide(this.imgDiv); var url = this.getURL(tileBounds);
// update div //determine new position (upper left corner of new bounds)
var img = this.imgDiv; var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
if (this.params.TRANSPARENT == 'true') { var pos = this.map.getLayerPxFromLonLat(ul);
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, if ( this.tile && !this.tile.size.equals(tileSize)) {
pos, this.tile.destroy();
size, this.tile = null;
url); }
img = this.imgDiv.childNodes[0];
if (!this.tile) {
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
url, tileSize);
this.tile.draw();
} else { } else {
OpenLayers.Util.modifyDOMElement(this.imgDiv, this.tile.moveTo(tileBounds, pos);
null, }
pos,
size);
this.imgDiv.src = url;
}
// wait until image is done loading to show again
Event.observe(img,
"load",
this.showDiv.bindAsEventListener(this));
} }
}, },
/** Helper function that allows us to first hide the imgDiv, then make all getURL: function(bounds) {
* the changes (position, size, url). Then when the url is done loading, var tileSize = this.map.getSize();
* we call this function to show the imgDiv. tileSize.w = tileSize.w * this.ratio;
* tileSize.h = tileSize.h * this.ratio;
* @private return this.getFullRequestString( {'BBOX': bounds.toBBOX(),
*/ 'WIDTH': tileSize.w,
showDiv: function() { 'HEIGHT': tileSize.h} );
Element.show(this.imgDiv);
}, },
/** Once HTTPRequest has updated the url, reload the image div /** Once HTTPRequest has updated the url, reload the image div
* @param {String} newUrl * @param {String} newUrl
@@ -180,7 +193,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
newArguments); newArguments);
//redraw //redraw
this.moveTo(); this.moveTo(null, true);
}, },
/** combine the layer's url with its params and these newParams. /** combine the layer's url with its params and these newParams.
@@ -201,48 +214,6 @@ OpenLayers.Layer.WMS.Untiled.prototype =
this, arguments); this, arguments);
}, },
/** This function first removes the previous image div, then adds a new
* one according to the transparency property.
*
* @private
*/
loadImageDiv: function() {
var size = this.map.getSize().clone();
var bounds = this.map.getExtent();
var url = "";
if (bounds != null) {
url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
WIDTH: size.w,
HEIGHT: size.h} );
}
//clear previous wms image (removes imgDiv)
this.div.innerHTML = "";
//always position at upper left corner of current viewspace
var tl = new OpenLayers.Pixel(0,0);
var pos = this.map.getLayerPxFromViewPortPx(tl);
//create div
if (this.params.TRANSPARENT == 'true') {
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
pos,
size,
url,
"absolute");
} else {
this.imgDiv = OpenLayers.Util.createImage(null,
pos,
size,
url,
"absolute");
}
this.div.appendChild(this.imgDiv);
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WMS.Untiled" CLASS_NAME: "OpenLayers.Layer.WMS.Untiled"
}); });

View File

@@ -1,15 +1,16 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/Grid.js * @requires OpenLayers/Layer/Grid.js
*/ */
OpenLayers.Layer.WorldWind = Class.create(); OpenLayers.Layer.WorldWind = OpenLayers.Class.create();
OpenLayers.Layer.WorldWind.prototype = OpenLayers.Layer.WorldWind.prototype =
Object.extend( new OpenLayers.Layer.Grid(), { OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
DEFAULT_PARAMS: { DEFAULT_PARAMS: {
}, },
@@ -32,7 +33,7 @@ OpenLayers.Layer.WorldWind.prototype =
newArguments.push(name, url, params, options); 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 (params) {
OpenLayers.Util.applyDefaults( OpenLayers.Util.applyDefaults(
this.params, this.params,
this.DEFAULT_PARAMS this.DEFAULT_PARAMS
@@ -42,23 +43,20 @@ OpenLayers.Layer.WorldWind.prototype =
addTile:function(bounds,position) { addTile:function(bounds,position) {
if (this.map.getResolution() <= (this.lzd/512) if (this.map.getResolution() <= (this.lzd/512)
&& this.getZoom() <= this.zoomLevels) { && this.getZoom() <= this.zoomLevels) {
var url = this.getURL(bounds);
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 +69,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);
return this.getFullRequestString( if (this.map.getResolution() <= (this.lzd/512)
&& this.getZoom() <= this.zoomLevels) {
return this.getFullRequestString(
{ L: zoom, { L: zoom,
X: x, X: x,
Y: y Y: y
}); });
} else {
return OpenLayers.Util.getImagesLocation() + "blank.gif";
}
}, },

View File

@@ -1,209 +1,108 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
* *
* @requires OpenLayers/Layer/EventPane.js * @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
*/ */
OpenLayers.Layer.Yahoo = Class.create(); OpenLayers.Layer.Yahoo = OpenLayers.Class.create();
OpenLayers.Layer.Yahoo.prototype = OpenLayers.Layer.Yahoo.prototype =
Object.extend( new OpenLayers.Layer.EventPane(), { OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type YMap */
yahoomap: null,
/** @type int */ /** @final @type int */
minZoomLevel: 0, MIN_ZOOM_LEVEL: 0,
/** @type int */
maxZoomLevel: 15,
/** /** @final @type int */
MAX_ZOOM_LEVEL: 15,
/** Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*
* @final @type Array(float) */
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
/** @type YahooMapType */
type: null,
/**
* @constructor * @constructor
* *
* @param {String} name * @param {String} name
*/ */
initialize:function(name) { 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,
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; arguments);
}, },
/**
* @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 yahoomap
this.loadYMap();
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} minor
*/
moveTo:function(bounds, zoomChanged, minor) {
if (this.yahoomap != null) {
var olCenter = this.map.getCenter();
var mmCenter = this.getYLatLongFromOLLonLat(olCenter);
if (zoomChanged) {
var olZoom = this.map.getZoom();
var mmZoom = this.getYZoomFromOLZoom(olZoom);
this.yahoomap.setZoomLevel(mmZoom);
}
this.yahoomap.drawZoomAndCenter(mmCenter, mmZoom);
}
},
/** /**
* *
*/ */
loadYMap:function() { loadMapObject:function() {
this.yahoomap = new YMap(this.div); try { //do not crash!
this.mapObject = new YMap(this.div, this.type);
} catch(e) {}
},
/** Overridden from EventPane because we need to remove this yahoo event
* pane which prohibits our drag and drop, and we can only do this
* once the map has been loaded and centered.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
this.map.events.register("moveend", this, this.fixYahooEventPane);
if (this.yahoomap == null) {
this.loadWarningMessage();
}
}, },
/** If we can't load the yahoomap, then display an error message to the /** The map has been centered, so the mysterious yahoo eventpane has been
* user and tell them where to go for help. * added. we remove it so that it doesnt mess with *our* event pane.
* *
* @private * @private
*
*/ */
loadWarningMessage:function() { fixYahooEventPane: function() {
var yahooEventPane = $("ygddfdiv");
if (yahooEventPane != null) {
if (yahooEventPane.parentNode != null)
yahooEventPane.parentNode.removeChild(yahooEventPane);
this.div.style.backgroundColor = "darkblue"; this.map.events.unregister("moveend", this,
this.fixYahooEventPane);
}
},
/**
* @return String with information on why layer is broken, how to get
* it working.
* @type String
*/
getWarningHTML:function() {
var html = ""; var html = "";
html += "The Y Layer was unable to load correctly.<br>"; html += "The Yahoo Layer was unable to load correctly.<br>";
html += "<br>"; html += "<br>";
html += "To get rid of this message, click on the Y Layer's " html += "To get rid of this message, select a new BaseLayer "
html += "tab in the layer switcher in the upper-right corner.<br>"; html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>"; html += "<br>";
html += "Most likely, this is because the Y library"; html += "Most likely, this is because the Yahoo library";
html += " script was either not correctly included.<br>"; html += " script was either not correctly included.<br>";
html += "<br>"; html += "<br>";
html += "Demmlopers: For help getting this working correctly, "; html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/YahooLayer' " html += "<a href='http://trac.openlayers.org/wiki/Yahoo' "
html += "target='_blank'>"; html += "target='_blank'>";
html += "click here"; html += "click here";
html += "</a>"; 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); return html;
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 Y
* If yahoomap is not loaded, returns null.
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if (this.yahoomap != null) {
var pixel = this.getPixelFromOLPixel(viewPortPx);
var mmLatLong = this.yahoomap.convertXYLatLon(pixel);
lonlat = this.getOLLonLatFromYLatLong(mmLatLong);
}
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 */ /* Translation Functions */
@@ -213,107 +112,175 @@ OpenLayers.Layer.Yahoo.prototype =
/* */ /* */
/********************************************************/ /********************************************************/
// //
// TRANSLATION: GZoom <-> OpenLayers Zoom // TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
// //
/** /**
* @param {int} mmZoom * @param {int} gZoom
* *
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom * @returns An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in * Returns null if null value is passed in
* @type int * @type int
*/ */
getOLZoomFromYZoom: function(mmZoom) { getOLZoomFromMapObjectZoom: function(moZoom) {
return 18 - mmZoom; var zoom = null;
if (moZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
zoom = 18 - zoom;
}
return zoom;
}, },
/** /**
* @param {int} olZoom * @param {int} olZoom
* *
* @returns A YZoom lemml, translated from the passed in olZoom * @returns A MapObject level, translated from the passed in olZoom
* Returns null if null value is passed in * Returns null if null value is passed in
* @type int * @type int
*/ */
getYZoomFromOLZoom: function(olZoom) { getMapObjectZoomFromOLZoom: function(olZoom) {
return 18 - olZoom; var zoom = null;
if (olZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
zoom = 18 - zoom;
}
return zoom;
}, },
// /************************************
// TRANSLATION: YLatLong <-> LonLat * *
// * MapObject Interface Controls *
* *
************************************/
/**
* @param {YLatLong} mmLatLong // Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
* *
* @returns An OpenLayers.LonLat, translated from the passed in YLatLong * @param {Object} center MapObject LonLat format
* Returns null if null value is passed in * @param {int} zoom MapObject zoom format
* @type OpenLayers.LonLat
*/ */
getOLLonLatFromYLatLong: function(mmLatLong) { setMapObjectCenter: function(center, zoom) {
var olLonLat = null; this.mapObject.drawZoomAndCenter(center, zoom);
if (mmLatLong != null) { },
olLonLat = new OpenLayers.LonLat(mmLatLong.Lon,
mmLatLong.Lat); /**
} * @returns the mapObject's current center in Map Object format
return olLonLat; * @type Object
*/
getMapObjectCenter: function() {
return this.mapObject.getCenterLatLon();
},
/**
* @returns the mapObject's current zoom, in Map Object format
* @type int
*/
getMapObjectZoom: function() {
return this.mapObject.getZoomLevel();
},
// LonLat - Pixel Translation
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject LonLat translated from MapObject Pixel
* @type Object
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
return this.mapObject.convertXYLatLon(moPixel);
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject Pixel translated from MapObject LonLat
* @type Object
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.convertLatLonXY(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Longitude of the given MapObject LonLat
* @type float
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.Lon;
}, },
/** /**
* @param {OpenLayers.LonLat} olLonLat * @param {Object} moLonLat MapObject LonLat format
* *
* @returns A YLatLong, translated from the passed in OpenLayers.LonLat * @returns Latitude of the given MapObject LonLat
* Returns null if null value is passed in * @type float
* @type YLatLong
*/ */
getYLatLongFromOLLonLat: function(olLonLat) { getLatitudeFromMapObjectLonLat: function(moLonLat) {
var mmLatLong = null; return moLonLat.Lat;
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 * @param {int} lon float
* @param {int} lat float
* *
* @returns A Pixel, translated from the passed in OpenLayers.Pixel * @returns MapObject LonLat built from lon and lat params
* Returns null if null value is passed in * @type Object
*
* 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) { getMapObjectLonLatFromLonLat: function(lon, lat) {
var pixel = null; return new YGeoPoint(lat, lon);
if (olPixel != null) {
pixel = new YCoordPoint(olPixel.x, olPixel.y);
}
return pixel;
}, },
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns Y value of the MapObject Pixel
* @type int
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {int} x
* @param {int} y
*
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getMapObjectPixelFromXY: function(x, y) {
return new YCoordPoint(x, y);
},
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Yahoo" CLASS_NAME: "OpenLayers.Layer.Yahoo"
}); });

View File

@@ -1,6 +1,7 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
@@ -8,7 +9,7 @@
* @requires OpenLayers/Util.js * @requires OpenLayers/Util.js
* @requires OpenLayers/Events.js * @requires OpenLayers/Events.js
*/ */
OpenLayers.Map = Class.create(); OpenLayers.Map = OpenLayers.Class.create();
OpenLayers.Map.TILE_WIDTH = 256; OpenLayers.Map.TILE_WIDTH = 256;
OpenLayers.Map.TILE_HEIGHT = 256; OpenLayers.Map.TILE_HEIGHT = 256;
OpenLayers.Map.prototype = { OpenLayers.Map.prototype = {
@@ -111,6 +112,8 @@ OpenLayers.Map.prototype = {
/** @type int */ /** @type int */
numZoomLevels: 16, numZoomLevels: 16,
/** @type string */
theme: null,
/** /**
* @constructor * @constructor
@@ -129,6 +132,7 @@ OpenLayers.Map.prototype = {
"hidden"); "hidden");
this.viewPortDiv.style.width = "100%"; this.viewPortDiv.style.width = "100%";
this.viewPortDiv.style.height = "100%"; this.viewPortDiv.style.height = "100%";
this.viewPortDiv.className = "olMapViewport";
this.div.appendChild(this.viewPortDiv); this.div.appendChild(this.viewPortDiv);
// the layerContainerDiv is the one that holds all the layers // the layerContainerDiv is the one that holds all the layers
@@ -152,18 +156,30 @@ OpenLayers.Map.prototype = {
// Else updateSize on catching the window's resize // Else updateSize on catching the window's resize
// Note that this is ok, as updateSize() does nothing if the // Note that this is ok, as updateSize() does nothing if the
// map's size has not actually changed. // map's size has not actually changed.
Event.observe(window, 'resize', OpenLayers.Event.observe(window, 'resize',
this.updateSize.bindAsEventListener(this)); this.updateSize.bindAsEventListener(this));
} }
//set the default options //set the default options
this.setOptions(options); this.setOptions(options);
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
cssNode.setAttribute('href', this.theme);
document.getElementsByTagName('head')[0].appendChild(cssNode);
this.layers = []; this.layers = [];
if (this.controls == null) { if (this.controls == null) {
this.controls = [ new OpenLayers.Control.MouseDefaults(), if (OpenLayers.Control != null) { // running full or lite?
new OpenLayers.Control.PanZoom()]; this.controls = [ new OpenLayers.Control.MouseDefaults(),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.ArgParser()
];
} else {
this.controls = [];
}
} }
for(var i=0; i < this.controls.length; i++) { for(var i=0; i < this.controls.length; i++) {
@@ -173,7 +189,7 @@ OpenLayers.Map.prototype = {
this.popups = new Array(); this.popups = new Array();
// always call map.destroy() // always call map.destroy()
Event.observe(window, OpenLayers.Event.observe(window,
'unload', 'unload',
this.destroy.bindAsEventListener(this)); this.destroy.bindAsEventListener(this));
@@ -211,9 +227,12 @@ OpenLayers.Map.prototype = {
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
this.theme = OpenLayers._getScriptLocation() +
'theme/default/style.css';
// 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); OpenLayers.Util.extend(this, options);
}, },
/** /**
@@ -251,14 +270,23 @@ OpenLayers.Map.prototype = {
return foundLayer; return foundLayer;
}, },
/**
* @param {OpenLayers.Layer} layer
* @param {int} zIdx
* @private
*/
setLayerZIndex: function (layer, zIdx) {
layer.setZIndex(
this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay']
+ zIdx * 5 );
},
/** /**
* @param {OpenLayers.Layer} layer * @param {OpenLayers.Layer} layer
*/ */
addLayer: function (layer) { addLayer: function (layer) {
layer.div.style.overflow = ""; layer.div.style.overflow = "";
layer.div.style.zIndex = this.setLayerZIndex(layer, this.layers.length);
this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay']
+ this.layers.length * 5;
if (layer.isFixed) { if (layer.isFixed) {
this.viewPortDiv.appendChild(layer.div); this.viewPortDiv.appendChild(layer.div);
@@ -268,23 +296,20 @@ OpenLayers.Map.prototype = {
this.layers.push(layer); this.layers.push(layer);
layer.setMap(this); layer.setMap(this);
this.events.triggerEvent("addlayer"); if (layer.isBaseLayer) {
//make sure layer draws itself!
if (this.center != null) {
var bounds = this.getExtent();
layer.moveTo(bounds, true);
}
if (layer.isBaseLayer) {
// set the first baselaye we add as the baselayer
if (this.baseLayer == null) { if (this.baseLayer == null) {
// set the first baselaye we add as the baselayer
this.setBaseLayer(layer); this.setBaseLayer(layer);
this.events.triggerEvent("changebaselayer");
} else { } else {
layer.setVisibility(false); layer.setVisibility(false);
} }
} else {
if (this.getCenter() != null) {
layer.moveTo(this.getExtent(), true);
}
} }
this.events.triggerEvent("addlayer");
}, },
/** /**
@@ -327,7 +352,7 @@ OpenLayers.Map.prototype = {
this.layerContainerDiv.removeChild(layer.div); this.layerContainerDiv.removeChild(layer.div);
} }
layer.map = null; layer.map = null;
this.layers.remove(layer); OpenLayers.Util.removeItem(this.layers, layer);
// if we removed the base layer, need to set a new one // if we removed the base layer, need to set a new one
if (this.baseLayer == layer) { if (this.baseLayer == layer) {
@@ -342,6 +367,62 @@ OpenLayers.Map.prototype = {
} }
this.events.triggerEvent("removelayer"); this.events.triggerEvent("removelayer");
}, },
/**
* @returns The number of layers attached to the map.
* @type int
*/
getNumLayers: function () {
return this.layers.length;
},
/**
* @returns The current (zero-based) index of the given layer in the map's
* layer stack. Returns -1 if the layer isn't on the map.
*
* @param {OpenLayers.Layer} layer
* @type int
*/
getLayerIndex: function (layer) {
return OpenLayers.Util.indexOf(this.layers, layer);
},
/** Move the given layer to the specified (zero-based) index in the layer
* list, changing its z-index in the map display. Use
* map.getLayerIndex() to find out the current index of a layer. Note
* that this cannot (or at least should not) be effectively used to
* raise base layers above overlays.
*
* @param {OpenLayers.Layer} layer
* @param {int} idx
*/
setLayerIndex: function (layer, idx) {
var base = this.getLayerIndex(layer);
if (idx < 0)
idx = 0;
else if (idx > this.layers.length)
idx = this.layers.length;
if (base != idx) {
this.layers.splice(base, 1);
this.layers.splice(idx, 0, layer);
for (var i = 0; i < this.layers.length; i++)
this.setLayerZIndex(this.layers[i], i);
this.events.triggerEvent("changelayer");
}
},
/** Change the index of the given layer by delta. If delta is positive,
* the layer is moved up the map's layer stack; if delta is negative,
* the layer is moved down. Again, note that this cannot (or at least
* should not) be effectively used to raise base layers above overlays.
*
* @param {OpenLayers.Layer} layer
* @param {int} idx
*/
raiseLayer: function (layer, delta) {
var idx = this.getLayerIndex(layer) + delta;
this.setLayerIndex(layer, idx);
},
/** Allows user to specify one of the currently-loaded layers as the Map's /** Allows user to specify one of the currently-loaded layers as the Map's
* new base layer. * new base layer.
@@ -350,12 +431,15 @@ OpenLayers.Map.prototype = {
* @param {Boolean} noEvent * @param {Boolean} noEvent
*/ */
setBaseLayer: function(newBaseLayer, noEvent) { setBaseLayer: function(newBaseLayer, noEvent) {
var oldExtent = null;
if(this.baseLayer) {
oldExtent = this.baseLayer.getExtent();
}
if (newBaseLayer != this.baseLayer) { if (newBaseLayer != this.baseLayer) {
// is newBaseLayer an already loaded layer? // is newBaseLayer an already loaded layer?
var foundLayer = (this.layers.indexOf(newBaseLayer) != -1); if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
if (foundLayer) {
// make the old base layer invisible // make the old base layer invisible
if (this.baseLayer != null) { if (this.baseLayer != null) {
@@ -369,14 +453,13 @@ OpenLayers.Map.prototype = {
//redraw all layers //redraw all layers
var center = this.getCenter(); var center = this.getCenter();
if (center != null) { if (center != null) {
var zoom = this.getZoom(); if (oldExtent == null) {
this.zoom = null; this.setCenter(center);
if (zoom > this.baseLayer.numZoomLevels - 1) { } else {
zoom = this.baseLayer.numZoomLevels - 1; this.zoomToExtent(oldExtent);
} }
this.setCenter(center, zoom);
} }
if ((noEvent == null) || (noEvent == false)) { if ((noEvent == null) || (noEvent == false)) {
this.events.triggerEvent("changebaselayer"); this.events.triggerEvent("changebaselayer");
} }
@@ -400,12 +483,17 @@ OpenLayers.Map.prototype = {
* @param {OpenLayers.Pixel} px * @param {OpenLayers.Pixel} px
*/ */
addControlToMap: function (control, px) { addControlToMap: function (control, px) {
// If a control doesn't have a div at this point, it belongs in the
// viewport.
control.outsideViewport = (control.div != null);
control.setMap(this); control.setMap(this);
var div = control.draw(px); var div = control.draw(px);
if (div) { if (div) {
div.style.zIndex = this.Z_INDEX_BASE['Control'] + if(!control.outsideViewport) {
this.controls.length; div.style.zIndex = this.Z_INDEX_BASE['Control'] +
this.viewPortDiv.appendChild( div ); this.controls.length;
this.viewPortDiv.appendChild( div );
}
} }
}, },
@@ -436,9 +524,11 @@ OpenLayers.Map.prototype = {
* @param {OpenLayers.Popup} popup * @param {OpenLayers.Popup} popup
*/ */
removePopup: function(popup) { removePopup: function(popup) {
this.popups.remove(popup); OpenLayers.Util.removeItem(this.popups, 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;
}, },
@@ -453,10 +543,20 @@ OpenLayers.Map.prototype = {
/********************************************************/ /********************************************************/
/** /**
* @returns {OpenLayers.Size} * @returns An OpenLayers.Size object that represents the size, in pixels,
* of the div into which OpenLayers has been loaded.
*
* Note: A clone() of this locally cached variable is returned, so
* as not to allow users to modify it.
*
* @type OpenLayers.Size
*/ */
getSize: function () { getSize: function () {
return this.size; var size = null;
if (this.size != null) {
size = this.size.clone();
}
return size;
}, },
/** /**
@@ -475,17 +575,20 @@ OpenLayers.Map.prototype = {
for(var i=0; i < this.layers.length; i++) { for(var i=0; i < this.layers.length; i++) {
this.layers[i].onMapResize(); this.layers[i].onMapResize();
} }
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
var zoom = this.getZoom();
this.zoom = null;
this.setCenter(center, zoom);
// 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);
}
} }
}, },
@@ -502,7 +605,7 @@ OpenLayers.Map.prototype = {
// Workaround for the fact that hidden elements return 0 for size. // Workaround for the fact that hidden elements return 0 for size.
if (size.w == 0 && size.h == 0) { if (size.w == 0 && size.h == 0) {
var dim = Element.getDimensions(this.div); var dim = OpenLayers.Element.getDimensions(this.div);
size.w = dim.width; size.w = dim.width;
size.h = dim.height; size.h = dim.height;
} }
@@ -513,6 +616,41 @@ OpenLayers.Map.prototype = {
return size; return size;
}, },
/**
* @param {OpenLayers.LonLat} center Default is this.getCenter()
* @param {float} resolution Default is this.getResolution()
*
* @returns A Bounds based on resolution, center, and current mapsize.
* @type OpenLayers.Bounds
*/
calculateBounds: function(center, resolution) {
var extent = null;
if (center == null) {
center = this.getCenter();
}
if (resolution == null) {
resolution = this.getResolution();
}
if ((center != null) && (resolution != null)) {
var size = this.getSize();
var w_deg = size.w * resolution;
var h_deg = size.h * resolution;
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;
},
/********************************************************/ /********************************************************/
/* */ /* */
/* Zoom, Center, Pan Functions */ /* Zoom, Center, Pan Functions */
@@ -561,10 +699,15 @@ OpenLayers.Map.prototype = {
/** /**
* @param {OpenLayers.LonLat} lonlat * @param {OpenLayers.LonLat} lonlat
* @param {int} zoom * @param {int} zoom
* @param {Boolean} minor Specifies whether or not to * @param {Boolean} dragging Specifies whether or not to
* trigger movestart/end events * trigger movestart/end events
*/ */
setCenter: function (lonlat, zoom, minor) { setCenter: function (lonlat, zoom, dragging) {
if (!this.center && !this.isValidLonLat(lonlat)) {
lonlat = this.maxExtent.getCenterLonLat();
}
var zoomChanged = (this.isValidZoomLevel(zoom)) && var zoomChanged = (this.isValidZoomLevel(zoom)) &&
(zoom != this.getZoom()); (zoom != this.getZoom());
@@ -573,9 +716,9 @@ OpenLayers.Map.prototype = {
// if neither center nor zoom will change, no need to do anything // if neither center nor zoom will change, no need to do anything
if (zoomChanged || centerChanged || !minor) { if (zoomChanged || centerChanged || !dragging) {
if (!minor) { this.events.triggerEvent("movestart"); } if (!dragging) { this.events.triggerEvent("movestart"); }
if (centerChanged) { if (centerChanged) {
if ((!zoomChanged) && (this.center)) { if ((!zoomChanged) && (this.center)) {
@@ -602,13 +745,33 @@ OpenLayers.Map.prototype = {
} }
} }
//send the move call to the baselayer and all the overlays
var bounds = this.getExtent(); var bounds = this.getExtent();
//send the move call to the baselayer and all the overlays
this.baseLayer.moveTo(bounds, zoomChanged, dragging);
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.getVisibility()) { if (!layer.isBaseLayer) {
layer.moveTo(bounds, zoomChanged, minor);
} var moveLayer;
var inRange = layer.calculateInRange();
if (layer.inRange != inRange) {
// Layer property has changed. We are going
// to call moveLayer so that the layer can be turned
// off or on.
layer.inRange = inRange;
moveLayer = true;
this.events.triggerEvent("changelayer");
} else {
// If nothing has changed, then we only move the layer
// if it is visible and inrange.
moveLayer = (layer.visibility && layer.inRange);
}
if (moveLayer) {
layer.moveTo(bounds, zoomChanged, dragging);
}
}
} }
this.events.triggerEvent("move"); this.events.triggerEvent("move");
@@ -617,7 +780,7 @@ OpenLayers.Map.prototype = {
} }
// even if nothing was done, we want to notify of this // even if nothing was done, we want to notify of this
if (!minor) { this.events.triggerEvent("moveend"); } if (!dragging) { this.events.triggerEvent("moveend"); }
}, },
/** This function takes care to recenter the layerContainerDiv /** This function takes care to recenter the layerContainerDiv
@@ -631,8 +794,10 @@ OpenLayers.Map.prototype = {
var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin); var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin);
var newPx = this.getViewPortPxFromLonLat(lonlat); var newPx = this.getViewPortPxFromLonLat(lonlat);
this.layerContainerDiv.style.left = (originPx.x - newPx.x) + "px"; if ((originPx != null) && (newPx != null)) {
this.layerContainerDiv.style.top = (originPx.y - newPx.y) + "px"; this.layerContainerDiv.style.left = (originPx.x - newPx.x) + "px";
this.layerContainerDiv.style.top = (originPx.y - newPx.y) + "px";
}
}, },
/** /**
@@ -664,7 +829,7 @@ OpenLayers.Map.prototype = {
var valid = false; var valid = false;
if (lonlat != null) { if (lonlat != null) {
var maxExtent = this.getMaxExtent(); var maxExtent = this.getMaxExtent();
valid = maxExtent.contains(lonlat.lon, lonlat.lat); valid = maxExtent.containsLonLat(lonlat);
} }
return valid; return valid;
}, },
@@ -773,8 +938,7 @@ OpenLayers.Map.prototype = {
if (this.baseLayer != null) { if (this.baseLayer != null) {
var res = this.getResolution(); var res = this.getResolution();
var units = this.baseLayer.units; var units = this.baseLayer.units;
scale = res * OpenLayers.INCHES_PER_UNIT[units] * scale = OpenLayers.Util.getScaleFromResolution(res, units);
OpenLayers.DOTS_PER_INCH;
} }
return scale; return scale;
}, },
@@ -992,11 +1156,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

@@ -1,11 +1,12 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license. /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* text of the license. */ * for the full text of the license. */
/** /**
* @class * @class
*/ */
OpenLayers.Marker = Class.create(); OpenLayers.Marker = OpenLayers.Class.create();
OpenLayers.Marker.prototype = { OpenLayers.Marker.prototype = {
/** @type OpenLayers.Icon */ /** @type OpenLayers.Icon */
@@ -28,11 +29,18 @@ OpenLayers.Marker.prototype = {
* @param {OpenLayers.LonLat lonlat * @param {OpenLayers.LonLat lonlat
*/ */
initialize: function(lonlat, icon) { initialize: function(lonlat, icon) {
if (arguments.length > 0) { this.lonlat = lonlat;
this.lonlat = lonlat;
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); 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);
}, },
destroy: function() { destroy: function() {
@@ -73,7 +81,7 @@ OpenLayers.Marker.prototype = {
var onScreen = false; var onScreen = false;
if (this.map) { if (this.map) {
var screenBounds = this.map.getExtent(); var screenBounds = this.map.getExtent();
onScreen = screenBounds.contains(this.lonlat.lon, this.lonlat.lat); onScreen = screenBounds.containsLonLat(this.lonlat);
} }
return onScreen; return onScreen;
}, },
@@ -89,6 +97,15 @@ OpenLayers.Marker.prototype = {
} }
}, },
/** Change the opacity of the marker by changin the opacity of
* its icon
*
* @param {float} opacity Specified as fraction (0.4, etc)
*/
setOpacity: function(opacity) {
this.icon.setOpacity(opacity);
},
/** Hide or show the icon /** Hide or show the icon
* *
* @param {Boolean} display * @param {Boolean} display

Some files were not shown because too many files have changed in this diff Show More