Compare commits
5 Commits
main
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edcb3d3863 | ||
|
|
6edb290f1b | ||
|
|
c7c21ea08a | ||
|
|
5f8dc06823 | ||
|
|
130e527702 |
@@ -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.
|
||||||
|
|||||||
40
examples/fullScreen.html
Normal file
40
examples/fullScreen.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
#map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
<!--
|
||||||
|
function init(){
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
|
||||||
|
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||||
|
|
||||||
|
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
|
||||||
|
"http://wms.jpl.nasa.gov/wms.cgi",
|
||||||
|
{layers: "modis,global_mosaic"});
|
||||||
|
|
||||||
|
var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
|
||||||
|
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
|
||||||
|
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
|
||||||
|
"prov_bound,fedlimit,rail,road,popplace",
|
||||||
|
transparent: "true", format: "image/png" });
|
||||||
|
|
||||||
|
map.addLayers([ol_wms, jpl_wms, dm_wms]);
|
||||||
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
}
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<div id="map"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
46
examples/getfeatureinfo.html
Normal file
46
examples/getfeatureinfo.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
ul, li { padding-left: 0px; margin-left: 0px; }
|
||||||
|
</style>
|
||||||
|
<title>World Map Query</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a id='permalink' href="">Permalink</a><br />
|
||||||
|
<div style="float:right;width:28%">
|
||||||
|
<h1 style="font-size:1.3em;">CIA Factbook</h1>
|
||||||
|
<p style='font-size:.8em;'>Click a country to see statistics about the country below.</p>
|
||||||
|
<div id="nodeList">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="map" style="width:70%; height:90%"></div>
|
||||||
|
<script defer="defer" type="text/javascript">
|
||||||
|
OpenLayers.ProxyHost = "/dev/examples/proxy.cgi?url=";
|
||||||
|
var map = new OpenLayers.Map('map', {'maxResolution':'auto'});
|
||||||
|
|
||||||
|
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
|
"http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/factbook.map", {'layers': 'factbook'} );
|
||||||
|
map.addLayer(wms);
|
||||||
|
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
map.events.register('click', map, function (e) {
|
||||||
|
var url = wms.getFullRequestString({
|
||||||
|
REQUEST: "GetFeatureInfo",
|
||||||
|
EXCEPTIONS: "application/vnd.ogc.se_xml",
|
||||||
|
BBOX: wms.map.getExtent().toBBOX(),
|
||||||
|
X: e.xy.x,
|
||||||
|
Y: e.xy.y,
|
||||||
|
INFO_FORMAT: 'text/html',
|
||||||
|
QUERY_LAYERS: wms.params.LAYERS,
|
||||||
|
WIDTH: wms.map.size.w,
|
||||||
|
HEIGHT: wms.map.size.h});
|
||||||
|
OpenLayers.loadURL(url, '', this, setHTML);
|
||||||
|
Event.stop(e);
|
||||||
|
});
|
||||||
|
function setHTML(response) {
|
||||||
|
$('nodeList').innerHTML = response.responseText;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
86
examples/layer-opacity.html
Normal file
86
examples/layer-opacity.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
#map {
|
||||||
|
width: 512px;
|
||||||
|
height: 350px;
|
||||||
|
border: 1px solid lightgray;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
width: 512px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
#opacity {
|
||||||
|
padding: 0;
|
||||||
|
text-align: center;
|
||||||
|
width: 2em;
|
||||||
|
font-family: sans-serif;
|
||||||
|
background: transparent;
|
||||||
|
color: black;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
p.note {
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 0.8em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
<!--
|
||||||
|
var map = null;
|
||||||
|
var shade = null;
|
||||||
|
var maxOpacity = 0.9;
|
||||||
|
var minOpacity = 0.1;
|
||||||
|
function changeOpacity(byOpacity) {
|
||||||
|
var newOpacity = (parseFloat($F('opacity')) + byOpacity).toFixed(1);
|
||||||
|
newOpacity = Math.min(maxOpacity,
|
||||||
|
Math.max(minOpacity, newOpacity));
|
||||||
|
$('opacity').value = newOpacity;
|
||||||
|
shade.setOpacity(newOpacity);
|
||||||
|
}
|
||||||
|
function init(){
|
||||||
|
var options = {
|
||||||
|
projection: "EPSG:26912",
|
||||||
|
units: 'm',
|
||||||
|
maxExtent: new OpenLayers.Bounds(455402, 4967657, 473295, 4984095),
|
||||||
|
maxResolution: 'auto',
|
||||||
|
maxZoomLevel: 8
|
||||||
|
};
|
||||||
|
map = new OpenLayers.Map('map', options);
|
||||||
|
var drg = new OpenLayers.Layer.WMS("Topo Maps",
|
||||||
|
"http://terraservice.net/ogcmap.ashx",
|
||||||
|
{layers: "DRG"});
|
||||||
|
shade = new OpenLayers.Layer.WMS("Shaded Relief",
|
||||||
|
"http://ims.cr.usgs.gov:80/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3",
|
||||||
|
{layers: "HR-NED.IMAGE", reaspect: "false", transparent: 'true'},
|
||||||
|
{isBaseLayer: false, opacity: 0.3});
|
||||||
|
map.addLayers([drg, shade]);
|
||||||
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
map.setCenter(new OpenLayers.LonLat(464348.5,4975876), 1);
|
||||||
|
}
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<h2>OpenLayers Layer Opacity Example</h2>
|
||||||
|
<div id="map"></div>
|
||||||
|
<p>
|
||||||
|
Note that if you also have the setOpacity method defined on the Layer
|
||||||
|
class, you can tweak the layer opacity after it has been added to the map.
|
||||||
|
</p>
|
||||||
|
<p>Opacity:
|
||||||
|
<a title="decrease opacity" href="javascript: changeOpacity(-0.1);"><<</a>
|
||||||
|
<input id="opacity" type="text" value="0.3" size="3" disabled="true" />
|
||||||
|
<a title="increase opacity" href="javascript: changeOpacity(0.1);">>></a>
|
||||||
|
</p>
|
||||||
|
<p class="note">IE users: Wait until the shade layer has finished loading to try this.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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
151
examples/scroll.html
Normal 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 & 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>
|
||||||
|
<iframe src="http://openlayers.org/viewer/"
|
||||||
|
width="400px" height="200px"
|
||||||
|
scrolling="no"
|
||||||
|
marginwidth="0" marginheight="0"
|
||||||
|
frameborder="0">
|
||||||
|
</iframe></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>
|
||||||
|
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -424,6 +424,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
|
||||||
|
|||||||
@@ -141,9 +141,12 @@ OpenLayers.Control.MouseDefaults.prototype =
|
|||||||
* @param {Event} evt
|
* @param {Event} evt
|
||||||
*/
|
*/
|
||||||
defaultMouseOut: function (evt) {
|
defaultMouseOut: function (evt) {
|
||||||
if (this.mouseDragStart != null
|
if (this.mouseDragStart != null &&
|
||||||
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||||
this.defaultMouseUp(evt);
|
if (this.zoomBox) {
|
||||||
|
this.removeZoomBox();
|
||||||
|
}
|
||||||
|
this.mouseDragStart = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -188,9 +191,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;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -62,10 +65,10 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
btn.imgLocation = imgLocation;
|
btn.imgLocation = imgLocation;
|
||||||
btn.activeImgLocation = activeImgLocation;
|
btn.activeImgLocation = activeImgLocation;
|
||||||
|
|
||||||
btn.events = new OpenLayers.Events(this, btn);
|
btn.events = new OpenLayers.Events(this, btn, null, true);
|
||||||
btn.events.register("mousedown", this, this.buttonClick);
|
btn.events.register("mousedown", this, this.buttonDown);
|
||||||
btn.events.register("mouseup", this, Event.stop);
|
btn.events.register("mouseup", this, this.buttonUp);
|
||||||
btn.events.register("click", this, Event.stop);
|
btn.events.register("dblclick", this, Event.stop);
|
||||||
btn.action = id;
|
btn.action = id;
|
||||||
btn.title = title;
|
btn.title = title;
|
||||||
btn.alt = title;
|
btn.alt = title;
|
||||||
@@ -76,11 +79,28 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
return btn;
|
return btn;
|
||||||
},
|
},
|
||||||
|
|
||||||
buttonClick: function(evt) {
|
/**
|
||||||
|
* @param {Event} evt
|
||||||
|
*/
|
||||||
|
buttonDown: function(evt) {
|
||||||
if (!Event.isLeftClick(evt)) return;
|
if (!Event.isLeftClick(evt)) return;
|
||||||
this.switchModeTo(evt.element.action);
|
this.buttonClicked = evt.element.action;
|
||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Event} evt
|
||||||
|
*/
|
||||||
|
buttonUp: function(evt) {
|
||||||
|
if (!Event.isLeftClick(evt)) return;
|
||||||
|
if (this.buttonClicked != null) {
|
||||||
|
if (this.buttonClicked == evt.element.action) {
|
||||||
|
this.switchModeTo(evt.element.action);
|
||||||
|
}
|
||||||
|
Event.stop(evt);
|
||||||
|
this.buttonClicked = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Event} evt
|
* @param {Event} evt
|
||||||
@@ -89,7 +109,7 @@ 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);
|
Event.stop(evt);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -179,6 +199,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
|
|
||||||
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 +217,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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -254,12 +285,21 @@ 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;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
"absolute");
|
"absolute");
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
|
|
||||||
this.sliderEvents = new OpenLayers.Events(this, slider);
|
this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
|
||||||
this.sliderEvents.register("mousedown", this, this.zoomBarDown);
|
this.sliderEvents.register("mousedown", this, this.zoomBarDown);
|
||||||
this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
|
this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
|
||||||
this.sliderEvents.register("mouseup", this, this.zoomBarUp);
|
this.sliderEvents.register("mouseup", this, this.zoomBarUp);
|
||||||
@@ -116,7 +116,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
|
|
||||||
this.zoombarDiv = div;
|
this.zoombarDiv = div;
|
||||||
|
|
||||||
this.divEvents = new OpenLayers.Events(this, div);
|
this.divEvents = new OpenLayers.Events(this, div, null, true);
|
||||||
this.divEvents.register("mousedown", this, this.divClick);
|
this.divEvents.register("mousedown", this, this.divClick);
|
||||||
this.divEvents.register("mousemove", this, this.passEventToSlider);
|
this.divEvents.register("mousemove", this, this.passEventToSlider);
|
||||||
this.divEvents.register("dblclick", this, this.doubleClick);
|
this.divEvents.register("dblclick", this, this.doubleClick);
|
||||||
|
|||||||
@@ -37,11 +37,14 @@ OpenLayers.Events.prototype = {
|
|||||||
* is being added
|
* is being added
|
||||||
* @param {DOMElement} element A dom element to respond to browser events
|
* @param {DOMElement} element A dom element to respond to browser events
|
||||||
* @param {Array} eventTypes Array of custom application events
|
* @param {Array} eventTypes Array of custom application events
|
||||||
|
* @param {Boolean} fallThrough Allow events to fall through after these
|
||||||
|
* have been handled?
|
||||||
*/
|
*/
|
||||||
initialize: function (object, element, eventTypes) {
|
initialize: function (object, element, eventTypes, fallThrough) {
|
||||||
this.object = object;
|
this.object = object;
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.eventTypes = eventTypes;
|
this.eventTypes = eventTypes;
|
||||||
|
this.fallThrough = fallThrough;
|
||||||
this.listeners = new Object();
|
this.listeners = new Object();
|
||||||
|
|
||||||
// if eventTypes is specified, create a listeners list for each
|
// if eventTypes is specified, create a listeners list for each
|
||||||
@@ -176,7 +179,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) {
|
||||||
|
Event.stop(evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -63,20 +63,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 +107,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 +142,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"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -322,7 +322,6 @@ OpenLayers.Layer.prototype = {
|
|||||||
this.resolutions.push(this.maxResolution / Math.pow(2, i));
|
this.resolutions.push(this.maxResolution / Math.pow(2, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.resolutions = this.resolutions.sort().reverse();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -394,7 +393,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 +409,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 - (size.w / 2);
|
||||||
center.lat - delta_y * res);
|
var delta_y = viewPortPx.y - (size.h / 2);
|
||||||
|
|
||||||
|
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||||
|
center.lat - delta_y * res);
|
||||||
|
}
|
||||||
|
return lonlat;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -429,12 +432,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;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,19 +46,16 @@ OpenLayers.Layer.WorldWind.prototype =
|
|||||||
return new OpenLayers.Tile.Image(this, position, bounds,
|
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||||
url, this.tileSize);
|
url, this.tileSize);
|
||||||
} else {
|
} else {
|
||||||
var tile = new Object();
|
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||||
tile.draw = function() {};
|
OpenLayers.Util.getImagesLocation() + "blank.gif",
|
||||||
tile.destroy = function() {};
|
this.tileSize);
|
||||||
tile.bounds = bounds;
|
|
||||||
tile.bounds = position;
|
|
||||||
return tile;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getZoom: function () {
|
getZoom: function () {
|
||||||
var zoom = this.map.getZoom();
|
var zoom = this.map.getZoom();
|
||||||
var extent = this.map.getMaxExtent();
|
var extent = this.map.getMaxExtent();
|
||||||
zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2);
|
zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2);
|
||||||
return zoom;
|
return zoom;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -71,14 +68,21 @@ OpenLayers.Layer.WorldWind.prototype =
|
|||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
getURL: function (bounds) {
|
getURL: function (bounds) {
|
||||||
|
var zoom = this.getZoom();
|
||||||
|
var extent = this.map.getMaxExtent();
|
||||||
var deg = this.lzd/Math.pow(2,this.getZoom());
|
var deg = this.lzd/Math.pow(2,this.getZoom());
|
||||||
var x = Math.floor((bounds.left - extent.left)/deg);
|
var x = Math.floor((bounds.left - extent.left)/deg);
|
||||||
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
|
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
|
||||||
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";
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -354,8 +354,7 @@ OpenLayers.Map.prototype = {
|
|||||||
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 (this.layers.indexOf(newBaseLayer) != -1) {
|
||||||
if (foundLayer) {
|
|
||||||
|
|
||||||
// make the old base layer invisible
|
// make the old base layer invisible
|
||||||
if (this.baseLayer != null) {
|
if (this.baseLayer != null) {
|
||||||
@@ -438,7 +437,9 @@ OpenLayers.Map.prototype = {
|
|||||||
removePopup: function(popup) {
|
removePopup: function(popup) {
|
||||||
this.popups.remove(popup);
|
this.popups.remove(popup);
|
||||||
if (popup.div) {
|
if (popup.div) {
|
||||||
this.layerContainerDiv.removeChild(popup.div);
|
try { this.layerContainerDiv.removeChild(popup.div); }
|
||||||
|
catch (e) { } // Popups sometimes apparently get disconnected
|
||||||
|
// from the layerContainerDiv, and cause complaints.
|
||||||
}
|
}
|
||||||
popup.map = null;
|
popup.map = null;
|
||||||
},
|
},
|
||||||
@@ -453,10 +454,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 +486,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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -664,7 +678,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;
|
||||||
},
|
},
|
||||||
@@ -992,11 +1006,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;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -30,7 +30,16 @@ OpenLayers.Marker.prototype = {
|
|||||||
initialize: function(lonlat, icon) {
|
initialize: function(lonlat, icon) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
this.lonlat = lonlat;
|
this.lonlat = lonlat;
|
||||||
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
|
|
||||||
|
var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
|
||||||
|
if (this.icon == null) {
|
||||||
|
this.icon = newIcon;
|
||||||
|
} else {
|
||||||
|
this.icon.url = newIcon.url;
|
||||||
|
this.icon.size = newIcon.size;
|
||||||
|
this.icon.offset = newIcon.offset;
|
||||||
|
this.icon.calculateOffset = newIcon.calculateOffset;
|
||||||
|
}
|
||||||
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -73,7 +82,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;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -250,18 +250,16 @@ OpenLayers.Popup.prototype = {
|
|||||||
* hyperlinks or drag-selecting text.
|
* hyperlinks or drag-selecting text.
|
||||||
*/
|
*/
|
||||||
registerEvents:function() {
|
registerEvents:function() {
|
||||||
Event.observe(this.div, "mousedown",
|
this.events = new OpenLayers.Events(this, this.div, null, true);
|
||||||
this.onmousedown.bindAsEventListener(this));
|
|
||||||
Event.observe(this.div, "mousemove",
|
this.events.register("mousedown", this, this.onmousedown);
|
||||||
this.onmousemove.bindAsEventListener(this));
|
this.events.register("mousemove", this, this.onmousemove);
|
||||||
Event.observe(this.div, "mouseup",
|
this.events.register("mouseup", this, this.onmouseup);
|
||||||
this.onmouseup.bindAsEventListener(this));
|
this.events.register("click", this,
|
||||||
Event.observe(this.div, "click",
|
OpenLayers.Util.safeStopPropagation);
|
||||||
OpenLayers.Util.safeStopPropagation);
|
this.events.register("mouseout", this, this.onmouseout);
|
||||||
Event.observe(this.div, "mouseout",
|
this.events.register("dblclick", this,
|
||||||
this.onmouseout.bindAsEventListener(this));
|
OpenLayers.Util.safeStopPropagation);
|
||||||
Event.observe(this.div, "dblclick",
|
|
||||||
OpenLayers.Util.safeStopPropagation);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** When mouse goes down within the popup, make a note of
|
/** When mouse goes down within the popup, make a note of
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ OpenLayers.Util.onImageLoadErrorColor = "pink";
|
|||||||
|
|
||||||
OpenLayers.Util.onImageLoadError = function() {
|
OpenLayers.Util.onImageLoadError = function() {
|
||||||
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
|
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
|
||||||
|
this.style.display = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_04_Bounds_contains(t) {
|
function test_04_Bounds_contains(t) {
|
||||||
t.plan( 4 );
|
t.plan( 6 );
|
||||||
bounds = new OpenLayers.Bounds(10,10,40,40);
|
bounds = new OpenLayers.Bounds(10,10,40,40);
|
||||||
t.eq( bounds.contains(20,20), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" );
|
t.eq( bounds.contains(20,20), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" );
|
||||||
t.eq( bounds.contains(0,0), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" );
|
t.eq( bounds.contains(0,0), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" );
|
||||||
t.eq( bounds.contains(40,40), true, "bounds(10,10,40,40) correctly contains LonLat(40,40) with inclusive set to true" );
|
t.eq( bounds.contains(40,40), true, "bounds(10,10,40,40) correctly contains LonLat(40,40) with inclusive set to true" );
|
||||||
t.eq( bounds.contains(40,40, false), false, "bounds(10,10,40,40) correctly does not contain LonLat(40,40) with inclusive set to false" );
|
t.eq( bounds.contains(40,40, false), false, "bounds(10,10,40,40) correctly does not contain LonLat(40,40) with inclusive set to false" );
|
||||||
|
|
||||||
|
var px = new OpenLayers.Pixel(15,30);
|
||||||
|
t.eq( bounds.containsPixel(px), bounds.contains(px.x, px.y), "containsPixel works");
|
||||||
|
|
||||||
|
var ll = new OpenLayers.LonLat(15,30);
|
||||||
|
t.eq( bounds.containsLonLat(ll), bounds.contains(ll.lon, ll.lat), "containsLonLat works");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_05_Bounds_fromString(t) {
|
function test_05_Bounds_fromString(t) {
|
||||||
|
|||||||
@@ -76,6 +76,32 @@
|
|||||||
"Layer div img contains correct url" );
|
"Layer div img contains correct url" );
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_03_Feature_onScreen(t) {
|
||||||
|
t.plan( 2 );
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
|
||||||
|
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||||
|
var wms = new OpenLayers.Layer.WMS(name, url);
|
||||||
|
|
||||||
|
map.addLayer(wms);
|
||||||
|
|
||||||
|
var layer = new OpenLayers.Layer("foo");
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
|
||||||
|
|
||||||
|
//onscreen feature
|
||||||
|
var feature1 = new OpenLayers.Feature(layer,
|
||||||
|
new OpenLayers.LonLat(0,0));
|
||||||
|
t.ok( feature1.onScreen(), "feature knows it's onscreen" );
|
||||||
|
|
||||||
|
//onscreen feature
|
||||||
|
var feature2 = new OpenLayers.Feature(layer,
|
||||||
|
new OpenLayers.LonLat(100,100));
|
||||||
|
t.ok( !feature2.onScreen(), "feature knows it's offscreen" );
|
||||||
|
}
|
||||||
|
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -126,6 +126,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_06_Layer_getZoomForResolution(t) {
|
||||||
|
|
||||||
|
t.plan(4);
|
||||||
|
|
||||||
|
var layer = new OpenLayers.Layer('Test Layer');
|
||||||
|
|
||||||
|
//make some dummy resolutions
|
||||||
|
layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
|
||||||
|
|
||||||
|
t.eq(layer.getZoomForResolution(200), 0, "zoom all the way out");
|
||||||
|
t.eq(layer.getZoomForResolution(25), 2, "zoom in middle");
|
||||||
|
t.eq(layer.getZoomForResolution(3), 5, "zoom allmost all the way in");
|
||||||
|
t.eq(layer.getZoomForResolution(1), 6, "zoom all the way in");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******
|
/******
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
function test_01_Layer_WMS_constructor (t) {
|
function test_01_Layer_WMS_constructor (t) {
|
||||||
t.plan( 4 );
|
t.plan( 4 );
|
||||||
|
|
||||||
layer = new OpenLayers.Layer.WMS();
|
|
||||||
|
|
||||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||||
t.ok( layer instanceof OpenLayers.Layer.WMS, "new OpenLayers.Layer.WMS returns object" );
|
t.ok( layer instanceof OpenLayers.Layer.WMS, "new OpenLayers.Layer.WMS returns object" );
|
||||||
|
|||||||
@@ -14,10 +14,42 @@
|
|||||||
t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" );
|
t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_02_Marker_onScreen(t) {
|
||||||
|
t.plan( 2 );
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
|
||||||
|
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||||
|
layer = new OpenLayers.Layer.WMS(name, url);
|
||||||
|
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
mlayer = new OpenLayers.Layer.Markers('Test Layer');
|
||||||
|
map.addLayer(mlayer);
|
||||||
|
|
||||||
|
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
|
||||||
|
|
||||||
|
//onscreen marker
|
||||||
|
var ll = new OpenLayers.LonLat(0,0);
|
||||||
|
var marker = new OpenLayers.Marker(ll);
|
||||||
|
mlayer.addMarker(marker);
|
||||||
|
|
||||||
|
t.ok( marker.onScreen(), "marker knows it's onscreen" );
|
||||||
|
|
||||||
|
//offscreen marker
|
||||||
|
var ll = new OpenLayers.LonLat(100,100);
|
||||||
|
var marker2 = new OpenLayers.Marker(ll);
|
||||||
|
mlayer.addMarker(marker2);
|
||||||
|
|
||||||
|
t.ok( !marker2.onScreen(), "marker knows it's offscreen" );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="map" style="width:500px;height:550px"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user