Compare commits
80 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48445f0878 | ||
|
|
a0cd93cb41 | ||
|
|
0a01ef899e | ||
|
|
5987d5ea33 | ||
|
|
b5153746f6 | ||
|
|
fb663b5127 | ||
|
|
1f9cb14069 | ||
|
|
6fe0826a54 | ||
|
|
e61545167d | ||
|
|
d564f2da47 | ||
|
|
5320cd290c | ||
|
|
a50b175b66 | ||
|
|
739b821570 | ||
|
|
82f786c630 | ||
|
|
eb783aab37 | ||
|
|
a668730ec1 | ||
|
|
3aca63eabe | ||
|
|
7ca9d2ec83 | ||
|
|
0500b9cba2 | ||
|
|
581df4e5f1 | ||
|
|
a7da80c24b | ||
|
|
00dfc669d2 | ||
|
|
2ed1ce98b3 | ||
|
|
9f0b0e0ed7 | ||
|
|
f6a50a37fc | ||
|
|
deaebf8733 | ||
|
|
a6ff5584ad | ||
|
|
402021f24f | ||
|
|
abfbe30b2b | ||
|
|
a98ee2580d | ||
|
|
426e1cf2f9 | ||
|
|
e31c7aaf0b | ||
|
|
6e9ba61679 | ||
|
|
6ddeb07e90 | ||
|
|
2408752e27 | ||
|
|
39536e788a | ||
|
|
e2378ad68a | ||
|
|
44819f20e8 | ||
|
|
6a2fa9aaf1 | ||
|
|
ea9a6a6a23 | ||
|
|
4847d66d6a | ||
|
|
c4541115f9 | ||
|
|
d500981f09 | ||
|
|
8e51ada8de | ||
|
|
633e31da36 | ||
|
|
c1779d1520 | ||
|
|
29d6d8f017 | ||
|
|
f56dab0644 | ||
|
|
2ec05163ed | ||
|
|
1e8c8e8404 | ||
|
|
cd21f42dab | ||
|
|
1459ac5de9 | ||
|
|
484fc207cf | ||
|
|
cfd7858861 | ||
|
|
17581c714d | ||
|
|
1a12d90455 | ||
|
|
7035551fcf | ||
|
|
b11580aca3 | ||
|
|
b8f4577a78 | ||
|
|
4df6b8aa2b | ||
|
|
d2601b3684 | ||
|
|
1a0cbdfd25 | ||
|
|
9956bffe71 | ||
|
|
24047ee512 | ||
|
|
07d39aca00 | ||
|
|
7ae04f7423 | ||
|
|
d8d2b225e4 | ||
|
|
5952a7e3af | ||
|
|
8d1fe36b0f | ||
|
|
fa3b3a3d0c | ||
|
|
36ec579e39 | ||
|
|
b1cfe16347 | ||
|
|
9d3aea6a2f | ||
|
|
a90c976375 | ||
|
|
08981babaa | ||
|
|
3623889f3a | ||
|
|
1bb0952c68 | ||
|
|
d28f293cd9 | ||
|
|
5ffbe842c2 | ||
|
|
0da9f792c7 |
@@ -2,9 +2,18 @@
|
||||
|
||||
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"
|
||||
echo "<html><head><title>OpenLayers Class Reference Documentation</title><style type='text/css'> .type { background-color: #ddd } td { border: black solid 1px; padding: 3px; } table { border-collapse: collapse; margin: 5px 10px; } .classref { margin-left: 20px; }
|
||||
div.index { float:left; width: 300px; }
|
||||
</style></head><body>" >> ../doc/reference.html
|
||||
echo "<html>
|
||||
<head>
|
||||
<title>OpenLayers Class Reference Documentation</title>
|
||||
<style type='text/css'>
|
||||
.type { background-color: #ddd }
|
||||
td { border: black solid 1px; padding: 3px; }
|
||||
table { border-collapse: collapse; margin: 5px 10px; }
|
||||
.classref { margin-left: 20px; }
|
||||
div.index { float:left; width: 300px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>" >> ../doc/reference.html
|
||||
|
||||
for i in $CLASSES; do
|
||||
echo "<div class='index'><a href='#OpenLayers.$i'>OpenLayers.$i</a></div>" >> ../doc/reference.html
|
||||
@@ -14,16 +23,17 @@ echo "<br style='clear:both' />" >> ../doc/reference.html
|
||||
|
||||
for i in $CLASSES; do
|
||||
cat ../doc/$i.txt | \
|
||||
perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g' | \
|
||||
perl -pe 's!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g' | \
|
||||
perl -pe 's!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!' | \
|
||||
perl -pe 's!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g' | \
|
||||
perl -pe 's!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!' | \
|
||||
perl -pe 's!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g' | \
|
||||
perl -pe 's!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g' | \
|
||||
perl -pe 's!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!' | \
|
||||
perl -pe 's!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \
|
||||
perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g;
|
||||
s!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g;
|
||||
s!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!;
|
||||
s!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g;
|
||||
s!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!;
|
||||
s!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g;
|
||||
s!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g;
|
||||
s!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!;
|
||||
s!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \
|
||||
>> ../doc/reference.html
|
||||
echo '</table></div>' >> ../doc/reference.html
|
||||
done
|
||||
echo "</body></html>" >> ../doc/reference.html
|
||||
echo " </body>
|
||||
</html>" >> ../doc/reference.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
OpenLayers.Control.Permalink
|
||||
|
||||
A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map,
|
||||
A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map. This control must be added to the map after a baselayer has been set.
|
||||
|
||||
* Constructor
|
||||
OpenLayers.Control.Scale({DOMElement|element}?, {String|base}) -- Creates a new permalink control. The DOMElement is used, if passed, as the element on which the 'href' is set. If you prefer to put this link on an element outside of the map, set this element to an anchor element to have its href updated when the map moves. If you wish to make the link go to some other URL (for example, an editing interface rather than the current URL), the 'base' property can be used, to which the ?lat=&lon=&zoom= will be appended after the map has moved.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
OpenLayers.Layer.GeoRSS
|
||||
|
||||
GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map.
|
||||
GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map. The GeoRSS layer supports 1.0 and 2.0 in IE and Firefox, and supports 2.0 in Safari. (Ticket #111 explains the reason for this difference.)
|
||||
|
||||
|
||||
* Constructor
|
||||
OpenLayers.Layer.GeoRSS(name, url) -- Name and location of GeoRSS XML file.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
OpenLayers.Layer.WMS
|
||||
|
||||
The WMS layer allows one to connect to a WMS server to obtain images.
|
||||
The WMS layer allows one to connect to a WMS server to obtain images. Params are available as a hash on the layer object, however, all keys are upper-cased automatically for maximum compatibility with WMS servers, so a parameter which is set as 'layers' will be uppercased to LAYERS. Where 'layer' is your Javscript variable for the layer, layer.params.LAYERS is the value of the layers param as set by the constructor.
|
||||
|
||||
If you wish to change params, you should use mergeNewParams, rather than accessing the parameters directly.
|
||||
|
||||
* Constructor
|
||||
OpenLayers.Layer.WMS(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer.
|
||||
@@ -9,5 +11,5 @@ The WMS layer allows one to connect to a WMS server to obtain images.
|
||||
getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a WMS URL for the given bounds based on the properties of the layer.
|
||||
All other methods are inherited from {OpenLayers.Layer.Grid}
|
||||
|
||||
* Parameters
|
||||
* Options
|
||||
isBaseLayer -- WMS layers default to being base layers unless one of their parameters is 'transparent':'true'.
|
||||
|
||||
@@ -23,20 +23,23 @@
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map') );
|
||||
map = new OpenLayers.Map( $('map') ,
|
||||
{ controls: [new OpenLayers.Control.MouseDefaults()] });
|
||||
|
||||
var normal = new OpenLayers.Layer.Google( "Google" );
|
||||
var normal = new OpenLayers.Layer.Google( "Google", // );
|
||||
{ minZoomLevel: 3, maxZoomLevel: 8 });
|
||||
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP });
|
||||
var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
|
||||
|
||||
|
||||
map.addLayers([normal, satellite, hybrid]);
|
||||
map.addLayers([satellite, normal, hybrid]);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
map.addControl( new OpenLayers.Control.PanZoomBar() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
{layers: 'basic'} );
|
||||
|
||||
var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite",
|
||||
"/world/index.php", {g: "satellite", map: "world"});
|
||||
"http://www.openlayers.org/world/index.php", {g: "satellite", map: "world"});
|
||||
var dm_wms = new OpenLayers.Layer.WMS( "Canada",
|
||||
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
|
||||
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
|
||||
|
||||
29
examples/setextent.html
Normal file
29
examples/setextent.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Setting a visual Extent</title>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Setting a Visual Extent</h1>
|
||||
<p>
|
||||
Because the ability to set the map to a given extent is limited by the
|
||||
current resolutions available, zoomToExtent will not always set the map to
|
||||
exactly the right extent. In order to visually annotate the actual extent,
|
||||
this example, will use the Boxes layer to visually describe the desired
|
||||
extent as well as setting the map extent.
|
||||
</p>
|
||||
<div style="width:100%; height:75%" id="map"></div>
|
||||
<script defer="defer" type="text/javascript">
|
||||
var map = new OpenLayers.Map('map');
|
||||
var bounds = new OpenLayers.Bounds(-45,-45, 0, 45);
|
||||
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||
map.addLayer(wms);
|
||||
map.zoomToExtent(bounds);
|
||||
var boxes = new OpenLayers.Layer.Boxes("boxes");
|
||||
var box = new OpenLayers.Marker.Box(bounds);
|
||||
boxes.addMarker(box);
|
||||
map.addLayer(boxes);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
90
examples/test.html
Normal file
90
examples/test.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<html>
|
||||
|
||||
<script src="../lib/Prototype.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var one, two, div, msg;
|
||||
|
||||
function init() {
|
||||
|
||||
one = $("one");
|
||||
two = $("two");
|
||||
div = $("div");
|
||||
msg = $("msg");
|
||||
|
||||
Event.observe(div, "click", bar);
|
||||
|
||||
one.checked = true;
|
||||
two.checked = false;
|
||||
|
||||
Event.observe(one, "change", oneClick);
|
||||
Event.observe(two, "change", twoClick);
|
||||
|
||||
}
|
||||
|
||||
function bar(e) {
|
||||
message("clicked div");
|
||||
|
||||
Event.stop(e);
|
||||
|
||||
var status = "one: ";
|
||||
status += (one.checked) ? "checked" : "unchecked";
|
||||
status += " two: ";
|
||||
status += (two.checked) ? "checked" : "unchecked";
|
||||
message(status);
|
||||
}
|
||||
|
||||
function oneClick(e) {
|
||||
message("clicked one");
|
||||
}
|
||||
|
||||
function twoClick(e) {
|
||||
message("clicked two");
|
||||
}
|
||||
|
||||
function message(txt) {
|
||||
msg.innerHTML += " ** " + txt;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<body onload="init()" onclick="message('clicked body')" onmouseup="message('<br>')">
|
||||
|
||||
<div> The idea here is to simulate the layerswitcher radiobuttons UI
|
||||
without all the overhead of openlayers.
|
||||
<br>
|
||||
<br>
|
||||
There are event handlers attached to the following elements:
|
||||
<br>
|
||||
* Body - Prints message "clicked body" to message area
|
||||
<br>
|
||||
* Blue Div - Prints message "clicked div" to message area, stops
|
||||
the event propagation, prints a message with the
|
||||
status of the two radiobuttons
|
||||
<br>
|
||||
* Radio One - Prints message "clicked one" to message area
|
||||
<br>
|
||||
* Radio Two - Prints message "clicked two" to message area
|
||||
<br>
|
||||
<br>
|
||||
<b>
|
||||
The problem, as you will see if you click the radio buttons
|
||||
themselves, is that their "checked" status seems to update, but
|
||||
their visual UI bit does not. Can we fix this!?!
|
||||
</b>
|
||||
</div>
|
||||
|
||||
<div id="div" style="background-color:blue; margin:50px">
|
||||
<input id="one" type="radio" name="foo"/>
|
||||
<span> one </span>
|
||||
<br>
|
||||
<input id="two" type="radio" name="foo"/>
|
||||
<span> two </span>
|
||||
</div>
|
||||
|
||||
<div id="msg" style="background-color:pink; margin-top:200px">
|
||||
Events:
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,11 +14,12 @@
|
||||
var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/4, controls:[]});
|
||||
|
||||
var ka_wms = new OpenLayers.Layer.KaMap( "TIGER (KaMap)",
|
||||
"http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' }, 'degrees', 72 );
|
||||
"http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' });
|
||||
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
|
||||
"http://wms.jpl.nasa.gov/wms.cgi",
|
||||
{layers: "modis,global_mosaic"});
|
||||
jpl_wms.setVisibility(false);
|
||||
ka_wms.isBaseLayer = false;
|
||||
map.addLayers([jpl_wms,ka_wms]);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.addControl(new OpenLayers.Control.MouseToolbar());
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function init(){
|
||||
var map = new OpenLayers.Map('map', {'maxResolution': 1.6, maxZoomLevel:20});
|
||||
var mapOptions = { maxResolution: 1.6, numZoomLevels: 21};
|
||||
var map = new OpenLayers.Map('map', mapOptions);
|
||||
|
||||
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||
|
||||
var ww = new OpenLayers.Layer.WorldWind( "Urban",
|
||||
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", .8, 9,
|
||||
{T:"104"});
|
||||
ww.setTileSize(new OpenLayers.Size(512,512));
|
||||
{T:"104"}, { tileSize: new OpenLayers.Size(512,512) });
|
||||
|
||||
|
||||
map.addLayers([ol_wms, ww]);
|
||||
|
||||
@@ -18,20 +18,23 @@
|
||||
|
||||
var lon = 5;
|
||||
var lat = 40;
|
||||
var zoom = 5;
|
||||
var zoom = 15;
|
||||
var map, velayer, layer;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map') );
|
||||
map = new OpenLayers.Map( $('map') ,
|
||||
{controls:[new OpenLayers.Control.MouseDefaults()]});
|
||||
|
||||
velayer = new OpenLayers.Layer.VirtualEarth( "VE");
|
||||
velayer = new OpenLayers.Layer.VirtualEarth( "VE",
|
||||
{ minZoomLevel: 4, maxZoomLevel: 6 });
|
||||
map.addLayer(velayer);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), 2);
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
map.addControl( new OpenLayers.Control.PanZoomBar() );
|
||||
}
|
||||
|
||||
function add() {
|
||||
|
||||
@@ -35,7 +35,7 @@ var map,ia_wms;
|
||||
<body onload="init()">
|
||||
<h1>OpenLayers Example</h1>
|
||||
<p>WMS-T example: update the times, and the radar image will change. Uses Layer.changeParams. Thanks to David Bitner for the inspiration, the original code, and the kick in the butt!</p>
|
||||
<input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.changeParams({"time":this.value});' >
|
||||
<input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.mergeNewParams({"time":this.value});' >
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
54
examples/zoomLevels.html
Normal file
54
examples/zoomLevels.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 475px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var lon = 50;
|
||||
var lat = 0;
|
||||
var zoom = 0;
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
|
||||
var options = {
|
||||
// resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101],
|
||||
// scales: [50000000, 10000000],
|
||||
// maxResolution: 0.17578125,
|
||||
// minResolution: 0.0439453125,
|
||||
// maxScale: 10000000,
|
||||
// minScale: 50000000,
|
||||
minResolution: "auto",
|
||||
minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
|
||||
maxResolution: "auto",
|
||||
maxExtent: new OpenLayers.Bounds(-180, -90, 90, 180),
|
||||
// numZoomLevels: 5,
|
||||
controls: [new OpenLayers.Control.MouseDefaults()]
|
||||
};
|
||||
|
||||
map = new OpenLayers.Map( $('map') , options);
|
||||
|
||||
map.addControl(new OpenLayers.Control.PanZoomBar());
|
||||
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
|
||||
map.addLayer(layer);
|
||||
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
img/blank.gif
Normal file
BIN
img/blank.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -420,8 +420,8 @@ OpenLayers.Bounds.prototype = {
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
add:function(x, y){
|
||||
return new OpenLayers.Box(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,16 +119,18 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
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" : "auto";
|
||||
Event.observe(labelSpan,
|
||||
"click",
|
||||
this.onLabelClick.bindAsEventListener(inputElem));
|
||||
|
||||
Event.observe(labelSpan, "click",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
@@ -158,11 +160,17 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
onLabelClick: function(e) {
|
||||
var clickedRadioButton = ((this.type == "radio") && (this.checked));
|
||||
if (!clickedRadioButton) {
|
||||
|
||||
onInputClick: function(e) {
|
||||
if (this.type == "radio") {
|
||||
this.checked = true;
|
||||
this.layer.map.setBaseLayer(this.layer, true);
|
||||
this.layer.map.events.triggerEvent("changebaselayer");
|
||||
} else {
|
||||
this.checked = !this.checked;
|
||||
this.control.updateMap();
|
||||
}
|
||||
Event.stop(e);
|
||||
},
|
||||
|
||||
/** Need to update the map accordingly whenever user clicks in either of
|
||||
@@ -189,7 +197,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
for(var i=0; i < this.baseLayerInputs.length; i++) {
|
||||
var input = this.baseLayerInputs[i];
|
||||
if (input.checked) {
|
||||
this.map.setBaseLayer(input.layer, true);
|
||||
this.map.setBaseLayer(input.layer, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,6 +279,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
Event.observe(this.div, "mouseup",
|
||||
this.mouseUp.bindAsEventListener(this));
|
||||
Event.observe(this.div, "click",
|
||||
this.ignoreEvent);
|
||||
Event.observe(this.div, "mousedown",
|
||||
this.mouseDown.bindAsEventListener(this));
|
||||
Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
@@ -301,8 +311,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||
Event.observe(this.baseLayersDiv, "click",
|
||||
/*Event.observe(this.baseLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
|
||||
|
||||
@@ -315,8 +326,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
this.dataLayersDiv = document.createElement("div");
|
||||
this.dataLayersDiv.style.paddingLeft = "10px";
|
||||
Event.observe(this.dataLayersDiv, "click",
|
||||
/*Event.observe(this.dataLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
@@ -60,6 +60,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -80,6 +81,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
}
|
||||
@@ -95,8 +97,8 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
if (this.zoomBox) {
|
||||
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
|
||||
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
|
||||
this.zoomBox.style.width = deltaX+"px";
|
||||
this.zoomBox.style.height = deltaY+"px";
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
@@ -124,20 +126,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomBox) {
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
var top = Math.max(start.lat, end.lat);
|
||||
var bottom = Math.min(start.lat, end.lat);
|
||||
var left = Math.min(start.lon, end.lon);
|
||||
var right = Math.max(start.lon, end.lon);
|
||||
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
|
||||
var zoom = this.map.getZoomForExtent(bounds);
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(start.lon + end.lon) / 2,
|
||||
(start.lat + end.lat) / 2
|
||||
), zoom);
|
||||
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
|
||||
this.zoomBox = null;
|
||||
this.zoomBoxEnd(evt);
|
||||
} else {
|
||||
if (this.performedDrag) {
|
||||
this.map.setCenter(this.map.center);
|
||||
@@ -173,6 +162,37 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.map.zoomOut();
|
||||
},
|
||||
|
||||
/** Zoombox function.
|
||||
*
|
||||
*/
|
||||
zoomBoxEnd: function(evt) {
|
||||
if (this.mouseDragStart != null) {
|
||||
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
|
||||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
var top = Math.max(start.lat, end.lat);
|
||||
var bottom = Math.min(start.lat, end.lat);
|
||||
var left = Math.min(start.lon, end.lon);
|
||||
var right = Math.max(start.lon, end.lon);
|
||||
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
|
||||
var zoom = this.map.getZoomForExtent(bounds);
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(start.lon + end.lon) / 2,
|
||||
(start.lat + end.lat) / 2
|
||||
), zoom);
|
||||
} else {
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(end.lon),
|
||||
(end.lat)
|
||||
), this.map.getZoom() + 1);
|
||||
}
|
||||
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
|
||||
this.zoomBox = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
|
||||
@@ -189,7 +209,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
var inMap = false;
|
||||
var elem = Event.element(e);
|
||||
while(elem != null) {
|
||||
if (elem == this.map.div) {
|
||||
if (this.map && elem == this.map.div) {
|
||||
inMap = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/MouseDefaults.js
|
||||
*/
|
||||
OpenLayers.Control.MouseToolbar = Class.create();
|
||||
OpenLayers.Control.MouseToolbar.X = 6;
|
||||
OpenLayers.Control.MouseToolbar.Y = 300;
|
||||
OpenLayers.Control.MouseToolbar.prototype =
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
Object.extend( new OpenLayers.Control(),
|
||||
Object.extend( new OpenLayers.Control.MouseDefaults(), {
|
||||
|
||||
mode: null,
|
||||
|
||||
@@ -35,6 +37,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
this.buttons = new Object();
|
||||
this.map.events.register( "click", this, this.defaultClick );
|
||||
this.map.events.register( "dblclick", this, this.defaultDblClick );
|
||||
this.map.events.register( "mousedown", this, this.defaultMouseDown );
|
||||
this.map.events.register( "mouseup", this, this.defaultMouseUp );
|
||||
@@ -46,9 +49,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
|
||||
this.switchModeTo("pan");
|
||||
this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
|
||||
return this.div;
|
||||
|
||||
},
|
||||
@@ -69,6 +70,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
btn.events = new OpenLayers.Events(this, btn);
|
||||
btn.events.register("mousedown", this, this.buttonClick);
|
||||
btn.events.register("mouseup", this, Event.stop);
|
||||
btn.events.register("click", this, Event.stop);
|
||||
btn.action = id;
|
||||
btn.title = title;
|
||||
btn.alt = title;
|
||||
@@ -93,6 +95,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.performedDrag = false;
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 2);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -102,8 +106,10 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
this.startViaKeyboard = false;
|
||||
if (evt.shiftKey && this.mode !="zoombox") {
|
||||
this.switchModeTo("zoombox");
|
||||
this.startViaKeyboard = true;
|
||||
} else if (evt.altKey && this.mode !="measure") {
|
||||
this.switchModeTo("measure");
|
||||
} else if (!this.mode) {
|
||||
@@ -122,8 +128,10 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
this.performedDrag = true;
|
||||
break;
|
||||
case "measure":
|
||||
var distance = "";
|
||||
@@ -144,6 +152,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
"absolute");
|
||||
this.measureBox.style.width="4px";
|
||||
this.measureBox.style.height="4px";
|
||||
this.measureBox.style.fontSize = "1px";
|
||||
this.measureBox.style.backgroundColor="red";
|
||||
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.layerContainerDiv.appendChild(this.measureBox);
|
||||
@@ -175,7 +184,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
|
||||
switchModeTo: function(mode) {
|
||||
if (mode != this.mode) {
|
||||
if (this.mode) {
|
||||
if (this.mode && this.buttons[this.mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
|
||||
}
|
||||
if (this.mode == "measure" && mode != "measure") {
|
||||
@@ -188,7 +197,9 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.measureStart = null;
|
||||
}
|
||||
this.mode = mode;
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
|
||||
if (this.buttons[mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -205,8 +216,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
case "zoombox":
|
||||
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
|
||||
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
|
||||
this.zoomBox.style.width = deltaX+"px";
|
||||
this.zoomBox.style.height = deltaY+"px";
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
@@ -235,21 +246,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
var top = Math.max(start.lat, end.lat);
|
||||
var bottom = Math.min(start.lat, end.lat);
|
||||
var left = Math.min(start.lon, end.lon);
|
||||
var right = Math.max(start.lon, end.lon);
|
||||
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
|
||||
var zoom = this.map.getZoomForExtent(bounds);
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(start.lon + end.lon) / 2,
|
||||
(start.lat + end.lat) / 2
|
||||
), zoom);
|
||||
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
|
||||
this.zoomBox = null;
|
||||
this.leaveMode();
|
||||
this.zoomBoxEnd(evt);
|
||||
if (this.startViaKeyboard) this.leaveMode();
|
||||
break;
|
||||
case "pan":
|
||||
if (this.performedDrag) {
|
||||
@@ -266,6 +264,12 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||
this.defaultMouseUp(evt);
|
||||
}
|
||||
},
|
||||
defaultClick: function (evt) {
|
||||
if (this.performedDrag) {
|
||||
this.performedDrag = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
@@ -25,10 +25,24 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
|
||||
this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X,
|
||||
OpenLayers.Control.PanZoomBar.Y);
|
||||
},
|
||||
|
||||
// put code here to catch "changebaselayer" event from map, because
|
||||
// we are going to have to redraw this thing each time, because
|
||||
// maxZoom will/might change.
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
|
||||
this.map.events.register("changebaselayer", this, this.redraw);
|
||||
},
|
||||
|
||||
/** clear the div and start over.
|
||||
*
|
||||
*/
|
||||
redraw: function() {
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = "";
|
||||
}
|
||||
this.draw();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -37,7 +51,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
draw: function(px) {
|
||||
// initialize our internal div
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
px = this.position;
|
||||
px = this.position.clone();
|
||||
|
||||
// place the controls
|
||||
this.buttons = new Array();
|
||||
@@ -63,9 +77,9 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
|
||||
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
|
||||
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
|
||||
var slider = OpenLayers.Util.createAlphaImageDiv(id,
|
||||
centered.add(-1,
|
||||
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
|
||||
centered.add(-1, zoomsToEnd * this.zoomStopHeight),
|
||||
new OpenLayers.Size(20,9),
|
||||
imgLocation+"slider.png",
|
||||
"absolute");
|
||||
@@ -79,7 +93,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.sliderEvents.register("click", this, this.doubleClick);
|
||||
|
||||
sz = new OpenLayers.Size();
|
||||
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1);
|
||||
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
|
||||
sz.w = this.zoomStopWidth;
|
||||
var div = null
|
||||
|
||||
@@ -115,7 +129,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.map.events.register("zoomend", this, this.moveZoomBar);
|
||||
|
||||
centered = centered.add(0,
|
||||
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1));
|
||||
this.zoomStopHeight * this.map.getNumZoomLevels());
|
||||
return centered;
|
||||
},
|
||||
/*
|
||||
@@ -136,7 +150,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
var y = evt.xy.y;
|
||||
var top = Position.page(evt.object)[1];
|
||||
var levels = Math.floor((y - top)/this.zoomStopHeight);
|
||||
this.map.zoomTo(this.map.getMaxZoomLevel() - levels);
|
||||
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
@@ -170,8 +184,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.slider.style.top = newTop+"px";
|
||||
}
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
Event.stop(evt);
|
||||
}
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -183,8 +197,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomStart) {
|
||||
this.div.style.cursor="default";
|
||||
this.map.events.remove("mousemove");
|
||||
this.map.events.remove("mouseup");
|
||||
this.map.events.unregister("mouseup", this, this.passEventToSlider);
|
||||
this.map.events.unregister("mousemove", this, this.passEventToSlider);
|
||||
var deltaY = this.zoomStart.y - evt.xy.y
|
||||
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
||||
this.moveZoomBar();
|
||||
@@ -198,8 +212,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
*/
|
||||
moveZoomBar:function() {
|
||||
var newTop =
|
||||
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight
|
||||
+ this.startTop + 1;
|
||||
((this.map.getNumZoomLevels()-1) - this.map.getZoom()) *
|
||||
this.zoomStopHeight + this.startTop + 1;
|
||||
this.slider.style.top = newTop + "px";
|
||||
},
|
||||
|
||||
|
||||
@@ -48,9 +48,8 @@ OpenLayers.Feature.WFS.prototype =
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
var point = xmlNode.getElementsByTagName("Point");
|
||||
var text = OpenLayers.Util.getXmlNodeValue(point[0]);
|
||||
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
|
||||
var floats = text.split(",");
|
||||
|
||||
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
|
||||
parseFloat(floats[1])),
|
||||
id: null};
|
||||
|
||||
@@ -51,10 +51,7 @@ OpenLayers.Layer.prototype = {
|
||||
maxResolution: null,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: null,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: null,
|
||||
numZoomLevels: null,
|
||||
|
||||
/** @type float */
|
||||
minScale: null,
|
||||
@@ -148,6 +145,12 @@ OpenLayers.Layer.prototype = {
|
||||
Object.extend(this, this.options);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
onMapResize: function() {
|
||||
//this function can be implemented by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bound
|
||||
@@ -163,19 +166,25 @@ OpenLayers.Layer.prototype = {
|
||||
* so that subclasses can override this and take special action once
|
||||
* they have their map variable set.
|
||||
*
|
||||
* Here we take care to bring over any of the necessary default properties
|
||||
* from the map.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.map = map;
|
||||
|
||||
var properties = new Array(
|
||||
'projection', 'minExtent', 'maxExtent',
|
||||
'minScale', 'maxScale',
|
||||
'projection', 'units',
|
||||
'scales', 'resolutions',
|
||||
'maxScale', 'minScale',
|
||||
'maxResolution', 'minResolution',
|
||||
'minZoomLevel', 'maxZoomLevel', 'units',
|
||||
'scales', 'resolutions'
|
||||
|
||||
'minExtent', 'maxExtent',
|
||||
'numZoomLevels'
|
||||
);
|
||||
if (this.map.maxZoomLevel && !this.numZoomLevels) {
|
||||
this.numZoomLevels = this.map.maxZoomLevel + 1;
|
||||
}
|
||||
for(var i=0; i < properties.length; i++) {
|
||||
if (this[properties[i]] == null) {
|
||||
this[properties[i]] = this.map[properties[i]];
|
||||
@@ -220,6 +229,16 @@ OpenLayers.Layer.prototype = {
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @param {Boolean} isBaseLayer
|
||||
*/
|
||||
setIsBaseLayer: function(isBaseLayer) {
|
||||
this.isBaseLayer = isBaseLayer;
|
||||
if (this.map != null) {
|
||||
this.map.events.triggerEvent("changelayer");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @type String
|
||||
*/
|
||||
@@ -242,19 +261,11 @@ OpenLayers.Layer.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The minimum zoom level that can be reached in this layer
|
||||
* @returns The total number of zoom levels this layer can reach
|
||||
* @type int
|
||||
*/
|
||||
getMinZoomLevel: function() {
|
||||
return this.minZoomLevel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The maximum zoom level that can be reached in this layer
|
||||
* @type int
|
||||
*/
|
||||
getMaxZoomLevel: function() {
|
||||
return this.maxZoomLevel;
|
||||
getNumZoomLevels: function() {
|
||||
return this.numZoomLevels;
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
@@ -272,7 +283,7 @@ OpenLayers.Layer.prototype = {
|
||||
*/
|
||||
getResolution: function() {
|
||||
var viewSize = this.map.getSize();
|
||||
var extent = this.map.getExtent();
|
||||
var extent = this.getExtent();
|
||||
return Math.max( extent.getWidth() / viewSize.w,
|
||||
extent.getHeight() / viewSize.h );
|
||||
},
|
||||
@@ -316,7 +327,7 @@ OpenLayers.Layer.prototype = {
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var size = this.map.getSize();
|
||||
var center = this.map.getCenter(); //map center lon/lat
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
|
||||
@@ -37,9 +37,6 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
if (arguments.length > 0) {
|
||||
if (this.pane == null) {
|
||||
this.pane = OpenLayers.Util.createDiv();
|
||||
this.pane.style.width = "100%";
|
||||
this.pane.style.height = "100%";
|
||||
this.pane.style.backgroundColor = "transparent";
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -55,12 +52,17 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
|
||||
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
|
||||
this.pane.style.display = this.div.style.display;
|
||||
this.pane.style.width="100%";
|
||||
this.pane.style.height="100%";
|
||||
if (/MSIE/.test(navigator.userAgent)) {
|
||||
this.pane.style.background = "url("+OpenLayers.Util.getImagesLocation()+"blank.gif)";
|
||||
}
|
||||
|
||||
if (this.isFixed) {
|
||||
this.map.viewPortDiv.appendChild(this.pane);
|
||||
} else {
|
||||
this.map.layerContainerDiv.appendChild(this.pane);
|
||||
}
|
||||
this.map.events.attachToElement(this.pane);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,11 +11,6 @@ OpenLayers.Layer.GeoRSS = Class.create();
|
||||
OpenLayers.Layer.GeoRSS.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** GeoRSS layer is never a base layer.
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
/** store url of text file
|
||||
* @type str */
|
||||
location:null,
|
||||
|
||||
@@ -2,31 +2,8 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
if (typeof GMap2 != "undefined") {
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
// it seems like "b" is the main div
|
||||
var div = this.b.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
@@ -49,7 +26,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
// OPTIONS
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: -1,
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
@@ -65,6 +42,8 @@ OpenLayers.Layer.Google.prototype =
|
||||
if (this.maxExtent == null) {
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
}
|
||||
this.addContainerPxFunction();
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -147,6 +126,13 @@ OpenLayers.Layer.Google.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
onMapResize: function() {
|
||||
this.gmap.checkResize();
|
||||
},
|
||||
|
||||
/** If we can't load the GMap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
@@ -259,6 +245,12 @@ OpenLayers.Layer.Google.prototype =
|
||||
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
|
||||
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
|
||||
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
|
||||
zoom = this.getOLZoomFromGZoom(gZoom);
|
||||
}
|
||||
return zoom;
|
||||
@@ -287,7 +279,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getOLZoomFromGZoom: function(gZoom) {
|
||||
var zoom = null;
|
||||
if (gZoom != null) {
|
||||
zoom = gZoom;
|
||||
zoom = gZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -302,7 +294,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getGZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -417,7 +409,33 @@ OpenLayers.Layer.Google.prototype =
|
||||
return gLatLngBounds;
|
||||
},
|
||||
|
||||
addContainerPxFunction: function() {
|
||||
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
// it seems like "b" is the main div
|
||||
var div = this.b.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
};
|
||||
}
|
||||
},
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Google"
|
||||
});
|
||||
|
||||
@@ -42,7 +42,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
destroy: function() {
|
||||
this.clearGrid();
|
||||
this.grid = null;
|
||||
this.alpha = null;
|
||||
this.tileSize = null;
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
@@ -88,30 +87,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} tileID
|
||||
*
|
||||
* @returns The OpenLayers.Tile with the corresponding ID from the grid.
|
||||
* if no tile is found, returns null
|
||||
* @type OpenLayers.Tile
|
||||
*/
|
||||
getTile: function(tileID) {
|
||||
var foundTile = null;
|
||||
if (this.grid) {
|
||||
|
||||
for(var iRow = 0; iRow < this.grid.length; iRow++) {
|
||||
var row = this.grid[iRow];
|
||||
for(var iCol = 0; iCol < row.length; iCol++) {
|
||||
var tile = row[iCol];
|
||||
if (tile.id == tileID) {
|
||||
foundTile = tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return foundTile;
|
||||
},
|
||||
|
||||
/** This function is called whenever the map is moved. All the moving
|
||||
* of actual 'tiles' is done by the map, but moveTo's role is to accept
|
||||
* a bounds and make sure the data that that bounds requires is pre-loaded.
|
||||
@@ -150,6 +125,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @returns A Bounds object representing the bounds of all the currently
|
||||
* loaded tiles (including those partially or not at all seen
|
||||
* onscreen)
|
||||
@@ -170,7 +147,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_initTiles:function() {
|
||||
var viewSize = this.map.getSize();
|
||||
@@ -247,7 +224,15 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Starts at the top right corner of the grid and proceeds in a spiral
|
||||
* towards the center, adding tiles one at a time to the beginning of a
|
||||
* queue.
|
||||
*
|
||||
* Once all the grid's tiles have been added to the queue, we go back
|
||||
* and iterate through the queue (thus reversing the spiral order from
|
||||
* outside-in to inside-out), calling draw() on each tile.
|
||||
*/
|
||||
spiralTileLoad: function() {
|
||||
var tileQueue = new Array();
|
||||
@@ -279,6 +264,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
break;
|
||||
}
|
||||
|
||||
// if the test grid coordinates are within the bounds of the
|
||||
// grid, get a reference to the tile.
|
||||
var tile = null;
|
||||
if ((testRow < this.grid.length) &&
|
||||
(testCell < this.grid[0].length)) {
|
||||
@@ -286,12 +273,16 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
|
||||
if ((tile != null) && (!tile.queued)) {
|
||||
//add tile to beginning of queue, mark it as queued.
|
||||
tileQueue.unshift(tile);
|
||||
tile.queued = true;
|
||||
|
||||
//restart the directions counter and take on the new coords
|
||||
directionsTried = 0;
|
||||
iRow = testRow;
|
||||
iCell = testCell;
|
||||
} else {
|
||||
//need to try to load a tile in a different direction
|
||||
direction = (direction + 1) % 4;
|
||||
directionsTried++;
|
||||
}
|
||||
@@ -301,6 +292,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
for(var i=0; i < tileQueue.length; i++) {
|
||||
var tile = tileQueue[i]
|
||||
tile.draw();
|
||||
//mark tile as unqueued for the next time (since tiles are reused)
|
||||
tile.queued = false;
|
||||
}
|
||||
},
|
||||
@@ -320,67 +312,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/** Calculates based on resolution, center, and mapsize
|
||||
*
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
var center = this.map.getCenter();
|
||||
if (center != null) {
|
||||
|
||||
var res = this.getResolution();
|
||||
var size = this.map.getSize();
|
||||
var w_deg = size.w * res;
|
||||
var h_deg = size.h * res;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/** go through and remove all tiles from the grid, calling
|
||||
* destroy() on each of them to kill circular references
|
||||
*
|
||||
@@ -462,6 +393,65 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/** Calculates based on resolution, center, and mapsize
|
||||
*
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
var center = this.map.getCenter();
|
||||
if (center != null) {
|
||||
|
||||
var res = this.map.getResolution();
|
||||
var size = this.map.getSize();
|
||||
var w_deg = size.w * res;
|
||||
var h_deg = size.h * res;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, 0),
|
||||
this.getNumZoomLevels() - 1);
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Grid"
|
||||
});
|
||||
|
||||
@@ -36,10 +36,17 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
this.params = Object.extend( new Object(), params);
|
||||
},
|
||||
|
||||
/** When the layer is added to the map, once it has taken all the
|
||||
* relevant properties from the map (in Layer.setMap()), we will
|
||||
* make the call to initialize the layer's resolutions array.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
this.initResolutions();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -131,31 +138,83 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
return requestString;
|
||||
},
|
||||
|
||||
/** This method's responsibility is to set up the 'resolutions' array
|
||||
* for the layer -- this array is what the layer will use to interface
|
||||
* between the zoom levels of the map and the resolution display of the
|
||||
* layer.
|
||||
*
|
||||
* The user has several options that determine how the array is set up.
|
||||
*
|
||||
* For a detailed explanation, see the following wiki from the
|
||||
* openlayers.org homepage:
|
||||
*
|
||||
* http://trac.openlayers.org/wiki/SettingZoomLevels
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
initResolutions: function() {
|
||||
if (this.scales != null) {
|
||||
this.resolutions = new Array();
|
||||
for(var i = 0; i < this.scales.length; i++)
|
||||
this.resolutions[i] = OpenLayers.Util.getResolutionFromScale(this.scales[i], this.units);
|
||||
this.maxZoomLevel = this.resolutions.length;
|
||||
} else if (this.resolutions != null) {
|
||||
this.maxZoomLevel = this.resolutions.length;
|
||||
} else {
|
||||
this.resolutions = new Array();
|
||||
if (this.minScale)
|
||||
this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units);
|
||||
var maxRes = this.getMaxResolution();
|
||||
if (this.maxScale) {
|
||||
/* This will cause this.map.getMaxZoomLevel() to be set the next time
|
||||
* it is called, which means that the next portion here will succeed. */
|
||||
var minRes = OpenLayers.Util.getResolutionFromScale(this.maxScale);
|
||||
this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) / Math.log(2));
|
||||
|
||||
if ((this.scales != null) || (this.resolutions != null)) {
|
||||
//preset levels
|
||||
if (this.scales != null) {
|
||||
this.resolutions = new Array();
|
||||
for(var i = 0; i < this.scales.length; i++) {
|
||||
this.resolutions[i] =
|
||||
OpenLayers.Util.getResolutionFromScale(this.scales[i],
|
||||
this.units);
|
||||
}
|
||||
}
|
||||
for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) {
|
||||
this.resolutions.push(maxRes / Math.pow(2, i));
|
||||
this.numZoomLevels = this.resolutions.length;
|
||||
|
||||
} else {
|
||||
//maxResolution and numZoomLevels
|
||||
|
||||
this.resolutions = new Array();
|
||||
|
||||
// determine maxResolution
|
||||
if (this.minScale) {
|
||||
this.maxResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(this.minScale,
|
||||
this.units);
|
||||
} else if (this.maxResolution == "auto") {
|
||||
var viewSize = this.map.getSize();
|
||||
var wRes = this.maxExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.maxExtent.getHeight()/ viewSize.h;
|
||||
this.maxResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine minResolution
|
||||
if (this.maxScale != null) {
|
||||
this.minResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(this.maxScale);
|
||||
} else if ((this.minResolution == "auto") &&
|
||||
(this.minExtent != null)){
|
||||
var viewSize = this.map.getSize();
|
||||
var wRes = this.minExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.minExtent.getHeight()/ viewSize.h;
|
||||
this.minResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine numZoomLevels
|
||||
if (this.minResolution != null) {
|
||||
var ratio = this.maxResolution / this.minResolution;
|
||||
this.numZoomLevels =
|
||||
Math.floor(Math.log(ratio) / Math.log(2)) + 1;
|
||||
}
|
||||
|
||||
// now we have numZoomLevels and maxResolution,
|
||||
// we can populate the resolutions array
|
||||
for (var i=0; i < this.numZoomLevels; i++) {
|
||||
this.resolutions.push(this.maxResolution / Math.pow(2, i));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The currently selected resolution of the map, taken from the
|
||||
* resolutions array, indexed by current zoom level.
|
||||
* @type float
|
||||
*/
|
||||
getResolution: function() {
|
||||
var zoom = this.map.getZoom();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype =
|
||||
*/
|
||||
getURL: function (bounds) {
|
||||
var mapRes = this.map.getResolution();
|
||||
var scale = this.map.getScale();
|
||||
var scale = Math.round((this.map.getScale() * 10000)) / 10000;
|
||||
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
|
||||
var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
|
||||
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);
|
||||
|
||||
@@ -11,12 +11,6 @@ OpenLayers.Layer.Text = Class.create();
|
||||
OpenLayers.Layer.Text.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** Text layer is never a base layer.
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
/** store url of text file - this should be specified in the
|
||||
* "options" hashtable
|
||||
* @type str */
|
||||
|
||||
@@ -14,6 +14,12 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 1,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -21,6 +27,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -200,24 +208,26 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
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 width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
//make sure zoom is within bounds
|
||||
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -245,7 +255,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getOLZoomFromVEZoom: function(veZoom) {
|
||||
var zoom = null;
|
||||
if (veZoom != null) {
|
||||
zoom = veZoom;
|
||||
zoom = veZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -260,7 +270,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getVEZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -19,6 +19,8 @@ OpenLayers.Layer.WFS.prototype =
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
buffer: 1,
|
||||
|
||||
/** Allow the user to specify special classes for features and tiles.
|
||||
*
|
||||
* This allows for easy-definition of behaviour. The defaults are
|
||||
@@ -157,10 +159,10 @@ OpenLayers.Layer.WFS.prototype =
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hashtable of new params to use
|
||||
* @param {Object} newParams Hashtable of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
|
||||
|
||||
|
||||
@@ -121,10 +121,10 @@ OpenLayers.Layer.WMS.prototype =
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hashtable of new params to use
|
||||
* @param {Object} newParams Hashtable of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
|
||||
newArguments);
|
||||
|
||||
@@ -177,8 +177,11 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
* @param {Object} newParams
|
||||
*/
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
|
||||
arguments);
|
||||
newArguments);
|
||||
//redraw
|
||||
this.moveTo();
|
||||
},
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ OpenLayers.Layer.WorldWind.prototype =
|
||||
|
||||
zoomLevels: null,
|
||||
|
||||
initialize: function(name, url, lzd, zoomLevels, params) {
|
||||
initialize: function(name, url, lzd, zoomLevels, params, options) {
|
||||
this.lzd = lzd;
|
||||
this.zoomLevels = zoomLevels;
|
||||
var newArguments = new Array();
|
||||
newArguments.push(name, url, params);
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (arguments.length > 0 && params) {
|
||||
|
||||
@@ -78,11 +78,14 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// Options
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
|
||||
/** @type String */
|
||||
projection: "EPSG:4326",
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** default max is 360 deg / 256 px, which corresponds to
|
||||
* zoom level 0 on gmaps
|
||||
@@ -90,21 +93,23 @@ OpenLayers.Map.prototype = {
|
||||
* @type float */
|
||||
maxResolution: 1.40625,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 0,
|
||||
/** @type float */
|
||||
minResolution: null,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
/** @type float */
|
||||
maxScale: null,
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** @type Float */
|
||||
/** @type float */
|
||||
minScale: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
minExtent: null,
|
||||
|
||||
/** @type int */
|
||||
numZoomLevels: 16,
|
||||
|
||||
|
||||
/**
|
||||
@@ -129,6 +134,8 @@ OpenLayers.Map.prototype = {
|
||||
// the layerContainerDiv is the one that holds all the layers
|
||||
id = div.id + "_OpenLayers_Container";
|
||||
this.layerContainerDiv = OpenLayers.Util.createDiv(id);
|
||||
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
|
||||
|
||||
this.viewPortDiv.appendChild(this.layerContainerDiv);
|
||||
|
||||
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
|
||||
@@ -207,16 +214,6 @@ OpenLayers.Map.prototype = {
|
||||
// now add the options declared by the user
|
||||
// (these will override defaults)
|
||||
Object.extend(this, options);
|
||||
|
||||
// if maxResolution is specified as "auto", calculate it
|
||||
// based on the maxExtent and the viewSize
|
||||
//
|
||||
if (this.maxResolution == "auto" || this.maxResolution == null) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
var viewSize = this.getSize();
|
||||
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
|
||||
maxExtent.getHeight() / viewSize.h );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -374,9 +371,12 @@ OpenLayers.Map.prototype = {
|
||||
if (center != null) {
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
if (zoom > this.baseLayer.numZoomLevels - 1) {
|
||||
zoom = this.baseLayer.numZoomLevels - 1;
|
||||
}
|
||||
this.setCenter(center, zoom);
|
||||
}
|
||||
|
||||
}
|
||||
if ((noEvent == null) || (noEvent == false)) {
|
||||
this.events.triggerEvent("changebaselayer");
|
||||
}
|
||||
@@ -470,14 +470,18 @@ OpenLayers.Map.prototype = {
|
||||
if (oldSize == null)
|
||||
this.size = oldSize = newSize;
|
||||
if (!newSize.equals(oldSize)) {
|
||||
// move the layer container so that the map is still centered
|
||||
var dx = (newSize.w - oldSize.w) / 2,
|
||||
dy = (newSize.h - oldSize.h) / 2;
|
||||
var lcStyle = this.layerContainerDiv.style;
|
||||
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px";
|
||||
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
|
||||
// reset the map center
|
||||
this.layerContainerOrigin = this.center.clone();
|
||||
|
||||
//notify layers of mapresize
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
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
|
||||
this.size = newSize;
|
||||
// the div might have moved on the page, also
|
||||
@@ -561,7 +565,6 @@ OpenLayers.Map.prototype = {
|
||||
* trigger movestart/end events
|
||||
*/
|
||||
setCenter: function (lonlat, zoom, minor) {
|
||||
|
||||
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
|
||||
(zoom != this.getZoom());
|
||||
|
||||
@@ -643,8 +646,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
isValidZoomLevel: function(zoomLevel) {
|
||||
return ( (zoomLevel != null) &&
|
||||
(zoomLevel >= this.getMinZoomLevel()) &&
|
||||
(zoomLevel <= this.getMaxZoomLevel()) );
|
||||
(zoomLevel >= 0) &&
|
||||
(zoomLevel < this.getNumZoomLevels()) );
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -680,15 +683,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getProjection: function() {
|
||||
var projection = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
projection = this.baseLayer.getProjection();
|
||||
}
|
||||
|
||||
if (projection == null) {
|
||||
projection = this.projection;
|
||||
}
|
||||
|
||||
return projection;
|
||||
},
|
||||
|
||||
@@ -698,15 +695,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxResolution: function() {
|
||||
var maxResolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxResolution = this.baseLayer.getMaxResolution();
|
||||
}
|
||||
|
||||
if (maxResolution == null) {
|
||||
maxResolution = this.maxResolution;
|
||||
}
|
||||
|
||||
return maxResolution;
|
||||
},
|
||||
|
||||
@@ -715,55 +706,25 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxExtent: function () {
|
||||
var maxExtent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxExtent = this.baseLayer.getMaxExtent();
|
||||
}
|
||||
|
||||
if (maxExtent == null) {
|
||||
maxExtent = this.maxExtent;
|
||||
}
|
||||
|
||||
return maxExtent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The maximum zoom level that can be reached in the map
|
||||
* @returns The total number of zoom levels that can be displayed by the
|
||||
* current baseLayer.
|
||||
* @type int
|
||||
*/
|
||||
getMaxZoomLevel: function() {
|
||||
var maxZoomLevel = null;
|
||||
|
||||
getNumZoomLevels: function() {
|
||||
var numZoomLevels = null;
|
||||
if (this.baseLayer != null) {
|
||||
maxZoomLevel = this.baseLayer.getMaxZoomLevel();
|
||||
numZoomLevels = this.baseLayer.getNumZoomLevels();
|
||||
}
|
||||
|
||||
if (maxZoomLevel == null) {
|
||||
maxZoomLevel = this.maxZoomLevel;
|
||||
}
|
||||
|
||||
return maxZoomLevel;
|
||||
return numZoomLevels;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The minimum zoom level that can be reached in the map
|
||||
* @type int
|
||||
*/
|
||||
getMinZoomLevel: function() {
|
||||
var minZoomLevel = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
minZoomLevel = this.baseLayer.getMinZoomLevel();
|
||||
}
|
||||
|
||||
if (minZoomLevel == null) {
|
||||
minZoomLevel = this.minZoomLevel;
|
||||
}
|
||||
|
||||
return minZoomLevel;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
@@ -783,7 +744,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
extent = this.baseLayer.getExtent();
|
||||
}
|
||||
@@ -797,7 +757,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getResolution: function () {
|
||||
var resolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
resolution = this.baseLayer.getResolution();
|
||||
}
|
||||
@@ -811,9 +770,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getScale: function () {
|
||||
var scale = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
var res = this.baseLayer.getResolution();
|
||||
var res = this.getResolution();
|
||||
var units = this.baseLayer.units;
|
||||
scale = res * OpenLayers.INCHES_PER_UNIT[units] *
|
||||
OpenLayers.DOTS_PER_INCH;
|
||||
@@ -831,7 +789,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
zoom = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForExtent(bounds);
|
||||
}
|
||||
@@ -853,7 +810,9 @@ OpenLayers.Map.prototype = {
|
||||
* @param {int} zoom
|
||||
*/
|
||||
zoomTo: function(zoom) {
|
||||
this.setCenter(null, zoom);
|
||||
if (this.isValidZoomLevel(zoom)) {
|
||||
this.setCenter(null, zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -927,7 +886,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
return this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
var lonlat = null;
|
||||
if (this.baseLayer != null) {
|
||||
lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -940,7 +903,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
return this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
var px = null;
|
||||
if (this.baseLayer != null) {
|
||||
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
}
|
||||
return px;
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ OpenLayers.Tile.Image.prototype =
|
||||
*/
|
||||
clear: function() {
|
||||
OpenLayers.Tile.prototype.clear.apply(this, arguments);
|
||||
this.imgDiv.style.display = "none";
|
||||
if(this.imgDiv) {
|
||||
this.imgDiv.style.display = "none";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,8 +79,8 @@ OpenLayers.Tile.WFS.prototype =
|
||||
if (this.urls != null) {
|
||||
|
||||
for(var i=0; i < this.urls.length; i++) {
|
||||
var params = { BBOX:bounds.toBBOX() };
|
||||
var url = this.urls[i] +
|
||||
var params = { BBOX:this.bounds.toBBOX() };
|
||||
var url = this.urls[i] + "&" +
|
||||
OpenLayers.Util.getParameterString(params);
|
||||
OpenLayers.loadURL(url, null, this, success, failure);
|
||||
}
|
||||
|
||||
@@ -355,6 +355,8 @@ OpenLayers.Util.getXmlNodeValue = function(node) {
|
||||
Try.these(
|
||||
function() {
|
||||
val = node.text;
|
||||
if (!val)
|
||||
val = node.textContent;
|
||||
},
|
||||
function() {
|
||||
val = node.textContent;
|
||||
|
||||
56
news.txt
Normal file
56
news.txt
Normal file
@@ -0,0 +1,56 @@
|
||||
OpenLayers 2.0 Release Notes
|
||||
|
||||
* Deprecated Methods which were removed:
|
||||
|
||||
For details, see r1228
|
||||
|
||||
* OpenLayers.Map
|
||||
* removed: getFullExtent() -- use getMaxExtent() instead
|
||||
* removed: zoomToFullExtent() -- use zoomToMaxExtent() instead
|
||||
* OpenLayers.Layer.Grid
|
||||
* removed: setTileSize() -- user should instead pass a 'tileSize' property
|
||||
as one of the options when initializing the Grid Layer. ex:
|
||||
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
var options = {tileSize: new OpenLayers.Size(500,50)};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
|
||||
* OpenLayers.Layer.HTTPRequest
|
||||
* removed: changeParams() -- use mergeNewParams() instead
|
||||
* OpenLayers.Pixel
|
||||
* removed: copyOf() -- use clone() instead
|
||||
* OpenLayers.Size
|
||||
* removed: copyOf() -- use clone() instead
|
||||
* OpenLayers.LonLat
|
||||
* removed: copyOf() -- use clone() instead
|
||||
* OpenLayers.Bounds
|
||||
* removed: copyOf() -- use clone() instead
|
||||
* Array
|
||||
* removed: copyOf() -- use clone() instead
|
||||
|
||||
* MouseWheel
|
||||
* It is now possible to zoom in/out with the mouse wheel instead of clicks.
|
||||
|
||||
* Spiral Gridding
|
||||
* Instead of loading from the top to bottom of the map, Openlayers will
|
||||
now start loading tiles from the center of the map.
|
||||
|
||||
* Tile Re-Use
|
||||
* In order to lower memory constraints and reduce element creation times,
|
||||
OpenLayers now creates a single set of images/tiles and reuses them as
|
||||
you scroll around the map.
|
||||
|
||||
* New Layer Support
|
||||
* Google
|
||||
* Virtual Earth
|
||||
* GeoRSS (RSS 1.0 and 2.0 in FF, IE, RSS 2.0 in Safari)
|
||||
* KaMap
|
||||
* Untiled WMS
|
||||
|
||||
* Scale Based Methods
|
||||
* It is now possible to set zooms based on the concept of scale. See
|
||||
documentation in the options for the Map constructor.
|
||||
|
||||
OpenLayers 1.0
|
||||
Initial release.
|
||||
@@ -38,7 +38,10 @@ Using OpenLayers in Your Own Website
|
||||
|
||||
The examples/ directory is full of useful examples.
|
||||
|
||||
There is some documentation at http://trac.openlayers.org/ as well.
|
||||
Dcumentation is available in the doc/ directory: to build an HTML version
|
||||
of the documentation, run ./docs.sh in the build/ directory.
|
||||
|
||||
Information on changes in the API is available in news.txt.
|
||||
|
||||
--------------------------
|
||||
Contributing to OpenLayers
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<li>test_Tile.html</li>
|
||||
<li>test_Tile_Image.html</li>
|
||||
<li>test_Control.html</li>
|
||||
<li>test_Control_MouseToolbar.html</li>
|
||||
<li>test_Control_LayerSwitcher.html</li>
|
||||
<li>test_Control_PanZoom.html</li>
|
||||
<li>test_Control_PanZoomBar.html</li>
|
||||
|
||||
55
tests/test_Control_MouseToolbar.html
Normal file
55
tests/test_Control_MouseToolbar.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_MouseToolbar_constructor (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
control = new OpenLayers.Control.MouseToolbar();
|
||||
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
|
||||
}
|
||||
function test_02_Control_MouseToolbar_addControl (t) {
|
||||
t.plan( 7 );
|
||||
map = new OpenLayers.Map('map');
|
||||
control = new OpenLayers.Control.MouseToolbar();
|
||||
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
|
||||
map.addControl(control);
|
||||
t.ok( control.map === map, "Control.map is set to the map object" );
|
||||
t.ok( map.controls[2] === control, "map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Viewport div contains control div" );
|
||||
t.eq( control.div.style.top, "6px", "Control div top located correctly by default");
|
||||
|
||||
}
|
||||
function test_03_Control_MouseToolbar_control_events (t) {
|
||||
t.plan( 1 );
|
||||
var evt = {which: 1}; // control expects left-click
|
||||
map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
|
||||
control = new OpenLayers.Control.MouseToolbar();
|
||||
map.addControl(control);
|
||||
|
||||
var centerLL = new OpenLayers.LonLat(0,0);
|
||||
map.setCenter(centerLL, 5);
|
||||
|
||||
evt.shiftKey = true;
|
||||
evt.xy = new OpenLayers.Size(5,5);
|
||||
control.defaultMouseDown(evt);
|
||||
evt.xy = new OpenLayers.Size(15,15);
|
||||
control.defaultMouseUp(evt);
|
||||
t.eq(map.getZoom(), 5, "Map zoom set correctly after zoombox");
|
||||
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -20,7 +20,11 @@
|
||||
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||
map.addControl(control);
|
||||
map.pan(5, 0);
|
||||
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
|
||||
if (/MSIE/.test(navigator.userAgent)) {
|
||||
t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
|
||||
} else {
|
||||
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
|
||||
}
|
||||
}
|
||||
function test_03_Control_Permalink_updateLinksBase (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
@@ -89,19 +89,17 @@
|
||||
|
||||
function test_04_Layer_StandardOptionsAccessors (t) {
|
||||
|
||||
t.plan( 5 );
|
||||
t.plan( 4 );
|
||||
|
||||
var projection = "chicken";
|
||||
var maxExtent = new OpenLayers.Bounds(50,50,100,100);
|
||||
var maxResolution = 1.5726;
|
||||
var minZoomLevel = 5;
|
||||
var maxZoomLevel = 15;
|
||||
var numZoomLevels = 11;
|
||||
|
||||
var options = { projection: projection,
|
||||
maxExtent: maxExtent,
|
||||
maxResolution: maxResolution,
|
||||
minZoomLevel: minZoomLevel,
|
||||
maxZoomLevel: maxZoomLevel
|
||||
numZoomLevels: numZoomLevels
|
||||
};
|
||||
|
||||
var layer = new OpenLayers.Layer('Test Layer', options);
|
||||
@@ -109,8 +107,7 @@
|
||||
t.eq(layer.getProjection(), projection, "getProjection() works");
|
||||
t.ok(layer.getMaxExtent().equals(maxExtent), "getMaxExtent() works");
|
||||
t.eq(layer.getMaxResolution(), maxResolution, "getMaxResolution() works");
|
||||
t.eq(layer.getMinZoomLevel(), minZoomLevel, "getMinZoomLevel() works");
|
||||
t.eq(layer.getMaxZoomLevel(), maxZoomLevel, "getMaxZoomLevel() works");
|
||||
t.eq(layer.getNumZoomLevels(), numZoomLevels, "getNumZoomLevels() works");
|
||||
}
|
||||
|
||||
function test_05_Layer_visibility(t) {
|
||||
|
||||
@@ -56,7 +56,11 @@
|
||||
// MOUSEMOVE test does not seem to work...
|
||||
// t.plan( 2 );
|
||||
|
||||
t.plan(1);
|
||||
if (document.createEventObject) {
|
||||
t.plan(3);
|
||||
} else {
|
||||
t.plan(1);
|
||||
}
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
layer = new OpenLayers.Layer.EventPane('Test Layer');
|
||||
|
||||
@@ -114,13 +114,13 @@
|
||||
* -insertColumn
|
||||
* -insertRow
|
||||
|
||||
function test_07_Layer_Grid_moveTo(t) {
|
||||
function 07_Layer_Grid_moveTo(t) {
|
||||
}
|
||||
|
||||
function test_08_Layer_Grid_insertColumn(t) {
|
||||
function 08_Layer_Grid_insertColumn(t) {
|
||||
}
|
||||
|
||||
function test_09_Layer_Grid_insertRow(t) {
|
||||
function 09_Layer_Grid_insertRow(t) {
|
||||
}
|
||||
|
||||
*
|
||||
@@ -166,41 +166,15 @@
|
||||
}
|
||||
|
||||
|
||||
function test_11_Layer_Grid_getTile(t) {
|
||||
|
||||
t.plan(2);
|
||||
|
||||
var options = {tileSize: new OpenLayers.Size(500,50)};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
|
||||
//test with tile creation
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
//grab a reference to one of the tiles
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
var gotTile = layer.getTile(tile.id);
|
||||
|
||||
t.ok( gotTile == tile, "got right tile");
|
||||
|
||||
gotTile = layer.getTile("chicken");
|
||||
t.ok( gotTile == null, "getTile() of bogus id returns null");
|
||||
}
|
||||
|
||||
|
||||
function test_99_Layer_Grid_destroy (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
t.plan( 3 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.Grid(name, url, params);
|
||||
map.addLayer(layer);
|
||||
layer.destroy();
|
||||
t.eq( layer.grid, null, "layer.grid is null after destroy" );
|
||||
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
|
||||
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
|
||||
|
||||
|
||||
|
||||
@@ -107,13 +107,13 @@
|
||||
* -insertColumn
|
||||
* -insertRow
|
||||
|
||||
function test_07_Layer_KaMap_moveTo(t) {
|
||||
function 07_Layer_KaMap_moveTo(t) {
|
||||
}
|
||||
|
||||
function test_08_Layer_KaMap_insertColumn(t) {
|
||||
function 08_Layer_KaMap_insertColumn(t) {
|
||||
}
|
||||
|
||||
function test_09_Layer_KaMap_insertRow(t) {
|
||||
function 09_Layer_KaMap_insertRow(t) {
|
||||
}
|
||||
|
||||
*
|
||||
@@ -158,42 +158,15 @@
|
||||
t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly");
|
||||
}
|
||||
|
||||
|
||||
function test_11_Layer_KaMap_getTile(t) {
|
||||
|
||||
t.plan(2);
|
||||
|
||||
var options = {tileSize: new OpenLayers.Size(500,50)};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
|
||||
//test with tile creation
|
||||
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
//grab a reference to one of the tiles
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
var gotTile = layer.getTile(tile.id);
|
||||
|
||||
t.ok( gotTile == tile, "got right tile");
|
||||
|
||||
gotTile = layer.getTile("chicken");
|
||||
t.ok( gotTile == null, "getTile() of bogus id returns null");
|
||||
}
|
||||
|
||||
|
||||
function test_99_Layer_KaMap_destroy (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
t.plan( 3 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
|
||||
map.addLayer(layer);
|
||||
layer.destroy();
|
||||
t.eq( layer.grid, null, "layer.grid is null after destroy" );
|
||||
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
|
||||
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
t.ok( map.controls instanceof Array, "map.controls is an Array" );
|
||||
t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" );
|
||||
t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
|
||||
t.ok( map.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" );
|
||||
t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" );
|
||||
}
|
||||
function test_02_Map_center(t) {
|
||||
t.plan(3);
|
||||
@@ -63,8 +63,8 @@
|
||||
}
|
||||
function test_04_Map_options(t) {
|
||||
t.plan(2);
|
||||
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 3.14159});
|
||||
t.eq( map.maxZoomLevel, 5, "map.maxZoomLevel set correctly via options hashtable" );
|
||||
map = new OpenLayers.Map($('map'), {numZoomLevels: 6, maxResolution: 3.14159});
|
||||
t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" );
|
||||
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" );
|
||||
}
|
||||
function test_05_Map_center(t) {
|
||||
@@ -151,18 +151,10 @@
|
||||
}
|
||||
t.ok(!found, "popup.div successfully removed from the map's viewPort");
|
||||
}
|
||||
function test_10_Map_auto_res(t) {
|
||||
t.plan(2);
|
||||
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 'auto'});
|
||||
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via auto" );
|
||||
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: null});
|
||||
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via null" );
|
||||
}
|
||||
|
||||
/*** THIS IS A GOOD TEST, BUT IT SHOULD BE MOVED TO WMS.
|
||||
* Also, it won't work until we figure out the viewSize bug
|
||||
|
||||
function test_08_Map_px_lonlat_translation (t) {
|
||||
function 08_Map_px_lonlat_translation (t) {
|
||||
t.plan( 6 );
|
||||
map = new OpenLayers.Map($('map'));
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
|
||||
Reference in New Issue
Block a user