Compare commits
3 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98759ba74d | ||
|
|
5f8dc06823 | ||
|
|
130e527702 |
@@ -9,11 +9,7 @@ TMP_OUTPUT_FILENAME=tmp.${OUTPUT_FILENAME}
|
||||
|
||||
TOOLS_DIR=../tools
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
CFG_FILENAME="$1.cfg"
|
||||
else
|
||||
CFG_FILENAME=library.cfg
|
||||
fi
|
||||
CFG_FILENAME=library.cfg
|
||||
|
||||
SRC_DIR=../lib
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
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.MousePosition Control.MouseToolbar Control.OverviewMap Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util Ajax"
|
||||
CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MouseToolbar Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util"
|
||||
echo "<html>
|
||||
<head>
|
||||
<title>OpenLayers Class Reference Documentation</title>
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
[first]
|
||||
Prototype.js
|
||||
Rico/Corner.js
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/Util.js
|
||||
Rico/Corner.js
|
||||
|
||||
[last]
|
||||
|
||||
[include]
|
||||
|
||||
[exclude]
|
||||
OpenLayers/Layer/Yahoo.js
|
||||
OpenLayers/Control/KeyboardDefaults.js
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
|
||||
*/
|
||||
|
||||
/* Contains portions of Prototype.js:
|
||||
*
|
||||
* Prototype JavaScript framework, version 1.4.0
|
||||
/* Prototype JavaScript framework, version 1.4.0
|
||||
* (c) 2005 Sam Stephenson <sam@conio.net>
|
||||
*
|
||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
[first]
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/Util.js
|
||||
|
||||
[last]
|
||||
|
||||
[include]
|
||||
OpenLayers/Events.js
|
||||
OpenLayers/Map.js
|
||||
OpenLayers/Layer.js
|
||||
OpenLayers/Layer/Grid.js
|
||||
OpenLayers/Layer/HTTPRequest.js
|
||||
OpenLayers/Layer/WMS.js
|
||||
OpenLayers/Layer/WMS/Untiled.js
|
||||
OpenLayers/Tile.js
|
||||
OpenLayers/Tile/Image.js
|
||||
|
||||
[exclude]
|
||||
@@ -11,4 +11,4 @@ This control will by default display a small image in the upper right corner of
|
||||
* Parameters
|
||||
position -- (inherited from {OpenLayers.Control}) {OpenLayers.Pixel} to use as the top-left corner of the control div, relative to the map area.
|
||||
activeColor -- The color to use for the background of the layer switcher div.
|
||||
ascending -- Ascending determines whether layers are added to the layer switcher in ascending or descending order. If ascending is true, the lowest layer is appended to the list first. If ascending is false, the lowest layer is at the very bottom of the LayerSwitcher. Default is true.
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
OpenLayers.Control.MousePosition
|
||||
|
||||
A small control which displays the Longitude and Latitude of the current mouse position, by defualt in the lower right of the map viewport.
|
||||
|
||||
* Constructor
|
||||
OpenLayers.Control.MousePosition({Object|options}) -- Creates a new MousePosition control.
|
||||
|
||||
|
||||
* Parameters
|
||||
|
||||
element -- if not null, div in which to display the MousePosition
|
||||
prefix -- html to precede the longitude value (default: '')
|
||||
separator -- html to separate the longitude and latitude values (default: '<br />')
|
||||
suffix -- html to follow the latitude value (default: '')
|
||||
numdigits -- number of digits to the right of the decimal (default: 5)
|
||||
granularity -- a change of how many pixels is considered a mouse move (default: 1)
|
||||
|
||||
prefix, separator, and suffix are used to format the lon/lat values.
|
||||
|
||||
With:
|
||||
prefix = 'Lon: '
|
||||
suffix = '<br />Lat: '
|
||||
suffix = ''
|
||||
nudigits = 3
|
||||
Lon/Lat is displayed as:
|
||||
Lon: 95.123
|
||||
Lat: 35.456
|
||||
|
||||
If the mouse has never been over the map, Lon/Lat will equal 0/0. If the mouse is over the map, Lon/Lat will equal the current mouse position. If the mouse has been moved off the map, Lon/Lat will equal the value displayed at the time the mouse was moved off the map.
|
||||
|
||||
If the mouse is moving slowly, the Lon/Lat will refresh continuously. If the mouse is moving rapidly, the refresh of Lon/Lat will be suspended until the mouse has slowed down or stopped. (Trying to update the Lon/Lat value while the mouse is in rapid movemement makes the movement of the mouse unacceptably jerky.)
|
||||
|
||||
@@ -6,8 +6,6 @@ Sublass of Layer used for services which require initiating multiple HTTPRequest
|
||||
OpenLayers.Layer.HTTPRequest(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer.
|
||||
|
||||
* Methods
|
||||
initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/numZoomLevel/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming.
|
||||
initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/maxZoomLevels/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming.
|
||||
getFullRequestString(newParams) -- {String} -- Returns the full request string for a combination of the defaults on this layer and the parameters passed via newParams.
|
||||
|
||||
* Options
|
||||
reproject -- If reproject is true, then the layer will alter the bounding boxes of its tiles to be based on the geographic location of the pixel bounds in the base layer. This is important for reprojecting WMS tiles onto something like Google Maps. Tile locations are calculated, and then when creating the tile request, the bounding box is adjusted to match the bounding box of the base layer at that location.
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ of different layers.
|
||||
getZoomForExtent({OpenLayers.Bounds|bounds}) -- {Integer} -- return the integer zoom which most closely matches the passed bounds.
|
||||
getLonLatFromViewPortPx({OpenLayers.Pixel|pixel}) -- {OpenLayers.LonLat} -- Returns an OpenLayers.LonLat which is the passed-in view port OpenLayers.Pixel, translated into lon/lat by the laye
|
||||
getViewPortPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel} -- Returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into view port pixels
|
||||
addOptions({options})) -- none -- Change the options on the layer. This is the supported way to change properties of the layer.
|
||||
|
||||
* Parameters
|
||||
displayOutsideMaxExtent -- Determine whether images or data are loaded outside the maxExtent. Default is false.
|
||||
isBaseLayer -- This determines whether the layer is a base layer or an overlay. Only one Base Layer can be displayed on the map at once. Default is false.
|
||||
projection -- SRS string to describe the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.
|
||||
maxExtent -- an OpenLayers.Bounds for the layer. This is the maximum geographic extent of the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.
|
||||
@@ -32,7 +30,6 @@ of different layers.
|
||||
minScale -- The scale at zoom level 0. If this is set on the map before the Layer is added to the map, it will inherit from the map.
|
||||
maxScale -- The scale at the highest zoom level. If this is set on the map before the Layer is added to the map, it will inherit from the map.
|
||||
units -- The units the map is projected into. If this is set on the map before the Layer is added to the map, it will inherit from the map.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ Instantiate class {OpenLayers.Map} in order to create a map. This is the central
|
||||
changelayer -- a layer has some property of it, typically visibility, changed.
|
||||
changebaselayer -- the current base layer changes
|
||||
movestart -- start of a movement in the map
|
||||
move -- end of movement in a map. this happens while te mouse is dragging as well as for all other events.
|
||||
moveend -- end of movement in a map, but does not happen when the 'dragging' flag is set, as is the case when the move event is in the middle of a drag action.
|
||||
zoomend -- end of a zoom action
|
||||
mouseover -- map is moused over
|
||||
mouseout -- map is no longer mousedout
|
||||
@@ -74,4 +72,4 @@ Instantiate class {OpenLayers.Map} in order to create a map. This is the central
|
||||
* maxScale -- The maximum scale the map should include. Overrides maxZoomLevel if present.
|
||||
* units -- The units of the map. Defaults to degrees. Neccesary when using scale in any way.
|
||||
* scales -- An array of scale values. Overrides maxResolution, maxZoomLevel, resolutions, and min/max scale if present.
|
||||
|
||||
|
||||
@@ -5,4 +5,3 @@ Utility class. Stores a bunch of methods and settings that don't fit anywhere el
|
||||
* Options
|
||||
|
||||
OpenLayers.Util.onImageLoadErrorColor -- A string to set img.style.backgroundColor to if the onerror event fires for the image (useful for 500 errors from WMS, for example).
|
||||
OpenLayers.ImgPath -- A string to be used as the base for images for controls and the like. Should end with '/'.
|
||||
|
||||
@@ -10,8 +10,6 @@ Patch contributors
|
||||
------------------
|
||||
Corey Puffault
|
||||
Tim Schaub
|
||||
Jeff Dege
|
||||
Sean Gilles
|
||||
|
||||
OpenLayers is graciously supported by MetaCarta, Inc.
|
||||
<http://www.metacarta.com>.
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
Customizing OpenLayers
|
||||
======================
|
||||
|
||||
OpenLayers is designed to fit many needs -- fitting in alongside all kinds of
|
||||
various applications which are currently in use.
|
||||
|
||||
Currently, OpenLayers supports a 'theme' option when creating a map. This
|
||||
theme option allows you to specify the location of a CSS theme which should
|
||||
be included.
|
||||
|
||||
A default theme is available as an example in the theme/ directory: the setup
|
||||
is:
|
||||
|
||||
* theme/
|
||||
* theme/default/
|
||||
* theme/default/style.css
|
||||
* theme/default/img/
|
||||
|
||||
Currently, the OpenLayers code does not support class names, and therefore,
|
||||
it is not possible to control many aspects of OpenLayers code with CSS
|
||||
classes. However, with this framework in place, we expect to invest time
|
||||
to make existing features and new features use the CSS theming framework
|
||||
where apropriate.
|
||||
|
||||
|
||||
Class Naming
|
||||
============
|
||||
Elements should have class names which are descriptive of the Javascript
|
||||
class from which they come. For example, the main layer switcher element
|
||||
in the OpenLayers.Control.LayerSwitcher would be classed:
|
||||
|
||||
olControlLayerSwitcher
|
||||
|
||||
This would allow users to add to their style.css class in their theme,
|
||||
changing, for example:
|
||||
|
||||
::
|
||||
|
||||
.olControlLayerSwitcher input {
|
||||
width:10px;
|
||||
}
|
||||
|
||||
Sub elements of a particular control can add to the class name:
|
||||
|
||||
::
|
||||
|
||||
.olControlLayerSwitcherBaseLabel {
|
||||
color: red;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 100%;
|
||||
@@ -13,9 +14,7 @@
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
|
||||
<!-- Localhost key -->
|
||||
<!-- <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
|
||||
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
|
||||
<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
|
||||
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
@@ -36,18 +35,15 @@
|
||||
{layers: 'basic'} );
|
||||
var google = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
|
||||
var ve = new OpenLayers.Layer.VirtualEarth( "VE");
|
||||
var yahoo = new OpenLayers.Layer.Yahoo( "Yahoo");
|
||||
var mm = new OpenLayers.Layer.MultiMap( "MultiMap");
|
||||
|
||||
|
||||
map.addLayers([wms, google, ve, yahoo, mm]);
|
||||
map.addLayers([wms, google, ve]);
|
||||
|
||||
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.MousePosition() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,6 @@
|
||||
function init(){
|
||||
var map = new OpenLayers.Map('map', { controls: [] });
|
||||
|
||||
map.addControl(new OpenLayers.Control.PanZoomBar());
|
||||
map.addControl(new OpenLayers.Control.MouseToolbar());
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
|
||||
map.addControl(new OpenLayers.Control.Permalink());
|
||||
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
|
||||
map.addControl(new OpenLayers.Control.MousePosition());
|
||||
map.addControl(new OpenLayers.Control.OverviewMap());
|
||||
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0",
|
||||
{layers: 'basic'} );
|
||||
@@ -38,6 +31,11 @@
|
||||
dm_wms.setVisibility(false);
|
||||
|
||||
map.addLayers([ol_wms, jpl_wms, dm_wms]);
|
||||
map.addControl(new OpenLayers.Control.PanZoomBar());
|
||||
map.addControl(new OpenLayers.Control.MouseToolbar());
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.addControl(new OpenLayers.Control.Permalink());
|
||||
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
|
||||
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||
}
|
||||
// -->
|
||||
|
||||
@@ -13,28 +13,18 @@
|
||||
function init(){
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
var options = {
|
||||
resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101]
|
||||
};
|
||||
|
||||
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
|
||||
options);
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||
|
||||
var options2 = {
|
||||
resolutions: [0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101]
|
||||
};
|
||||
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
|
||||
"http://wms.jpl.nasa.gov/wms.cgi",
|
||||
{layers: "modis,global_mosaic"}, options2);
|
||||
{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"},
|
||||
{minResolution: 0.17578125,
|
||||
maxResolution: 0.703125});
|
||||
transparent: "true", format: "image/png" });
|
||||
|
||||
map.addLayers([ol_wms, jpl_wms, dm_wms]);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
|
||||
<style type="text/css">
|
||||
body { font-family: sans-serif; font-weight: bold; font-size: .8em; }
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<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>
|
||||
@@ -1,5 +1,6 @@
|
||||
<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;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<style type="text/css">
|
||||
ul, li { padding-left: 0px; margin-left: 0px; }
|
||||
</style>
|
||||
<title>World Map Query</title>
|
||||
</head>
|
||||
<body>
|
||||
<a id='permalink' href="">Permalink</a><br />
|
||||
<div style="float:right;width:28%">
|
||||
<h1 style="font-size:1.3em;">CIA Factbook</h1>
|
||||
<p style='font-size:.8em;'>Click a country to see statistics about the country below.</p>
|
||||
<div id="nodeList">
|
||||
</div>
|
||||
</div>
|
||||
<div id="map" style="width:70%; height:90%"></div>
|
||||
<script defer="defer" type="text/javascript">
|
||||
OpenLayers.ProxyHost = "/dev/examples/proxy.cgi?url=";
|
||||
var map = new OpenLayers.Map('map', {'maxResolution':'auto'});
|
||||
|
||||
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/factbook.map", {'layers': 'factbook'} );
|
||||
map.addLayer(wms);
|
||||
map.addControl(new OpenLayers.Control.Permalink($('permalink')));
|
||||
map.zoomToMaxExtent();
|
||||
map.events.register('click', map, function (e) {
|
||||
$('nodeList').innerHTML = "Loading... please wait...";
|
||||
var url = wms.getFullRequestString({
|
||||
REQUEST: "GetFeatureInfo",
|
||||
EXCEPTIONS: "application/vnd.ogc.se_xml",
|
||||
BBOX: wms.map.getExtent().toBBOX(),
|
||||
X: e.xy.x,
|
||||
Y: e.xy.y,
|
||||
INFO_FORMAT: 'text/html',
|
||||
QUERY_LAYERS: wms.params.LAYERS,
|
||||
WIDTH: wms.map.size.w,
|
||||
HEIGHT: wms.map.size.h});
|
||||
OpenLayers.loadURL(url, '', this, setHTML);
|
||||
Event.stop(e);
|
||||
});
|
||||
function setHTML(response) {
|
||||
$('nodeList').innerHTML = response.responseText;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 100%;
|
||||
@@ -10,7 +11,7 @@
|
||||
</style>
|
||||
|
||||
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
|
||||
<!-- Localhost key -->
|
||||
<!-- <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
@@ -18,35 +19,25 @@
|
||||
<!--
|
||||
var lon = 5;
|
||||
var lat = 40;
|
||||
var zoom = 17;
|
||||
var zoom = 5;
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map') ,
|
||||
{ controls: [new OpenLayers.Control.MouseDefaults()] , 'numZoomLevels':20});
|
||||
{ controls: [new OpenLayers.Control.MouseDefaults()] });
|
||||
|
||||
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':18} );
|
||||
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([satellite]);
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
|
||||
{isBaseLayer: false} );
|
||||
layer.setVisibility(false);
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
|
||||
{isBaseLayer: false} );
|
||||
layer.setVisibility(false);
|
||||
map.addLayer(layer);
|
||||
var twms = new OpenLayers.Layer.WMS( "World Map",
|
||||
"http://world.freemap.in/cgi-bin/mapserv?",
|
||||
{map: '/www/freemap.in/world/map/factbooktrans.map', transparent:'true',
|
||||
layers: 'factbook', 'format':'png'} );
|
||||
map.addLayer(twms);
|
||||
map.addLayers([satellite, normal, hybrid]);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5);
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
map.addControl( new OpenLayers.Control.PanZoomBar() );
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
#map {
|
||||
width: 512px;
|
||||
height: 350px;
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
p {
|
||||
width: 512px;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
#opacity {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
width: 2em;
|
||||
font-family: sans-serif;
|
||||
background: transparent;
|
||||
color: black;
|
||||
border: 0;
|
||||
}
|
||||
p.note {
|
||||
font-style: italic;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var map = null;
|
||||
var shade = null;
|
||||
var maxOpacity = 0.9;
|
||||
var minOpacity = 0.1;
|
||||
function changeOpacity(byOpacity) {
|
||||
var newOpacity = (parseFloat($('opacity').value) + byOpacity).toFixed(1);
|
||||
newOpacity = Math.min(maxOpacity,
|
||||
Math.max(minOpacity, newOpacity));
|
||||
$('opacity').value = newOpacity;
|
||||
shade.setOpacity(newOpacity);
|
||||
}
|
||||
function init(){
|
||||
var options = {
|
||||
projection: "EPSG:26912",
|
||||
units: 'm',
|
||||
maxExtent: new OpenLayers.Bounds(455402, 4967657, 473295, 4984095),
|
||||
maxResolution: 'auto',
|
||||
maxZoomLevel: 8
|
||||
};
|
||||
map = new OpenLayers.Map('map', options);
|
||||
var drg = new OpenLayers.Layer.WMS("Topo Maps",
|
||||
"http://terraservice.net/ogcmap.ashx",
|
||||
{layers: "DRG"});
|
||||
shade = new OpenLayers.Layer.WMS("Shaded Relief",
|
||||
"http://ims.cr.usgs.gov: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>
|
||||
@@ -1,31 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 475px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var lon = 5;
|
||||
var lat = 40;
|
||||
var zoom = 5;
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map') );
|
||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,34 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 475px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var lon = 5;
|
||||
var lat = 40;
|
||||
var zoom = 5;
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map( $('map') );
|
||||
layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
@@ -20,29 +21,20 @@
|
||||
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||
|
||||
var newl = new OpenLayers.Layer.Text( "text", { location:"./textfile.txt"} );
|
||||
map.addLayer(newl);
|
||||
|
||||
var markers = new OpenLayers.Layer.Markers( "Markers" );
|
||||
map.addLayer(markers);
|
||||
|
||||
var newl = new OpenLayers.Layer.Text( "text", { location:"./textfile.txt"} );
|
||||
map.addLayer(newl);
|
||||
var size = new OpenLayers.Size(10,17);
|
||||
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
|
||||
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',size,offset);
|
||||
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));
|
||||
|
||||
var halfIcon = icon.clone();
|
||||
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,45),halfIcon));
|
||||
|
||||
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,45),icon.clone()));
|
||||
marker = new OpenLayers.Marker(new OpenLayers.LonLat(90,10),icon.clone());
|
||||
marker.setOpacity(0.2);
|
||||
marker.events.register('mousedown', marker, function(evt) { alert(this.icon.url); Event.stop(evt); });
|
||||
markers.addMarker(marker);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
halfIcon.setOpacity(0.5);
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 100%;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
var ol_wms = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||
ol_wms.addOptions({isBaseLayer: true});
|
||||
ol_wms.isBaseLayer = true;
|
||||
map.addLayers([ol_wms]);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
@@ -37,8 +38,7 @@
|
||||
popup = new OpenLayers.Popup("chicken",
|
||||
new OpenLayers.LonLat(5,40),
|
||||
new OpenLayers.Size(200,200),
|
||||
"example popup",
|
||||
true);
|
||||
"example popup");
|
||||
|
||||
map.addPopup(popup);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ url = fs.getvalue('url', "http://openlayers.org")
|
||||
|
||||
# Designed to prevent Open Proxy type stuff.
|
||||
|
||||
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in']
|
||||
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com']
|
||||
|
||||
try:
|
||||
host = url.split("/")[2]
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
|
||||
<!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>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"http://wms.jpl.nasa.gov/wms.cgi",
|
||||
{layers: "modis,global_mosaic"});
|
||||
jpl_wms.setVisibility(false);
|
||||
ka_wms.addOptions({isBaseLayer: false});
|
||||
ka_wms.isBaseLayer = false;
|
||||
map.addLayers([jpl_wms,ka_wms]);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.addControl(new OpenLayers.Control.MouseToolbar());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 100%;
|
||||
@@ -25,16 +26,8 @@
|
||||
{controls:[new OpenLayers.Control.MouseDefaults()]});
|
||||
|
||||
velayer = new OpenLayers.Layer.VirtualEarth( "VE",
|
||||
{ minZoomLevel: 4, maxZoomLevel: 6, 'type': VEMapStyle.Aerial});
|
||||
{ minZoomLevel: 4, maxZoomLevel: 6 });
|
||||
map.addLayer(velayer);
|
||||
|
||||
var twms = new OpenLayers.Layer.WMS( "World Map",
|
||||
"http://world.freemap.in/cgi-bin/mapserv?",
|
||||
{ map: '/www/freemap.in/world/map/factbooktrans.map',
|
||||
transparent:'true',
|
||||
layers: 'factbook',
|
||||
'format':'png'} );
|
||||
map.addLayer(twms);
|
||||
|
||||
markers = new OpenLayers.Layer.Markers("markers");
|
||||
map.addLayer(markers);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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;
|
||||
|
||||
@@ -10,19 +10,20 @@
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var ol_wms, ww, ww2;
|
||||
function init(){
|
||||
var map = new OpenLayers.Map('map', {'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)});
|
||||
var map = new OpenLayers.Map('map', {'maxResolution': .0703125*4});
|
||||
|
||||
ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||
|
||||
ww = new OpenLayers.Layer.WorldWind( "Bathy",
|
||||
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4,
|
||||
{T:"bmng.topo.bathy.200406"});
|
||||
ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
|
||||
var ww = new OpenLayers.Layer.WorldWind( "Bathy",
|
||||
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4,
|
||||
{T:"bmng.topo.bathy.200406"});
|
||||
ww.setTileSize(new OpenLayers.Size(512,512));
|
||||
var ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
|
||||
"http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4,
|
||||
{T:"105"});
|
||||
ww2.setTileSize(new OpenLayers.Size(512,512));
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +37,5 @@
|
||||
<body onload="init()">
|
||||
<h1>OpenLayers Example</h1>
|
||||
<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>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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: 512px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<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;
|
||||
|
||||
BIN
img/close.gif
BIN
img/close.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 992 B |
Binary file not shown.
|
Before Width: | Height: | Size: 831 B |
Binary file not shown.
|
Before Width: | Height: | Size: 967 B |
@@ -48,10 +48,11 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
||||
*/
|
||||
(function() {
|
||||
var jsfiles=new Array(
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/Util.js",
|
||||
"Prototype.js",
|
||||
"Rico/Corner.js",
|
||||
"Rico/Color.js",
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/Util.js",
|
||||
"OpenLayers/Ajax.js",
|
||||
"OpenLayers/Events.js",
|
||||
"OpenLayers/Map.js",
|
||||
@@ -72,7 +73,6 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
||||
"OpenLayers/Layer/Yahoo.js",
|
||||
"OpenLayers/Layer/HTTPRequest.js",
|
||||
"OpenLayers/Layer/Grid.js",
|
||||
"OpenLayers/Layer/MapServer.js",
|
||||
"OpenLayers/Layer/KaMap.js",
|
||||
"OpenLayers/Layer/MultiMap.js",
|
||||
"OpenLayers/Layer/Markers.js",
|
||||
@@ -89,34 +89,29 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
||||
"OpenLayers/Control.js",
|
||||
"OpenLayers/Control/MouseDefaults.js",
|
||||
"OpenLayers/Control/MouseToolbar.js",
|
||||
"OpenLayers/Control/MousePosition.js",
|
||||
"OpenLayers/Control/OverviewMap.js",
|
||||
"OpenLayers/Control/KeyboardDefaults.js",
|
||||
"OpenLayers/Control/PanZoom.js",
|
||||
"OpenLayers/Control/PanZoomBar.js",
|
||||
"OpenLayers/Control/ArgParser.js",
|
||||
"OpenLayers/Control/Permalink.js",
|
||||
"OpenLayers/Control/Scale.js",
|
||||
"OpenLayers/Control/LayerSwitcher.js"
|
||||
"OpenLayers/Control/LayerSwitcher.js",
|
||||
"OpenLayers/Control/LayerTabs.js"
|
||||
); // etc.
|
||||
|
||||
var allScriptTags = "";
|
||||
var host = OpenLayers._getScriptLocation() + "lib/";
|
||||
|
||||
for (var i = 0; i < jsfiles.length; i++) {
|
||||
if (/MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) {
|
||||
var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";
|
||||
allScriptTags += currentScriptTag;
|
||||
} else {
|
||||
var s = document.createElement("script");
|
||||
s.src = host + jsfiles[i];
|
||||
var h = document.getElementsByTagName("head").length ?
|
||||
document.getElementsByTagName("head")[0] :
|
||||
document.body;
|
||||
h.appendChild(s);
|
||||
}
|
||||
// check to see if prototype.js was already loaded
|
||||
// if so, skip the first dynamic include
|
||||
//
|
||||
var start=1;
|
||||
try { x = Prototype; }
|
||||
catch (e) { start=0; }
|
||||
|
||||
for (var i = start; i < jsfiles.length; i++) {
|
||||
var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";
|
||||
allScriptTags += currentScriptTag;
|
||||
}
|
||||
if (allScriptTags) document.write(allScriptTags);
|
||||
document.write(allScriptTags);
|
||||
})();
|
||||
}
|
||||
OpenLayers.VERSION_NUMBER="$Revision$";
|
||||
|
||||
@@ -60,7 +60,7 @@ OpenLayers.loadURL = function(uri, params, caller,
|
||||
: OpenLayers.nullHandler;
|
||||
|
||||
// from prototype.js
|
||||
new OpenLayers.Ajax.Request(uri,
|
||||
new Ajax.Request(uri,
|
||||
{ method: 'get',
|
||||
parameters: params,
|
||||
onComplete: success,
|
||||
@@ -83,7 +83,7 @@ OpenLayers.parseXMLString = function(text) {
|
||||
text = text.substring(index);
|
||||
}
|
||||
|
||||
var ajaxResponse = OpenLayers.Util.Try(
|
||||
var ajaxResponse = Try.these(
|
||||
function() {
|
||||
var xmldom = new ActiveXObject('Microsoft.XMLDOM');
|
||||
xmldom.loadXML(text);
|
||||
@@ -106,202 +106,3 @@ OpenLayers.parseXMLString = function(text) {
|
||||
|
||||
return ajaxResponse;
|
||||
};
|
||||
|
||||
OpenLayers.Ajax = {
|
||||
emptyFunction: function () {},
|
||||
|
||||
getTransport: function() {
|
||||
return OpenLayers.Util.Try(
|
||||
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
|
||||
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
|
||||
function() {return new XMLHttpRequest()}
|
||||
) || false;
|
||||
},
|
||||
|
||||
activeRequestCount: 0
|
||||
};
|
||||
|
||||
OpenLayers.Ajax.Responders = {
|
||||
responders: [],
|
||||
|
||||
register: function(responderToAdd) {
|
||||
for (var i = 0; i < this.responders.length; i++)
|
||||
if (responderToAdd == this.responders[i])
|
||||
return;
|
||||
this.responders.push(responderToAdd);
|
||||
},
|
||||
|
||||
dispatch: function(callback, request, transport, json) {
|
||||
for (var i = 0; i < this.responders.length; i++) {
|
||||
responder = this.responders[i];
|
||||
if (responder[callback] && typeof responder[callback] == 'function') {
|
||||
try {
|
||||
responder[callback].apply(responder, [request, transport, json]);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OpenLayers.Ajax.Responders.register({
|
||||
onCreate: function() {
|
||||
OpenLayers.Ajax.activeRequestCount++;
|
||||
},
|
||||
|
||||
onComplete: function() {
|
||||
OpenLayers.Ajax.activeRequestCount--;
|
||||
}
|
||||
});
|
||||
|
||||
OpenLayers.Ajax.Base = function() {};
|
||||
OpenLayers.Ajax.Base.prototype = {
|
||||
setOptions: function(options) {
|
||||
this.options = {
|
||||
method: 'post',
|
||||
asynchronous: true,
|
||||
parameters: ''
|
||||
}
|
||||
OpenLayers.Util.extend(this.options, options || {});
|
||||
},
|
||||
|
||||
responseIsSuccess: function() {
|
||||
return this.transport.status == undefined
|
||||
|| this.transport.status == 0
|
||||
|| (this.transport.status >= 200 && this.transport.status < 300);
|
||||
},
|
||||
|
||||
responseIsFailure: function() {
|
||||
return !this.responseIsSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
OpenLayers.Ajax.Request = OpenLayers.Class.create();
|
||||
OpenLayers.Ajax.Request.Events =
|
||||
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
|
||||
|
||||
OpenLayers.Ajax.Request.prototype = OpenLayers.Class.inherit( OpenLayers.Ajax.Base, {
|
||||
initialize: function(url, options) {
|
||||
this.transport = OpenLayers.Ajax.getTransport();
|
||||
this.setOptions(options);
|
||||
this.request(url);
|
||||
},
|
||||
|
||||
request: function(url) {
|
||||
var parameters = this.options.parameters || '';
|
||||
if (parameters.length > 0) parameters += '&_=';
|
||||
|
||||
try {
|
||||
this.url = url;
|
||||
if (this.options.method == 'get' && parameters.length > 0)
|
||||
this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
|
||||
|
||||
OpenLayers.Ajax.Responders.dispatch('onCreate', this, this.transport);
|
||||
|
||||
this.transport.open(this.options.method, this.url,
|
||||
this.options.asynchronous);
|
||||
|
||||
if (this.options.asynchronous) {
|
||||
this.transport.onreadystatechange = this.onStateChange.bind(this);
|
||||
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
|
||||
}
|
||||
|
||||
this.setRequestHeaders();
|
||||
|
||||
var body = this.options.postBody ? this.options.postBody : parameters;
|
||||
this.transport.send(this.options.method == 'post' ? body : null);
|
||||
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
},
|
||||
|
||||
setRequestHeaders: function() {
|
||||
var requestHeaders =
|
||||
['X-Requested-With', 'XMLHttpRequest',
|
||||
'X-Prototype-Version', 'OpenLayers'];
|
||||
|
||||
if (this.options.method == 'post') {
|
||||
requestHeaders.push('Content-type',
|
||||
'application/x-www-form-urlencoded');
|
||||
|
||||
/* Force "Connection: close" for Mozilla browsers to work around
|
||||
* a bug where XMLHttpReqeuest sends an incorrect Content-length
|
||||
* header. See Mozilla Bugzilla #246651.
|
||||
*/
|
||||
if (this.transport.overrideMimeType)
|
||||
requestHeaders.push('Connection', 'close');
|
||||
}
|
||||
|
||||
if (this.options.requestHeaders)
|
||||
requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
|
||||
|
||||
for (var i = 0; i < requestHeaders.length; i += 2)
|
||||
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
|
||||
},
|
||||
|
||||
onStateChange: function() {
|
||||
var readyState = this.transport.readyState;
|
||||
if (readyState != 1)
|
||||
this.respondToReadyState(this.transport.readyState);
|
||||
},
|
||||
|
||||
header: function(name) {
|
||||
try {
|
||||
return this.transport.getResponseHeader(name);
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
evalJSON: function() {
|
||||
try {
|
||||
return eval(this.header('X-JSON'));
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
evalResponse: function() {
|
||||
try {
|
||||
return eval(this.transport.responseText);
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
},
|
||||
|
||||
respondToReadyState: function(readyState) {
|
||||
var event = OpenLayers.Ajax.Request.Events[readyState];
|
||||
var transport = this.transport, json = this.evalJSON();
|
||||
|
||||
if (event == 'Complete') {
|
||||
try {
|
||||
(this.options['on' + this.transport.status]
|
||||
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
|
||||
|| OpenLayers.Ajax.emptyFunction)(transport, json);
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
|
||||
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
|
||||
this.evalResponse();
|
||||
}
|
||||
|
||||
try {
|
||||
(this.options['on' + event] || OpenLayers.Ajax.emptyFunction)(transport, json);
|
||||
OpenLayers.Ajax.Responders.dispatch('on' + event, this, transport, json);
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
|
||||
/* Avoid memory leak in MSIE: clean up the oncomplete event handler */
|
||||
if (event == 'Complete')
|
||||
this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction;
|
||||
},
|
||||
|
||||
dispatchException: function(exception) {
|
||||
(this.options.onException || OpenLayers.Ajax.emptyFunction)(this, exception);
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
}
|
||||
});
|
||||
|
||||
OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, nsprefix, tagname) {
|
||||
return parentnode.getElementsByTagNameNS ?
|
||||
parentnode.getElementsByTagNameNS(nsuri, tagname)
|
||||
: parentnode.getElementsByTagName(nsprefix + ':' + tagname);
|
||||
}
|
||||
|
||||
@@ -2,36 +2,6 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/* OpenLayers.Class metaclass */
|
||||
OpenLayers.Class = {
|
||||
isPrototype: function () {}, // magic anonymous value
|
||||
|
||||
create: function() {
|
||||
return function() {
|
||||
if (arguments && arguments[0] != OpenLayers.Class.isPrototype)
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
inherit: function () {
|
||||
var superClass = arguments[0];
|
||||
var proto = new superClass(OpenLayers.Class.isPrototype);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
if (typeof arguments[i] == "function") {
|
||||
var mixin = arguments[i];
|
||||
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
|
||||
}
|
||||
OpenLayers.Util.extend(proto, arguments[i]);
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, OpenLayers.Layer.HTTPRequest, {
|
||||
some stuff
|
||||
});
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* *
|
||||
@@ -39,12 +9,13 @@ OpenLayers.Class = {
|
||||
* *
|
||||
*********************/
|
||||
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* This class represents a screen coordinate, in x and y coordinates
|
||||
*/
|
||||
OpenLayers.Pixel = OpenLayers.Class.create();
|
||||
OpenLayers.Pixel = Class.create();
|
||||
OpenLayers.Pixel.prototype = {
|
||||
|
||||
/** @type float */
|
||||
@@ -115,11 +86,7 @@ OpenLayers.Pixel.prototype = {
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
offset:function(px) {
|
||||
var newPx = this.clone();
|
||||
if (px) {
|
||||
newPx = this.add(px.x, px.y);
|
||||
}
|
||||
return newPx;
|
||||
return this.add(px.x, px.y);
|
||||
},
|
||||
|
||||
/** @final @type str */
|
||||
@@ -139,7 +106,7 @@ OpenLayers.Pixel.prototype = {
|
||||
*
|
||||
* This class represents a width and height pair
|
||||
*/
|
||||
OpenLayers.Size = OpenLayers.Class.create();
|
||||
OpenLayers.Size = Class.create();
|
||||
OpenLayers.Size.prototype = {
|
||||
|
||||
/** @type float */
|
||||
@@ -210,7 +177,7 @@ OpenLayers.Size.prototype = {
|
||||
*
|
||||
* This class represents a longitude and latitude pair
|
||||
*/
|
||||
OpenLayers.LonLat = OpenLayers.Class.create();
|
||||
OpenLayers.LonLat = Class.create();
|
||||
OpenLayers.LonLat.prototype = {
|
||||
|
||||
/** @type float */
|
||||
@@ -323,7 +290,7 @@ OpenLayers.LonLat.fromString = function(str) {
|
||||
* This class represents a bounding box.
|
||||
* Data stored as left, bottom, right, top floats
|
||||
*/
|
||||
OpenLayers.Bounds = OpenLayers.Class.create();
|
||||
OpenLayers.Bounds = Class.create();
|
||||
OpenLayers.Bounds.prototype = {
|
||||
|
||||
/** @type float */
|
||||
@@ -393,24 +360,13 @@ OpenLayers.Bounds.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} decimal How many significant digits in the bbox coords?
|
||||
* Default is 6
|
||||
*
|
||||
* @returns Simple String representation of OpenLayers.Bounds object.
|
||||
* (ex. <i>"5,42,10,45"</i>)
|
||||
* @type String
|
||||
*/
|
||||
toBBOX:function(decimal) {
|
||||
if (decimal== null) {
|
||||
decimal = 6;
|
||||
}
|
||||
var mult = Math.pow(10, decimal);
|
||||
var bbox = Math.round(this.left * mult) / mult + "," +
|
||||
Math.round(this.bottom * mult) / mult + "," +
|
||||
Math.round(this.right * mult) / mult + "," +
|
||||
Math.round(this.top * mult) / mult;
|
||||
|
||||
return bbox;
|
||||
* @return Simple String representation of OpenLayers.Bounds object.
|
||||
* (ex. <i>"5,42,10,45"</i>)
|
||||
* @type String
|
||||
*/
|
||||
toBBOX:function() {
|
||||
return (this.left + "," + this.bottom + ","
|
||||
+ this.right + "," + this.top);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -468,30 +424,6 @@ OpenLayers.Bounds.prototype = {
|
||||
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} y
|
||||
@@ -518,40 +450,7 @@ OpenLayers.Bounds.prototype = {
|
||||
}
|
||||
return contains;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} inclusive Whether or not to include the border.
|
||||
* Default is true
|
||||
*
|
||||
* @return Whether or not the passed-in OpenLayers.Bounds object intersects
|
||||
* this bounds. Simple math just check if either contains the other,
|
||||
* allowing for partial.
|
||||
* @type Boolean
|
||||
*/
|
||||
intersectsBounds:function(bounds, inclusive) {
|
||||
|
||||
if (inclusive == null) {
|
||||
inclusive = true;
|
||||
}
|
||||
var inBottom = (bounds.bottom == this.bottom && bounds.top == this.top) ?
|
||||
true : (((bounds.bottom > this.bottom) && (bounds.bottom < this.top)) ||
|
||||
((this.bottom > bounds.bottom) && (this.bottom < bounds.top)));
|
||||
var inTop = (bounds.bottom == this.bottom && bounds.top == this.top) ?
|
||||
true : (((bounds.top > this.bottom) && (bounds.top < this.top)) ||
|
||||
((this.top > bounds.bottom) && (this.top < bounds.top)));
|
||||
var inRight = (bounds.right == this.right && bounds.left == this.left) ?
|
||||
true : (((bounds.right > this.left) && (bounds.right < this.right)) ||
|
||||
((this.right > bounds.left) && (this.right < bounds.right)));
|
||||
var inLeft = (bounds.right == this.right && bounds.left == this.left) ?
|
||||
true : (((bounds.left > this.left) && (bounds.left < this.right)) ||
|
||||
((this.left > bounds.left) && (this.left < bounds.right)));
|
||||
|
||||
return (this.containsBounds(bounds, true, inclusive) ||
|
||||
bounds.containsBounds(this, true, inclusive) ||
|
||||
((inTop || inBottom ) && (inLeft || inRight )));
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} partial If true, only part of passed-in
|
||||
@@ -592,7 +491,7 @@ OpenLayers.Bounds.prototype = {
|
||||
inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top);
|
||||
}
|
||||
|
||||
return (partial) ? (inTop || inBottom ) && (inLeft || inRight )
|
||||
return (partial) ? (inTop || inBottom) && (inLeft || inRight )
|
||||
: (inTop && inLeft && inBottom && inRight);
|
||||
},
|
||||
|
||||
@@ -685,88 +584,7 @@ OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
|
||||
};
|
||||
|
||||
|
||||
/*********************
|
||||
* *
|
||||
* ELEMENT *
|
||||
* *
|
||||
*********************/
|
||||
|
||||
OpenLayers.Element = {
|
||||
visible: function(element) {
|
||||
return $(element).style.display != 'none';
|
||||
},
|
||||
|
||||
toggle: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = $(arguments[i]);
|
||||
OpenLayers.Element[OpenLayers.Element.visible(element) ? 'hide' : 'show'](element);
|
||||
}
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = $(arguments[i]);
|
||||
element.style.display = 'none';
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = $(arguments[i]);
|
||||
element.style.display = '';
|
||||
}
|
||||
},
|
||||
|
||||
remove: function(element) {
|
||||
element = $(element);
|
||||
element.parentNode.removeChild(element);
|
||||
},
|
||||
|
||||
getHeight: function(element) {
|
||||
element = $(element);
|
||||
return element.offsetHeight;
|
||||
},
|
||||
|
||||
getDimensions: function(element) {
|
||||
element = $(element);
|
||||
if (OpenLayers.Element.getStyle(element, 'display') != 'none')
|
||||
return {width: element.offsetWidth, height: element.offsetHeight};
|
||||
|
||||
// All *Width and *Height properties give 0 on elements with display none,
|
||||
// so enable the element temporarily
|
||||
var els = element.style;
|
||||
var originalVisibility = els.visibility;
|
||||
var originalPosition = els.position;
|
||||
els.visibility = 'hidden';
|
||||
els.position = 'absolute';
|
||||
els.display = '';
|
||||
var originalWidth = element.clientWidth;
|
||||
var originalHeight = element.clientHeight;
|
||||
els.display = 'none';
|
||||
els.position = originalPosition;
|
||||
els.visibility = originalVisibility;
|
||||
return {width: originalWidth, height: originalHeight};
|
||||
},
|
||||
|
||||
getStyle: function(element, style) {
|
||||
element = $(element);
|
||||
var value = element.style[style.camelize()];
|
||||
if (!value) {
|
||||
if (document.defaultView && document.defaultView.getComputedStyle) {
|
||||
var css = document.defaultView.getComputedStyle(element, null);
|
||||
value = css ? css.getPropertyValue(style) : null;
|
||||
} else if (element.currentStyle) {
|
||||
value = element.currentStyle[style.camelize()];
|
||||
}
|
||||
}
|
||||
|
||||
if (window.opera && OpenLayers.Util.indexOf(['left', 'top', 'right', 'bottom'],style) != -1)
|
||||
if (OpenLayers.Element.getStyle(element, 'position') == 'static') value = 'auto';
|
||||
|
||||
return value == 'auto' ? null : value;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*********************
|
||||
* *
|
||||
@@ -774,6 +592,8 @@ OpenLayers.Element = {
|
||||
* *
|
||||
*********************/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} sStart
|
||||
*
|
||||
@@ -815,26 +635,50 @@ String.prototype.trim = function() {
|
||||
};
|
||||
|
||||
|
||||
String.indexOf = function(object) {
|
||||
for (var i = 0; i < this.length; i++)
|
||||
if (this[i] == object) return i;
|
||||
return -1;
|
||||
|
||||
|
||||
/*********************
|
||||
* *
|
||||
* ARRAY *
|
||||
* *
|
||||
*********************/
|
||||
|
||||
|
||||
|
||||
/** Remove an object from an array. Iterates through the array
|
||||
* to find the item, then removes it.
|
||||
*
|
||||
* @param {Object} item
|
||||
*
|
||||
* @returns A reference to the array
|
||||
* @type Array
|
||||
*/
|
||||
Array.prototype.remove = function(item) {
|
||||
for(var i=0; i < this.length; i++) {
|
||||
if(this[i] == item) {
|
||||
this.splice(i,1);
|
||||
//break;more than once??
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns A fresh copy of the array
|
||||
* @type Array
|
||||
*/
|
||||
Array.prototype.clone = function() {
|
||||
var clone = new Array();
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
clone[i] = this[i];
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
String.prototype.camelize = function() {
|
||||
var oStringList = this.split('-');
|
||||
if (oStringList.length == 1) return oStringList[0];
|
||||
|
||||
var camelizedString = this.indexOf('-') == 0
|
||||
? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
|
||||
: oStringList[0];
|
||||
|
||||
for (var i = 1, len = oStringList.length; i < len; i++) {
|
||||
var s = oStringList[i];
|
||||
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
||||
}
|
||||
|
||||
return camelizedString;
|
||||
/**
|
||||
*/
|
||||
Array.prototype.clear = function() {
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -844,6 +688,8 @@ String.prototype.camelize = function() {
|
||||
* *
|
||||
*********************/
|
||||
|
||||
|
||||
|
||||
/** NOTE: Works only with integer values does *not* work with floats!
|
||||
*
|
||||
* @param {int} sig
|
||||
@@ -860,28 +706,3 @@ Number.prototype.limitSigDigs = function(sig) {
|
||||
}
|
||||
return parseInt(number);
|
||||
}
|
||||
|
||||
|
||||
/*********************
|
||||
* *
|
||||
* FUNCTION *
|
||||
* *
|
||||
*********************/
|
||||
|
||||
Function.prototype.bind = function() {
|
||||
var __method = this, args = [], object = arguments[0];
|
||||
for (var i = 1; i < arguments.length; i++)
|
||||
args.push(arguments[i]);
|
||||
return function(moreargs) {
|
||||
for (var i = 0; i < arguments.length; i++)
|
||||
args.push(arguments[i]);
|
||||
return __method.apply(object, args);
|
||||
}
|
||||
};
|
||||
|
||||
Function.prototype.bindAsEventListener = function(object) {
|
||||
var __method = this;
|
||||
return function(event) {
|
||||
return __method.call(object, event || window.event);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Control = OpenLayers.Class.create();
|
||||
OpenLayers.Control = Class.create();
|
||||
OpenLayers.Control.prototype = {
|
||||
|
||||
/** @type String */
|
||||
@@ -30,7 +30,7 @@ OpenLayers.Control.prototype = {
|
||||
* @param {Object} options
|
||||
*/
|
||||
initialize: function (options) {
|
||||
OpenLayers.Util.extend(this, options);
|
||||
Object.extend(this, options);
|
||||
|
||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
},
|
||||
@@ -63,7 +63,6 @@ OpenLayers.Control.prototype = {
|
||||
if (this.div == null) {
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.div.id = this.id;
|
||||
this.div.className = 'olControl';
|
||||
}
|
||||
if (px != null) {
|
||||
this.position = px.clone();
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.ArgParser = OpenLayers.Class.create();
|
||||
OpenLayers.Control.ArgParser.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
|
||||
/** @type OpenLayers.LonLat */
|
||||
center: null,
|
||||
|
||||
/** @type int */
|
||||
zoom: null,
|
||||
|
||||
/** @type Array */
|
||||
layers: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {DOMElement} element
|
||||
* @param {String} base
|
||||
*/
|
||||
initialize: function(element, base) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** Set the map property for the control.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
|
||||
//make sure we dont already have an arg parser attached
|
||||
for(var i=0; i< this.map.controls.length; i++) {
|
||||
var control = this.map.controls[i];
|
||||
if ( (control != this) &&
|
||||
(control.CLASS_NAME == "OpenLayers.Control.ArgParser") ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == this.map.controls.length) {
|
||||
|
||||
var args = OpenLayers.Util.getArgs();
|
||||
if (args.lat && args.lon) {
|
||||
this.center = new OpenLayers.LonLat(parseFloat(args.lon),
|
||||
parseFloat(args.lat));
|
||||
if (args.zoom) {
|
||||
this.zoom = parseInt(args.zoom);
|
||||
}
|
||||
|
||||
// when we add a new baselayer to see when we can set the center
|
||||
this.map.events.register('changebaselayer', this,
|
||||
this.setCenter);
|
||||
this.setCenter();
|
||||
}
|
||||
|
||||
if (args.layers) {
|
||||
this.layers = args.layers;
|
||||
|
||||
// when we add a new layer, set its visibility
|
||||
this.map.events.register('addlayer', this,
|
||||
this.configureLayers);
|
||||
this.configureLayers();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** As soon as a baseLayer has been loaded, we center and zoom
|
||||
* ...and remove the handler.
|
||||
*/
|
||||
setCenter: function() {
|
||||
|
||||
if (this.map.baseLayer) {
|
||||
//dont need to listen for this one anymore
|
||||
this.map.events.unregister('changebaselayer', this,
|
||||
this.setCenter);
|
||||
|
||||
this.map.setCenter(this.center, this.zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/** As soon as all the layers are loaded, cycle through them and
|
||||
* hide or show them.
|
||||
*/
|
||||
configureLayers: function() {
|
||||
|
||||
if (this.layers.length == this.map.layers.length) {
|
||||
this.map.events.unregister('addlayer', this, this.configureLayers);
|
||||
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
|
||||
var layer = this.map.layers[i];
|
||||
var c = this.layers.charAt(i);
|
||||
|
||||
if (c == "B") {
|
||||
this.map.setBaseLayer(layer);
|
||||
} else if ( (c == "T") || (c == "F") ) {
|
||||
layer.setVisibility(c == "T");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.ArgParser"
|
||||
});
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
|
||||
OpenLayers.Control.KeyboardDefaults = Class.create();
|
||||
OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type int */
|
||||
slideFactor: 50,
|
||||
@@ -25,7 +25,7 @@ OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
*
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Event.observe(document,
|
||||
Event.observe(document,
|
||||
'keypress',
|
||||
this.defaultKeyDown.bind(this));
|
||||
},
|
||||
@@ -35,16 +35,16 @@ OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
*/
|
||||
defaultKeyDown: function (evt) {
|
||||
switch(evt.keyCode) {
|
||||
case OpenLayers.Event.KEY_LEFT:
|
||||
case Event.KEY_LEFT:
|
||||
this.map.pan(-50, 0);
|
||||
break;
|
||||
case OpenLayers.Event.KEY_RIGHT:
|
||||
case Event.KEY_RIGHT:
|
||||
this.map.pan(50, 0);
|
||||
break;
|
||||
case OpenLayers.Event.KEY_UP:
|
||||
case Event.KEY_UP:
|
||||
this.map.pan(0, -50);
|
||||
break;
|
||||
case OpenLayers.Event.KEY_DOWN:
|
||||
case Event.KEY_DOWN:
|
||||
this.map.pan(0, 50);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
|
||||
OpenLayers.Control.LayerSwitcher = Class.create();
|
||||
OpenLayers.Control.LayerSwitcher.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type String */
|
||||
activeColor: "darkblue",
|
||||
@@ -43,9 +43,6 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
/** @type DOMElement */
|
||||
maximizeDiv: null,
|
||||
|
||||
/** @type Boolean */
|
||||
ascending: true,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
@@ -102,64 +99,53 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
var containsOverlays = false;
|
||||
|
||||
var layers = this.map.layers.slice();
|
||||
if (!this.ascending) { layers.reverse(); }
|
||||
for( var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
for( var i = 0; i < this.map.layers.length; i++) {
|
||||
var layer = this.map.layers[i];
|
||||
var baseLayer = layer.isBaseLayer;
|
||||
|
||||
if (baseLayer || layer.displayInLayerSwitcher) {
|
||||
|
||||
if (!baseLayer) {
|
||||
containsOverlays = true;
|
||||
}
|
||||
|
||||
// only check a baselayer if it is *the* baselayer, check data
|
||||
// layers if they are visible
|
||||
var checked = (baseLayer) ? (layer == this.map.baseLayer)
|
||||
: layer.getVisibility();
|
||||
|
||||
// create input element
|
||||
var inputElem = document.createElement("input");
|
||||
inputElem.id = "input_" + layer.name;
|
||||
inputElem.name = (baseLayer) ? "baseLayers" : layer.name;
|
||||
inputElem.type = (baseLayer) ? "radio" : "checkbox";
|
||||
inputElem.value = layer.name;
|
||||
inputElem.checked = checked;
|
||||
inputElem.defaultChecked = checked;
|
||||
inputElem.layer = layer;
|
||||
inputElem.control = this;
|
||||
|
||||
if (!baseLayer && !layer.inRange) {
|
||||
inputElem.disabled = true;
|
||||
}
|
||||
OpenLayers.Event.observe(inputElem, "mouseup",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
|
||||
// create span
|
||||
var labelSpan = document.createElement("span");
|
||||
if (!baseLayer && !layer.inRange) {
|
||||
labelSpan.style.color = "gray";
|
||||
}
|
||||
labelSpan.innerHTML = layer.name;
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline";
|
||||
OpenLayers.Event.observe(labelSpan, "click",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
|
||||
var groupArray = (baseLayer) ? this.baseLayerInputs
|
||||
: this.dataLayerInputs;
|
||||
groupArray.push(inputElem);
|
||||
|
||||
|
||||
var groupDiv = (baseLayer) ? this.baseLayersDiv
|
||||
: this.dataLayersDiv;
|
||||
groupDiv.appendChild(inputElem);
|
||||
groupDiv.appendChild(labelSpan);
|
||||
groupDiv.appendChild(br);
|
||||
if (!baseLayer) {
|
||||
containsOverlays = true;
|
||||
}
|
||||
|
||||
// only check a baselayer if it is *the* baselayer, check data
|
||||
// layers if they are visible
|
||||
var checked = (baseLayer) ? (layer == this.map.baseLayer)
|
||||
: layer.getVisibility();
|
||||
|
||||
// create input element
|
||||
var inputElem = document.createElement("input");
|
||||
inputElem.id = "input_" + layer.name;
|
||||
inputElem.name = (baseLayer) ? "baseLayers" : layer.name;
|
||||
inputElem.type = (baseLayer) ? "radio" : "checkbox";
|
||||
inputElem.value = layer.name;
|
||||
inputElem.checked = checked;
|
||||
inputElem.defaultChecked = checked;
|
||||
inputElem.layer = layer;
|
||||
inputElem.control = this;
|
||||
Event.observe(inputElem, "mouseup",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
|
||||
// create span
|
||||
var labelSpan = document.createElement("span");
|
||||
labelSpan.innerHTML = layer.name;
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline";
|
||||
Event.observe(labelSpan, "click",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
|
||||
var groupArray = (baseLayer) ? this.baseLayerInputs
|
||||
: this.dataLayerInputs;
|
||||
groupArray.push(inputElem);
|
||||
|
||||
|
||||
var groupDiv = (baseLayer) ? this.baseLayersDiv
|
||||
: this.dataLayersDiv;
|
||||
groupDiv.appendChild(inputElem);
|
||||
groupDiv.appendChild(labelSpan);
|
||||
groupDiv.appendChild(br);
|
||||
|
||||
}
|
||||
|
||||
// if no overlays, dont display the overlay label
|
||||
@@ -176,17 +162,15 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
*/
|
||||
|
||||
onInputClick: function(e) {
|
||||
if (!this.disabled) {
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
OpenLayers.Event.stop(e);
|
||||
Event.stop(e);
|
||||
},
|
||||
|
||||
/** Need to update the map accordingly whenever user clicks in either of
|
||||
@@ -238,7 +222,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.showControls(false);
|
||||
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -255,7 +239,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.showControls(true);
|
||||
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -293,13 +277,13 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.div.style.color = "white";
|
||||
this.div.style.backgroundColor = "transparent";
|
||||
|
||||
OpenLayers.Event.observe(this.div, "mouseup",
|
||||
Event.observe(this.div, "mouseup",
|
||||
this.mouseUp.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.div, "click",
|
||||
Event.observe(this.div, "click",
|
||||
this.ignoreEvent);
|
||||
OpenLayers.Event.observe(this.div, "mousedown",
|
||||
Event.observe(this.div, "mousedown",
|
||||
this.mouseDown.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
|
||||
|
||||
// layers list div
|
||||
@@ -323,12 +307,14 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
baseLbl.style.marginTop = "3px";
|
||||
baseLbl.style.marginLeft = "3px";
|
||||
baseLbl.style.marginBottom = "3px";
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||
/*OpenLayers.Event.observe(this.baseLayersDiv, "click",
|
||||
/*Event.observe(this.baseLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
|
||||
|
||||
this.dataLbl = document.createElement("div");
|
||||
@@ -336,22 +322,15 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.dataLbl.style.marginTop = "3px";
|
||||
this.dataLbl.style.marginLeft = "3px";
|
||||
this.dataLbl.style.marginBottom = "3px";
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
|
||||
this.dataLayersDiv = document.createElement("div");
|
||||
this.dataLayersDiv.style.paddingLeft = "10px";
|
||||
/*Event.observe(this.dataLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
|
||||
if (this.ascending) {
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
} else {
|
||||
this.layersDiv.appendChild(this.dataLbl);
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
this.layersDiv.appendChild(baseLbl);
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
}
|
||||
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
Rico.Corner.round(this.div, {corners: "tl bl",
|
||||
@@ -376,7 +355,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.maximizeDiv.style.right = "0px";
|
||||
this.maximizeDiv.style.left = "";
|
||||
this.maximizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
Event.observe(this.maximizeDiv,
|
||||
"click",
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
|
||||
@@ -395,7 +374,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.minimizeDiv.style.right = "0px";
|
||||
this.minimizeDiv.style.left = "";
|
||||
this.minimizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
Event.observe(this.minimizeDiv,
|
||||
"click",
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
|
||||
@@ -408,7 +387,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
ignoreEvent: function(evt) {
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/** Register a local 'mouseDown' flag so that we'll know whether or not
|
||||
|
||||
226
lib/OpenLayers/Control/LayerTabs.js
Normal file
226
lib/OpenLayers/Control/LayerTabs.js
Normal file
@@ -0,0 +1,226 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.LayerTabs = Class.create();
|
||||
|
||||
/** color used in the UI to show a layer is active/displayed
|
||||
*
|
||||
* @final
|
||||
* @type String
|
||||
*/
|
||||
OpenLayers.Control.LayerTabs.ACTIVE_COLOR = "darkblue";
|
||||
|
||||
/** color used in the UI to show a layer is deactivated/hidden
|
||||
*
|
||||
* @final
|
||||
* @type String
|
||||
*/
|
||||
OpenLayers.Control.LayerTabs.NONACTIVE_COLOR = "lightblue";
|
||||
|
||||
|
||||
OpenLayers.Control.LayerTabs.prototype =
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type String */
|
||||
activeColor: "",
|
||||
|
||||
/** @type String */
|
||||
nonActiveColor: "",
|
||||
|
||||
/** @type String */
|
||||
mode: "checkbox",
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.activeColor = OpenLayers.Control.LayerTabs.ACTIVE_COLOR;
|
||||
this.nonActiveColor = OpenLayers.Control.LayerTabs.NONACTIVE_COLOR;
|
||||
this.backdrops = [];
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function() {
|
||||
// initialize our internal div
|
||||
OpenLayers.Control.prototype.draw.apply(this);
|
||||
|
||||
this.div.style.position = "absolute";
|
||||
this.div.style.top = "10px";
|
||||
this.div.style.right = "0px";
|
||||
this.div.style.left = "";
|
||||
this.div.style.fontFamily = "sans-serif";
|
||||
this.div.style.color = "white";
|
||||
this.div.style.fontWeight = "bold";
|
||||
this.div.style.marginTop = "3px";
|
||||
this.div.style.marginLeft = "3px";
|
||||
this.div.style.marginBottom = "3px";
|
||||
this.div.style.fontSize="smaller";
|
||||
this.div.style.width = "10em";
|
||||
|
||||
this.map.events.register("addlayer", this, this.redraw);
|
||||
this.map.events.register("removelayer", this, this.redraw);
|
||||
return this.redraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||
* @type DOMElement
|
||||
*/
|
||||
redraw: function() {
|
||||
|
||||
//clear out previous incarnation of LayerTabs tabs
|
||||
this.div.innerHTML = "";
|
||||
var visible = false;
|
||||
for( var i = 0; i < this.map.layers.length; i++) {
|
||||
if (visible && this.mode == "radio") {
|
||||
this.map.layers[i].setVisibility(false);
|
||||
} else {
|
||||
visible = this.map.layers[i].getVisibility();
|
||||
}
|
||||
this.addTab(this.map.layers[i]);
|
||||
}
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
singleClick: function(evt) {
|
||||
var div = Event.element(evt);
|
||||
|
||||
// See comment about OL #57 fix below.
|
||||
// If the click occurred on the corner spans we need
|
||||
// to make sure we act on the actual label tab instead.
|
||||
div = div.labelElement || div;
|
||||
|
||||
var layer = div.layer;
|
||||
if (this.mode == "radio") {
|
||||
for(var i=0; i < this.backdrops.length; i++) {
|
||||
this.setTabActivation(this.backdrops[i], false);
|
||||
this.backdrops[i].layer.setVisibility(false);
|
||||
}
|
||||
this.setTabActivation(div, true);
|
||||
layer.setVisibility(true);
|
||||
} else {
|
||||
var visible = layer.getVisibility();
|
||||
|
||||
this.setTabActivation(div, !visible);
|
||||
layer.setVisibility(!visible);
|
||||
}
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {Event} evt
|
||||
*/
|
||||
ignoreEvent: function(evt) {
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
*/
|
||||
addTab: function(layer) {
|
||||
|
||||
// Outer DIV - for Rico Corners
|
||||
//
|
||||
var backdropLabelOuter = document.createElement('div');
|
||||
backdropLabelOuter.id = "LayerTabs_" + layer.name + "_Tab";
|
||||
backdropLabelOuter.style.marginTop = "4px";
|
||||
backdropLabelOuter.style.marginBottom = "4px";
|
||||
|
||||
this._setEventHandlers(backdropLabelOuter);
|
||||
|
||||
// Inner Label - for Rico Corners
|
||||
//
|
||||
var backdropLabel = document.createElement('p');
|
||||
backdropLabel.innerHTML = layer.name;
|
||||
backdropLabel.style.marginTop = "0px";
|
||||
backdropLabel.style.marginBottom = "0px";
|
||||
backdropLabel.style.paddingLeft = "10px";
|
||||
backdropLabel.style.paddingRight = "10px";
|
||||
|
||||
// add reference to layer onto the div for use in event handlers
|
||||
backdropLabel.layer = layer;
|
||||
|
||||
// set event handlers
|
||||
this._setEventHandlers(backdropLabel);
|
||||
|
||||
// add label to div
|
||||
backdropLabelOuter.appendChild(backdropLabel);
|
||||
|
||||
this.backdrops.push(backdropLabel);
|
||||
|
||||
// add div to main LayerTabs Div
|
||||
this.div.appendChild(backdropLabelOuter);
|
||||
|
||||
Rico.Corner.round(backdropLabelOuter, {corners: "tl bl",
|
||||
bgColor: "transparent",
|
||||
color: "white",
|
||||
blend: false});
|
||||
|
||||
// extend the event handlers to operate on the
|
||||
// rounded corners as well. (Fixes OL #57.)
|
||||
var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
|
||||
|
||||
for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
|
||||
this._setEventHandlers(spanElements[currIdx], backdropLabel);
|
||||
}
|
||||
|
||||
this.setTabActivation(backdropLabel, layer.getVisibility());
|
||||
},
|
||||
|
||||
/*
|
||||
@private
|
||||
|
||||
@param {DOMElement} div
|
||||
@param {Boolean} activate
|
||||
*/
|
||||
_setEventHandlers : function(element, labelDiv) {
|
||||
|
||||
// We only want to respond to a mousedown event.
|
||||
element.onclick = this.singleClick.bindAsEventListener(this);
|
||||
element.ondblclick = this.singleClick.bindAsEventListener(this);
|
||||
element.onmouseup = this.ignoreEvent.bindAsEventListener(this);
|
||||
element.onmousedown = this.ignoreEvent.bindAsEventListener(this);
|
||||
|
||||
// If we are operating on a corner span we need to store a
|
||||
// reference to the actual tab. (See comment about OL #57 fix above.)
|
||||
if (labelDiv) {
|
||||
element.labelElement = labelDiv;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {DOMElement} div
|
||||
* @param {Boolean} activate
|
||||
*/
|
||||
setTabActivation:function(div, activate) {
|
||||
var color = (activate) ? this.activeColor : this.nonActiveColor;
|
||||
Rico.Corner.changeColor(div, color);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.LayerTabs"
|
||||
});
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.MouseDefaults = OpenLayers.Class.create();
|
||||
OpenLayers.Control.MouseDefaults = Class.create();
|
||||
OpenLayers.Control.MouseDefaults.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type Boolean */
|
||||
performedDrag: false,
|
||||
@@ -21,11 +21,11 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
|
||||
//register mousewheel events specifically on the window and document
|
||||
OpenLayers.Event.observe(window, "DOMMouseScroll",
|
||||
Event.observe(window, "DOMMouseScroll",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(window, "mousewheel",
|
||||
Event.observe(window, "mousewheel",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(document, "mousewheel",
|
||||
Event.observe(document, "mousewheel",
|
||||
this.onWheelEvent.bindAsEventListener(this));
|
||||
},
|
||||
|
||||
@@ -47,7 +47,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
* @type Boolean
|
||||
*/
|
||||
defaultClick: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
var notAfterDrag = !this.performedDrag;
|
||||
this.performedDrag = false;
|
||||
return notAfterDrag;
|
||||
@@ -59,7 +59,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
defaultDblClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -67,7 +67,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
defaultMouseDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
if (evt.shiftKey) {
|
||||
@@ -86,7 +86,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
}
|
||||
document.onselectstart=function() { return false; }
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -124,7 +124,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomBox) {
|
||||
this.zoomBoxEnd(evt);
|
||||
} else {
|
||||
@@ -179,7 +179,11 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
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);
|
||||
this.map.zoomToExtent(bounds);
|
||||
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(
|
||||
@@ -213,7 +217,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
|
||||
// first determine whether or not the wheeling was inside the map
|
||||
var inMap = false;
|
||||
var elem = OpenLayers.Event.element(e);
|
||||
var elem = Event.element(e);
|
||||
while(elem != null) {
|
||||
if (this.map && elem == this.map.div) {
|
||||
inMap = true;
|
||||
@@ -245,7 +249,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
}
|
||||
|
||||
//only wheel the map, not the window
|
||||
OpenLayers.Event.stop(e);
|
||||
Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.MousePosition = OpenLayers.Class.create();
|
||||
OpenLayers.Control.MousePosition.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
|
||||
/** @type DOMElement */
|
||||
element: null,
|
||||
|
||||
/** @type String */
|
||||
prefix: '',
|
||||
|
||||
/** @type String */
|
||||
separator: ', ',
|
||||
|
||||
/** @type String */
|
||||
suffix: '',
|
||||
|
||||
/** @type int */
|
||||
numdigits: 5,
|
||||
|
||||
/** @type int */
|
||||
granularity: 1,
|
||||
|
||||
/** @type OpenLayers.LonLat */
|
||||
lastXy: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {DOMElement} options Options for control.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
if (!this.element) {
|
||||
this.div.left = "";
|
||||
this.div.top = "";
|
||||
this.div.className = "olControlMousePosition";
|
||||
this.element = this.div;
|
||||
}
|
||||
|
||||
this.redraw();
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
redraw: function(evt) {
|
||||
|
||||
var lonLat;
|
||||
|
||||
if (evt == null) {
|
||||
lonLat = new OpenLayers.LonLat(0, 0);
|
||||
} else {
|
||||
if (this.lastXy == null ||
|
||||
Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||
|
||||
Math.abs(evt.xy.y - this.lastXy.y) > this.granularity)
|
||||
{
|
||||
this.lastXy = evt.xy;
|
||||
return;
|
||||
}
|
||||
|
||||
lonLat = this.map.getLonLatFromPixel(evt.xy);
|
||||
this.lastXy = evt.xy;
|
||||
}
|
||||
|
||||
var digits = parseInt(this.numdigits);
|
||||
var newHtml =
|
||||
this.prefix +
|
||||
lonLat.lon.toFixed(digits) +
|
||||
this.separator +
|
||||
lonLat.lat.toFixed(digits) +
|
||||
this.suffix;
|
||||
|
||||
if (newHtml != this.element.innerHTML) {
|
||||
this.element.innerHTML = newHtml;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
setMap: function() {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
this.map.events.register( 'mousemove', this, this.redraw);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.MousePosition"
|
||||
});
|
||||
@@ -8,11 +8,12 @@
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/MouseDefaults.js
|
||||
*/
|
||||
OpenLayers.Control.MouseToolbar = OpenLayers.Class.create();
|
||||
OpenLayers.Control.MouseToolbar = Class.create();
|
||||
OpenLayers.Control.MouseToolbar.X = 6;
|
||||
OpenLayers.Control.MouseToolbar.Y = 300;
|
||||
OpenLayers.Control.MouseToolbar.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control.MouseDefaults, {
|
||||
Object.extend( new OpenLayers.Control(),
|
||||
Object.extend( new OpenLayers.Control.MouseDefaults(), {
|
||||
|
||||
mode: null,
|
||||
|
||||
@@ -67,7 +68,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
btn.events = new OpenLayers.Events(this, btn, null, true);
|
||||
btn.events.register("mousedown", this, this.buttonDown);
|
||||
btn.events.register("mouseup", this, this.buttonUp);
|
||||
btn.events.register("dblclick", this, OpenLayers.Event.stop);
|
||||
btn.events.register("dblclick", this, Event.stop);
|
||||
btn.action = id;
|
||||
btn.title = title;
|
||||
btn.alt = title;
|
||||
@@ -82,21 +83,21 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
buttonDown: function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.buttonClicked = evt.element.action;
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
buttonUp: function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.buttonClicked != null) {
|
||||
if (this.buttonClicked == evt.element.action) {
|
||||
this.switchModeTo(evt.element.action);
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
this.buttonClicked = null;
|
||||
}
|
||||
},
|
||||
@@ -109,7 +110,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.performedDrag = false;
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -117,7 +118,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
defaultMouseDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
this.startViaKeyboard = false;
|
||||
@@ -193,7 +194,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
break;
|
||||
}
|
||||
document.onselectstart = function() { return false; }
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
switchModeTo: function(mode) {
|
||||
@@ -268,7 +269,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
this.zoomBoxEnd(evt);
|
||||
@@ -305,5 +306,5 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,511 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Locator Map Control
|
||||
* @author Tim Schaub
|
||||
*/
|
||||
|
||||
// @require: OpenLayers/Control.js
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Control.OverviewMap = OpenLayers.Class.create();
|
||||
|
||||
OpenLayers.Control.OverviewMap.prototype =
|
||||
OpenLayers.Util.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** For div.id
|
||||
* @type String */
|
||||
id: "OverviewMap",
|
||||
|
||||
/** @type DOMElement */
|
||||
element: null,
|
||||
|
||||
/**
|
||||
* The overvew map itself.
|
||||
* @type OpenLayers.Map
|
||||
*/
|
||||
ovmap: null,
|
||||
|
||||
/**
|
||||
* Ordered list of layers in the overview map. If none are sent at
|
||||
* construction, then the default below is used.
|
||||
*
|
||||
* @type Array(OpenLayers.Layer)
|
||||
*/
|
||||
layers: [],
|
||||
|
||||
/**
|
||||
* The ratio of the overview map resolution to the main map resolution
|
||||
* at which to zoom farther out on the overview map.
|
||||
* @type Float
|
||||
*/
|
||||
minRatio: 8,
|
||||
|
||||
/**
|
||||
* The ratio of the overview map resolution to the main map resolution
|
||||
* at which to zoom farther in on the overview map.
|
||||
* @type Float
|
||||
*/
|
||||
maxRatio: 32,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} options Hashtable of options to set on the overview map
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
if(!(this.layers.length > 0)) {
|
||||
if (this.map.baseLayer) {
|
||||
var layer = this.map.baseLayer.clone();
|
||||
this.layers = [layer];
|
||||
} else {
|
||||
this.map.events.register("changebaselayer", this, this.baseLayerDraw);
|
||||
return this.div;
|
||||
}
|
||||
}
|
||||
|
||||
// create overview map DOM elements
|
||||
this.element = document.createElement('div');
|
||||
this.element.className = 'olControlOverviewMapElement';
|
||||
this.element.style.display = 'none';
|
||||
|
||||
this.mapDiv = document.createElement('div');
|
||||
this.mapDiv.style.width = '180px';
|
||||
this.mapDiv.style.height = '90px';
|
||||
this.mapDiv.style.position = 'relative';
|
||||
this.mapDiv.style.overflow = 'hidden';
|
||||
this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');
|
||||
|
||||
this.extentRectangle = document.createElement('div');
|
||||
this.extentRectangle.style.position = 'absolute';
|
||||
this.extentRectangle.style.zIndex = 1000; //HACK
|
||||
this.extentRectangle.style.backgroundImage = 'url(' +
|
||||
OpenLayers.Util.getImagesLocation() +
|
||||
'/blank.png)';
|
||||
this.extentRectangle.className = 'olControlOverviewMapExtentRectangle';
|
||||
this.mapDiv.appendChild(this.extentRectangle);
|
||||
|
||||
this.element.appendChild(this.mapDiv);
|
||||
|
||||
this.div.appendChild(this.element);
|
||||
this.div.className = 'olControlOverviewMapContainer';
|
||||
|
||||
this.map.events.register('moveend', this, this.update);
|
||||
|
||||
// Set up events. The image div recenters the map on click.
|
||||
// The extent rectangle can be dragged to recenter the map.
|
||||
// If the mousedown happened elsewhere, then mousemove and mouseup
|
||||
// should slip through.
|
||||
this.elementEvents = new OpenLayers.Events(this, this.element);
|
||||
this.elementEvents.register('mousedown', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.elementEvents.register('click', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.elementEvents.register('dblclick', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle);
|
||||
this.rectEvents.register('mouseover', this, this.rectMouseOver);
|
||||
this.rectEvents.register('mouseout', this, this.rectMouseOut);
|
||||
this.rectEvents.register('mousedown', this, this.rectMouseDown);
|
||||
this.rectEvents.register('mousemove', this, this.rectMouseMove);
|
||||
this.rectEvents.register('mouseup', this, this.rectMouseUp);
|
||||
this.rectEvents.register('click', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.rectEvents.register('dblclick', this, this.rectDblClick );
|
||||
this.mapDivEvents = new OpenLayers.Events(this, this.mapDiv);
|
||||
this.mapDivEvents.register('click', this, this.mapDivClick);
|
||||
|
||||
// There should be an option to place the control outside of the
|
||||
// map viewport. This would make these buttons optional.
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
// maximize button div
|
||||
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
'olControlOverviewMapMaximizeButton',
|
||||
null,
|
||||
new OpenLayers.Size(18,18),
|
||||
img,
|
||||
'absolute');
|
||||
this.maximizeDiv.style.display = 'none';
|
||||
this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton';
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
'click',
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
// minimize button div
|
||||
var img = imgLocation + 'layer-switcher-minimize.png';
|
||||
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
'OpenLayers_Control_minimizeDiv',
|
||||
null,
|
||||
new OpenLayers.Size(18,18),
|
||||
img,
|
||||
'absolute');
|
||||
this.minimizeDiv.style.display = 'none';
|
||||
this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton';
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
'click',
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
|
||||
this.minimizeControl();
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
baseLayerDraw: function() {
|
||||
this.draw();
|
||||
this.map.events.unregister("changebaselayer", this, this.baseLayerDraw);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectMouseOver: function (evt) {
|
||||
this.extentRectangle.style.cursor = 'move';
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectMouseOut: function (evt) {
|
||||
this.extentRectangle.style.cursor = 'default';
|
||||
if(this.rectDragStart != null) {
|
||||
if(this.performedRectDrag) {
|
||||
this.updateMapToRect();
|
||||
}
|
||||
document.onselectstart = null;
|
||||
this.rectDragStart = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectMouseDown: function (evt) {
|
||||
if(!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
this.rectDragStart = evt.xy.clone();
|
||||
this.performedRectDrag = false;
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectMouseMove: function(evt) {
|
||||
if(this.rectDragStart != null) {
|
||||
var deltaX = this.rectDragStart.x - evt.xy.x;
|
||||
var deltaY = this.rectDragStart.y - evt.xy.y;
|
||||
var rectPxBounds = this.getRectPxBounds();
|
||||
var rectTop = rectPxBounds.top;
|
||||
var rectLeft = rectPxBounds.left;
|
||||
var rectHeight = Math.abs(rectPxBounds.getHeight());
|
||||
var rectWidth = rectPxBounds.getWidth();
|
||||
// don't allow dragging off of parent element
|
||||
var newTop = Math.max(0, (rectTop - deltaY));
|
||||
newTop = Math.min(newTop,
|
||||
this.ovmap.size.h - this.hComp - rectHeight);
|
||||
var newLeft = Math.max(0, (rectLeft - deltaX));
|
||||
newLeft = Math.min(newLeft,
|
||||
this.ovmap.size.w - this.wComp - rectWidth);
|
||||
this.setRectPxBounds(new OpenLayers.Bounds(newLeft,
|
||||
newTop + rectHeight,
|
||||
newLeft + rectWidth,
|
||||
newTop));
|
||||
this.rectDragStart = evt.xy.clone();
|
||||
this.performedRectDrag = true;
|
||||
OpenLayers.Event.stop(evt);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectMouseUp: function(evt) {
|
||||
if(!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if(this.performedRectDrag) {
|
||||
this.updateMapToRect();
|
||||
OpenLayers.Event.stop(evt);
|
||||
}
|
||||
document.onselectstart = null;
|
||||
this.rectDragStart = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
rectDblClick: function(evt) {
|
||||
this.performedRectDrag = false;
|
||||
OpenLayers.Event.stop(evt);
|
||||
this.updateOverview();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Event} evt
|
||||
*/
|
||||
mapDivClick: function(evt) {
|
||||
var pxBounds = this.getRectPxBounds();
|
||||
var pxCenter = pxBounds.getCenterPixel();
|
||||
var deltaX = evt.xy.x - pxCenter.x;
|
||||
var deltaY = evt.xy.y - pxCenter.y;
|
||||
var top = pxBounds.top;
|
||||
var left = pxBounds.left;
|
||||
var height = Math.abs(pxBounds.getHeight());
|
||||
var width = pxBounds.getWidth();
|
||||
var newTop = Math.max(0, (top + deltaY));
|
||||
newTop = Math.min(newTop, this.ovmap.size.h - height);
|
||||
var newLeft = Math.max(0, (left + deltaX));
|
||||
newLeft = Math.min(newLeft, this.ovmap.size.w - width);
|
||||
this.setRectPxBounds(new OpenLayers.Bounds(newLeft,
|
||||
newTop + height,
|
||||
newLeft + width,
|
||||
newTop));
|
||||
this.updateMapToRect();
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/** Set up the labels and divs for the control
|
||||
*
|
||||
* @param {OpenLayers.Event} e
|
||||
*/
|
||||
maximizeControl: function(e) {
|
||||
this.element.style.display = '';
|
||||
this.showToggle(false);
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
/** Hide all the contents of the control, shrink the size,
|
||||
* add the maximize icon
|
||||
*
|
||||
* @param {OpenLayers.Event} e
|
||||
*/
|
||||
minimizeControl: function(e) {
|
||||
this.element.style.display = 'none';
|
||||
this.showToggle(true);
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
/** Hide/Show all LayerSwitcher controls depending on whether we are
|
||||
* minimized or not
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Boolean} minimize
|
||||
*/
|
||||
showToggle: function(minimize) {
|
||||
this.maximizeDiv.style.display = minimize ? '' : 'none';
|
||||
this.minimizeDiv.style.display = minimize ? 'none' : '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the overview map after layers move.
|
||||
*/
|
||||
update: function() {
|
||||
if(this.ovmap == null) {
|
||||
this.createMap();
|
||||
}
|
||||
|
||||
if(!this.isSuitableOverview()) {
|
||||
this.updateOverview();
|
||||
}
|
||||
|
||||
// update extent rectangle
|
||||
this.updateRectToMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines if the overview map is suitable given the extent and
|
||||
* resolution of the main map.
|
||||
*/
|
||||
isSuitableOverview: function() {
|
||||
var mapExtent = this.map.getExtent();
|
||||
var maxExtent = this.map.maxExtent;
|
||||
var testExtent = new OpenLayers.Bounds(
|
||||
Math.max(mapExtent.left, maxExtent.left),
|
||||
Math.max(mapExtent.bottom, maxExtent.bottom),
|
||||
Math.min(mapExtent.right, maxExtent.right),
|
||||
Math.min(mapExtent.top, maxExtent.top));
|
||||
var resRatio = this.ovmap.getResolution() / this.map.getResolution();
|
||||
return ((resRatio > this.minRatio) &&
|
||||
(resRatio <= this.maxRatio) &&
|
||||
(this.ovmap.getExtent().containsBounds(testExtent)));
|
||||
},
|
||||
|
||||
updateOverview: function() {
|
||||
var mapRes = this.map.getResolution();
|
||||
var targetRes = this.ovmap.getResolution();
|
||||
var resRatio = targetRes / mapRes;
|
||||
if(resRatio > this.maxRatio) {
|
||||
// zoom in overview map
|
||||
targetRes = this.minRatio * mapRes;
|
||||
} else if(resRatio <= this.minRatio) {
|
||||
// zoom out overview map
|
||||
targetRes = this.maxRatio * mapRes;
|
||||
}
|
||||
this.ovmap.setCenter(this.map.center,
|
||||
this.ovmap.getZoomForResolution(targetRes));
|
||||
this.updateRectToMap();
|
||||
},
|
||||
|
||||
createMap: function() {
|
||||
// create the overview map
|
||||
this.ovmap = new OpenLayers.Map(this.mapDiv.id, {controls: [], maxResolution: 'auto'});
|
||||
this.ovmap.addLayers(this.layers);
|
||||
this.ovmap.zoomToMaxExtent();
|
||||
// check extent rectangle border width
|
||||
this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
|
||||
'border-left-width')) +
|
||||
parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
|
||||
'border-right-width'));
|
||||
this.wComp = (this.wComp) ? this.wComp : 2;
|
||||
this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
|
||||
'border-top-width')) +
|
||||
parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
|
||||
'border-bottom-width'));
|
||||
this.hComp = (this.hComp) ? this.hComp : 2;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the extent rectangle position and size to match the map extent
|
||||
*/
|
||||
updateRectToMap: function() {
|
||||
if(this.map.units != 'degrees') {
|
||||
if(this.map.projection != this.ovmap.map.projection) {
|
||||
alert('The overview map only works when it is in the same projection as the main map');
|
||||
}
|
||||
}
|
||||
var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent());
|
||||
this.setRectPxBounds(pxBounds);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the map extent to match the extent rectangle position and size
|
||||
*/
|
||||
updateMapToRect: function() {
|
||||
var pxBounds = this.getRectPxBounds();
|
||||
var lonLatBounds = this.getMapBoundsFromRectBounds(pxBounds);
|
||||
this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get extent rectangle pixel bounds
|
||||
* @returns An OpenLayers.Bounds wich is the extent rectangle's pixel
|
||||
* bounds (relative to the parent element)
|
||||
*/
|
||||
getRectPxBounds: function() {
|
||||
var top = parseInt(this.extentRectangle.style.top);
|
||||
var left = parseInt(this.extentRectangle.style.left);
|
||||
var height = parseInt(this.extentRectangle.style.height);
|
||||
var width = parseInt(this.extentRectangle.style.width);
|
||||
return new OpenLayers.Bounds(left, top + height, left + width, top);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set extent rectangle pixel bounds.
|
||||
* @param {OpenLayers.Bounds} pxBounds
|
||||
*/
|
||||
setRectPxBounds: function(pxBounds) {
|
||||
var top = Math.max(pxBounds.top, 0);
|
||||
var left = Math.max(pxBounds.left, 0);
|
||||
var bottom = Math.min(pxBounds.top + Math.abs(pxBounds.getHeight()),
|
||||
this.ovmap.size.h - this.hComp);
|
||||
var right = Math.min(pxBounds.left + pxBounds.getWidth(),
|
||||
this.ovmap.size.w - this.wComp);
|
||||
this.extentRectangle.style.top = parseInt(top) + 'px';
|
||||
this.extentRectangle.style.left = parseInt(left) + 'px';
|
||||
this.extentRectangle.style.height = parseInt(bottom - top)+ 'px';
|
||||
this.extentRectangle.style.width = parseInt(right - left) + 'px';
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} lonLatBounds
|
||||
*
|
||||
* @returns An OpenLayers.Bounds which is the passed-in map lon/lat extent
|
||||
* translated into pixel bounds for the overview map
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getRectBoundsFromMapBounds: function(lonLatBounds) {
|
||||
var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left,
|
||||
lonLatBounds.bottom);
|
||||
var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right,
|
||||
lonLatBounds.top);
|
||||
var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat);
|
||||
var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat);
|
||||
return new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
|
||||
rightTopPx.x, rightTopPx.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} pxBounds
|
||||
*
|
||||
* @returns An OpenLayers.Bounds which is the passed-in overview rect bounds
|
||||
* translated into lon/lat bounds for the overview map
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getMapBoundsFromRectBounds: function(pxBounds) {
|
||||
var leftBottomPx = new OpenLayers.Pixel(pxBounds.left,
|
||||
pxBounds.bottom);
|
||||
var rightTopPx = new OpenLayers.Pixel(pxBounds.right,
|
||||
pxBounds.top);
|
||||
var leftBottomLonLat = this.getLonLatFromOverviewPx(leftBottomPx);
|
||||
var rightTopLonLat = this.getLonLatFromOverviewPx(rightTopPx);
|
||||
return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,
|
||||
rightTopLonLat.lon, rightTopLonLat.lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} overviewMapPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in overview map
|
||||
* OpenLayers.Pixel, translated into lon/lat by the overview map
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getLonLatFromOverviewPx: function(overviewMapPx) {
|
||||
var size = this.ovmap.size;
|
||||
var res = this.ovmap.getResolution();
|
||||
var center = this.ovmap.getExtent().getCenterLonLat();
|
||||
|
||||
var delta_x = overviewMapPx.x - (size.w / 2);
|
||||
var delta_y = overviewMapPx.y - (size.h / 2);
|
||||
|
||||
return new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into overview map pixels
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOverviewPxFromLonLat: function(lonlat) {
|
||||
var res = this.ovmap.getResolution();
|
||||
var extent = this.ovmap.getExtent();
|
||||
return new OpenLayers.Pixel(
|
||||
Math.round(1/res * (lonlat.lon - extent.left)),
|
||||
Math.round(1/res * (extent.top - lonlat.lat))
|
||||
);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: 'OpenLayers.Control.OverviewMap'
|
||||
|
||||
});
|
||||
@@ -7,11 +7,11 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.PanZoom = OpenLayers.Class.create();
|
||||
OpenLayers.Control.PanZoom = Class.create();
|
||||
OpenLayers.Control.PanZoom.X = 4;
|
||||
OpenLayers.Control.PanZoom.Y = 4;
|
||||
OpenLayers.Control.PanZoom.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type int */
|
||||
slideFactor: 50,
|
||||
@@ -101,7 +101,7 @@ OpenLayers.Control.PanZoom.prototype =
|
||||
* @type Boolean
|
||||
*/
|
||||
doubleClick: function (evt) {
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -109,7 +109,7 @@ OpenLayers.Control.PanZoom.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
buttonDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
|
||||
switch (this.action) {
|
||||
case "panup":
|
||||
@@ -135,7 +135,7 @@ OpenLayers.Control.PanZoom.prototype =
|
||||
break;
|
||||
}
|
||||
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
*
|
||||
* @requires OpenLayers/Control/PanZoom.js
|
||||
*/
|
||||
OpenLayers.Control.PanZoomBar = OpenLayers.Class.create();
|
||||
OpenLayers.Control.PanZoomBar = Class.create();
|
||||
OpenLayers.Control.PanZoomBar.X = 4;
|
||||
OpenLayers.Control.PanZoomBar.Y = 4;
|
||||
OpenLayers.Control.PanZoomBar.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control.PanZoom, {
|
||||
Object.extend( new OpenLayers.Control.PanZoom(), {
|
||||
|
||||
/** @type Array(...) */
|
||||
buttons: null,
|
||||
@@ -147,12 +147,12 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
* and sets the zoom level appropriately.
|
||||
*/
|
||||
divClick: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
var y = evt.xy.y;
|
||||
var top = OpenLayers.Util.pagePosition(evt.object)[1];
|
||||
var top = Position.page(evt.object)[1];
|
||||
var levels = Math.floor((y - top)/this.zoomStopHeight);
|
||||
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -160,13 +160,13 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
* event listener for clicks on the slider
|
||||
*/
|
||||
zoomBarDown:function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.map.events.register("mousemove", this, this.passEventToSlider);
|
||||
this.map.events.register("mouseup", this, this.passEventToSlider);
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.zoomStart = evt.xy.clone();
|
||||
this.div.style.cursor = "move";
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -178,14 +178,14 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
zoomBarDrag:function(evt) {
|
||||
if (this.mouseDragStart != null) {
|
||||
var deltaY = this.mouseDragStart.y - evt.xy.y
|
||||
var offsets = OpenLayers.Util.pagePosition(this.zoombarDiv);
|
||||
var offsets = Position.page(this.zoombarDiv);
|
||||
if ((evt.clientY - offsets[1]) > 0 &&
|
||||
(evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {
|
||||
var newTop = parseInt(this.slider.style.top) - deltaY;
|
||||
this.slider.style.top = newTop+"px";
|
||||
}
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -195,7 +195,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
* and switch to it.
|
||||
*/
|
||||
zoomBarUp:function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) return;
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomStart) {
|
||||
this.div.style.cursor="default";
|
||||
this.map.events.unregister("mouseup", this, this.passEventToSlider);
|
||||
@@ -204,7 +204,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
||||
this.moveZoomBar();
|
||||
this.mouseDragStart = null;
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.Permalink = OpenLayers.Class.create();
|
||||
OpenLayers.Control.Permalink = Class.create();
|
||||
OpenLayers.Control.Permalink.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
|
||||
/** @type DOMElement */
|
||||
element: null,
|
||||
|
||||
/** @type String */
|
||||
base: '',
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -26,29 +26,7 @@ OpenLayers.Control.Permalink.prototype =
|
||||
initialize: function(element, base) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
this.element = element;
|
||||
if (base) {
|
||||
this.base = base;
|
||||
}
|
||||
},
|
||||
|
||||
/** Set the map property for the control.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
|
||||
//make sure we have an arg parser attached
|
||||
for(var i=0; i< this.map.controls.length; i++) {
|
||||
var control = this.map.controls[i];
|
||||
if (control.CLASS_NAME == "OpenLayers.Control.ArgParser") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == this.map.controls.length) {
|
||||
this.map.addControl(new OpenLayers.Control.ArgParser());
|
||||
}
|
||||
|
||||
if (base) this.base = base;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -56,16 +34,29 @@ OpenLayers.Control.Permalink.prototype =
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
var args = OpenLayers.Util.getArgs();
|
||||
if (args.lat && args.lon) {
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat))
|
||||
);
|
||||
}
|
||||
if (args.zoom) {
|
||||
this.map.zoomTo(parseInt(args.zoom));
|
||||
}
|
||||
if (!this.element) {
|
||||
this.div.className = 'olControlPermalink';
|
||||
this.element = document.createElement("a");
|
||||
this.div.style.right = "3px";
|
||||
this.div.style.bottom = "3px";
|
||||
this.div.style.left = "";
|
||||
this.div.style.top = "";
|
||||
this.div.style.display = "block";
|
||||
this.div.style.position = "absolute";
|
||||
this.element.style.fontSize="smaller";
|
||||
this.element.innerHTML = "Permalink";
|
||||
this.element.href="";
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
this.map.events.register('moveend', this, this.updateLink);
|
||||
this.map.events.register( 'moveend', this, this.updateLink);
|
||||
return this.div;
|
||||
},
|
||||
|
||||
@@ -74,25 +65,13 @@ OpenLayers.Control.Permalink.prototype =
|
||||
*/
|
||||
updateLink: function() {
|
||||
var center = this.map.getCenter();
|
||||
var zoom = "zoom=" + this.map.getZoom();
|
||||
var lat = "lat=" + Math.round(center.lat*100000)/100000;
|
||||
var lon = "lon=" + Math.round(center.lon*100000)/100000;
|
||||
|
||||
var layers = "layers=";
|
||||
for(var i=0; i< this.map.layers.length; i++) {
|
||||
var layer = this.map.layers[i];
|
||||
|
||||
if (layer.isBaseLayer) {
|
||||
layers += (layer == this.map.baseLayer) ? "B" : "0";
|
||||
} else {
|
||||
layers += (layer.getVisibility()) ? "T" : "F";
|
||||
}
|
||||
}
|
||||
var href = this.base + "?" + lat + "&" + lon + "&" + zoom +
|
||||
"&" + layers;
|
||||
this.element.href = href;
|
||||
var zoom = this.map.getZoom();
|
||||
var lat = Math.round(center.lat*100000)/100000;
|
||||
var lon = Math.round(center.lon*100000)/100000;
|
||||
this.element.href = this.base+"?lat="+lat+"&lon="+lon+"&zoom="+zoom;
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.Permalink"
|
||||
});
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.Scale = OpenLayers.Class.create();
|
||||
OpenLayers.Control.Scale = Class.create();
|
||||
OpenLayers.Control.Scale.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
/** @type DOMElement */
|
||||
element: null,
|
||||
|
||||
@@ -31,7 +31,12 @@ OpenLayers.Control.Scale.prototype =
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
if (!this.element) {
|
||||
this.element = document.createElement("div");
|
||||
this.div.className = "olControlScale";
|
||||
this.div.style.right = "3px";
|
||||
this.div.style.bottom = "2em";
|
||||
this.div.style.left = "";
|
||||
this.div.style.top = "";
|
||||
this.div.style.display = "block";
|
||||
this.div.style.position = "absolute";
|
||||
this.element.style.fontSize="smaller";
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
|
||||
@@ -2,121 +2,10 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
OpenLayers.Event = {
|
||||
KEY_BACKSPACE: 8,
|
||||
KEY_TAB: 9,
|
||||
KEY_RETURN: 13,
|
||||
KEY_ESC: 27,
|
||||
KEY_LEFT: 37,
|
||||
KEY_UP: 38,
|
||||
KEY_RIGHT: 39,
|
||||
KEY_DOWN: 40,
|
||||
KEY_DELETE: 46,
|
||||
|
||||
element: function(event) {
|
||||
return event.target || event.srcElement;
|
||||
},
|
||||
|
||||
isLeftClick: function(event) {
|
||||
return (((event.which) && (event.which == 1)) ||
|
||||
((event.button) && (event.button == 1)));
|
||||
},
|
||||
|
||||
pointerX: function(event) {
|
||||
return event.pageX || (event.clientX +
|
||||
(document.documentElement.scrollLeft || document.body.scrollLeft));
|
||||
},
|
||||
|
||||
pointerY: function(event) {
|
||||
return event.pageY || (event.clientY +
|
||||
(document.documentElement.scrollTop || document.body.scrollTop));
|
||||
},
|
||||
|
||||
stop: function(event) {
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
event.returnValue = false;
|
||||
event.cancelBubble = true;
|
||||
}
|
||||
},
|
||||
|
||||
// find the first node with the given tagName, starting from the
|
||||
// node the event was triggered on; traverses the DOM upwards
|
||||
findElement: function(event, tagName) {
|
||||
var element = OpenLayers.Event.element(event);
|
||||
while (element.parentNode && (!element.tagName ||
|
||||
(element.tagName.toUpperCase() != tagName.toUpperCase())))
|
||||
element = element.parentNode;
|
||||
return element;
|
||||
},
|
||||
|
||||
observers: false,
|
||||
|
||||
_observeAndCache: function(element, name, observer, useCapture) {
|
||||
if (!this.observers) this.observers = [];
|
||||
if (element.addEventListener) {
|
||||
this.observers.push([element, name, observer, useCapture]);
|
||||
element.addEventListener(name, observer, useCapture);
|
||||
} else if (element.attachEvent) {
|
||||
this.observers.push([element, name, observer, useCapture]);
|
||||
element.attachEvent('on' + name, observer);
|
||||
}
|
||||
},
|
||||
|
||||
unloadCache: function() {
|
||||
if (!OpenLayers.Event.observers) return;
|
||||
for (var i = 0; i < OpenLayers.Event.observers.length; i++) {
|
||||
OpenLayers.Event.stopObserving.apply(this, OpenLayers.Event.observers[i]);
|
||||
OpenLayers.Event.observers[i][0] = null;
|
||||
}
|
||||
OpenLayers.Event.observers = false;
|
||||
},
|
||||
|
||||
observe: function(elementParam, name, observer, useCapture) {
|
||||
var element = $(elementParam);
|
||||
useCapture = useCapture || false;
|
||||
|
||||
if (name == 'keypress' &&
|
||||
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|
||||
|| element.attachEvent))
|
||||
name = 'keydown';
|
||||
|
||||
this._observeAndCache(element, name, observer, useCapture);
|
||||
},
|
||||
|
||||
stopObserving: function(elementParam, name, observer, useCapture) {
|
||||
var element = $(elementParam);
|
||||
useCapture = useCapture || false;
|
||||
|
||||
if (name == 'keypress' &&
|
||||
(navigator.appVersion.match(/Konqueror|Safari|KHTML/)
|
||||
|| element.detachEvent))
|
||||
name = 'keydown';
|
||||
|
||||
if (element.removeEventListener) {
|
||||
element.removeEventListener(name, observer, useCapture);
|
||||
} else if (element.detachEvent) {
|
||||
element.detachEvent('on' + name, observer);
|
||||
}
|
||||
}
|
||||
};
|
||||
/* prevent memory leaks in IE */
|
||||
OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false);
|
||||
|
||||
if (window.Event) {
|
||||
OpenLayers.Util.extend(window.Event, OpenLayers.Event);
|
||||
} else {
|
||||
var Event = OpenLayers.Event;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Events = OpenLayers.Class.create();
|
||||
OpenLayers.Events = Class.create();
|
||||
OpenLayers.Events.prototype = {
|
||||
|
||||
/** @final @type Array: supported events */
|
||||
@@ -140,6 +29,7 @@ OpenLayers.Events.prototype = {
|
||||
/** @type Array: list of support application events */
|
||||
eventTypes: null,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -182,11 +72,11 @@ OpenLayers.Events.prototype = {
|
||||
this.listeners[eventType] = new Array();
|
||||
|
||||
// use Prototype to register the event cross-browser
|
||||
OpenLayers.Event.observe(element, eventType,
|
||||
Event.observe(element, eventType,
|
||||
this.handleBrowserEvent.bindAsEventListener(this));
|
||||
}
|
||||
// disable dragstart in IE so that mousedown/move/up works normally
|
||||
OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop);
|
||||
Event.observe(element, "dragstart", Event.stop);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -289,8 +179,8 @@ OpenLayers.Events.prototype = {
|
||||
}
|
||||
}
|
||||
// don't fall through to other DOM elements
|
||||
if (!this.fallThrough) {
|
||||
OpenLayers.Util.safeStopPropagation(evt);
|
||||
if (!this.fallThrough) {
|
||||
Event.stop(evt);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -318,18 +208,12 @@ OpenLayers.Events.prototype = {
|
||||
*/
|
||||
getMousePosition: function (evt) {
|
||||
if (!this.element.offsets) {
|
||||
this.element.offsets = OpenLayers.Util.pagePosition(this.element);
|
||||
this.element.offsets[0] += (document.documentElement.scrollLeft
|
||||
|| document.body.scrollLeft);
|
||||
this.element.offsets[1] += (document.documentElement.scrollTop
|
||||
|| document.body.scrollTop);
|
||||
this.element.offsets = Position.page(this.element);
|
||||
}
|
||||
return new OpenLayers.Pixel(
|
||||
(evt.clientX + (document.documentElement.scrollLeft
|
||||
|| document.body.scrollLeft)) - this.element.offsets[0],
|
||||
(evt.clientY + (document.documentElement.scrollTop
|
||||
|| document.body.scrollTop)) - this.element.offsets[1]
|
||||
);
|
||||
(evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) - this.element.offsets[0],
|
||||
(evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) - this.element.offsets[1]
|
||||
);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* @requires OpenLayers/Util.js
|
||||
*/
|
||||
OpenLayers.Feature = OpenLayers.Class.create();
|
||||
OpenLayers.Feature = Class.create();
|
||||
OpenLayers.Feature.prototype= {
|
||||
|
||||
/** @type OpenLayers.Events */
|
||||
@@ -63,38 +63,20 @@ OpenLayers.Feature.prototype= {
|
||||
this.lonlat = null;
|
||||
this.data = null;
|
||||
if (this.marker != null) {
|
||||
this.destroyMarker(this.marker);
|
||||
this.marker.destroy();
|
||||
this.marker = null;
|
||||
}
|
||||
if (this.popup != null) {
|
||||
this.destroyPopup(this.popup);
|
||||
this.popup.destroy();
|
||||
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
|
||||
* set in this.data. If no 'lonlat' is set, returns null. If no
|
||||
* 'icon' is set, OpenLayers.Marker() will load the default image.
|
||||
*
|
||||
* Note: this.marker is set to return value
|
||||
*
|
||||
* 'icon' is set, OpenLayers.Marker() will load the default image
|
||||
* @type OpenLayers.Marker
|
||||
*/
|
||||
createMarker: function() {
|
||||
@@ -107,24 +89,8 @@ OpenLayers.Feature.prototype= {
|
||||
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() {
|
||||
|
||||
@@ -142,13 +108,5 @@ OpenLayers.Feature.prototype= {
|
||||
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"
|
||||
};
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Feature.js
|
||||
*/
|
||||
OpenLayers.Feature.WFS = OpenLayers.Class.create();
|
||||
OpenLayers.Feature.WFS = Class.create();
|
||||
OpenLayers.Feature.WFS.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Feature, {
|
||||
Object.extend( new OpenLayers.Feature(), {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -19,11 +19,16 @@ OpenLayers.Feature.WFS.prototype =
|
||||
*/
|
||||
initialize: function(layer, xmlNode) {
|
||||
var newArguments = arguments;
|
||||
var data = this.processXMLNode(xmlNode);
|
||||
newArguments = new Array(layer, data.lonlat, data)
|
||||
if (arguments.length > 0) {
|
||||
var data = this.processXMLNode(xmlNode);
|
||||
newArguments = new Array(layer, data.lonlat, data)
|
||||
}
|
||||
OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
|
||||
this.createMarker();
|
||||
this.layer.addMarker(this.marker);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
this.createMarker();
|
||||
this.layer.addMarker(this.marker);
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
@@ -42,8 +47,8 @@ OpenLayers.Feature.WFS.prototype =
|
||||
processXMLNode: function(xmlNode) {
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/gml", "gml", "Point");
|
||||
var text = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(point[0], "http://www.opengis.net/gml","gml", "coordinates")[0]);
|
||||
var point = xmlNode.getElementsByTagName("Point");
|
||||
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])),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Icon = OpenLayers.Class.create();
|
||||
OpenLayers.Icon = Class.create();
|
||||
OpenLayers.Icon.prototype = {
|
||||
|
||||
/** image url
|
||||
@@ -39,12 +39,8 @@ OpenLayers.Icon.prototype = {
|
||||
initialize: function(url, size, offset, calculateOffset) {
|
||||
this.url = url;
|
||||
this.size = (size) ? size : new OpenLayers.Size(20,20);
|
||||
this.offset = offset;
|
||||
this.calculateOffset = (calculateOffset) ? calculateOffset
|
||||
: function(size) {
|
||||
return new OpenLayers.Pixel(-(size.w/2),
|
||||
-(size.h/2));
|
||||
};
|
||||
this.offset = (offset) ? offset : new OpenLayers.Pixel(0,0);
|
||||
this.calculateOffset = calculateOffset;
|
||||
|
||||
this.imageDiv = OpenLayers.Util.createAlphaImageDiv();
|
||||
},
|
||||
@@ -91,16 +87,6 @@ OpenLayers.Icon.prototype = {
|
||||
return this.imageDiv;
|
||||
},
|
||||
|
||||
|
||||
/** Change the icon's opacity
|
||||
* @param {float} opacity
|
||||
*/
|
||||
setOpacity: function(opacity) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,
|
||||
null, null, null, null, opacity);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
@@ -134,4 +120,4 @@ OpenLayers.Icon.prototype = {
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Icon"
|
||||
};
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Layer = OpenLayers.Class.create();
|
||||
OpenLayers.Layer = Class.create();
|
||||
OpenLayers.Layer.prototype = {
|
||||
|
||||
/** @type String */
|
||||
@@ -36,25 +36,6 @@ OpenLayers.Layer.prototype = {
|
||||
* @type boolean */
|
||||
alpha: false,
|
||||
|
||||
/** should the layer's name appear in the layer switcher?
|
||||
*
|
||||
* @type boolean */
|
||||
displayInLayerSwitcher: true,
|
||||
|
||||
/** Whether or not the layer should be displayed in the map
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
visibility: true,
|
||||
|
||||
/** Whether or not the map's current resolution is within this layer's
|
||||
* min/max range -- this is set in map's setCenter() whenever zoom
|
||||
* changes
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
inRange: false,
|
||||
|
||||
// OPTIONS
|
||||
|
||||
/** @type Array */
|
||||
@@ -92,9 +73,6 @@ OpenLayers.Layer.prototype = {
|
||||
|
||||
/** @type float */
|
||||
maxScale: null,
|
||||
|
||||
/** @type Boolean */
|
||||
displayOutsideMaxExtent: false,
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,21 +82,24 @@ OpenLayers.Layer.prototype = {
|
||||
* @param {Object} options Hashtable of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
//store a copy of the custom options for later cloning
|
||||
this.options = OpenLayers.Util.extend(new Object(), options);
|
||||
|
||||
//add options to layer
|
||||
OpenLayers.Util.extend(this, this.options);
|
||||
if (arguments.length > 0) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
|
||||
if (this.div == null) {
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.div.style.width = "100%";
|
||||
this.div.style.height = "100%";
|
||||
this.div.id = this.id;
|
||||
//store a copy of the custom options for later cloning
|
||||
this.options = Object.extend(new Object(), options);
|
||||
|
||||
//add options to layer
|
||||
Object.extend(this, this.options);
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
|
||||
if (this.div == null) {
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.div.style.width = "100%";
|
||||
this.div.style.height = "100%";
|
||||
this.div.id = this.id;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -171,10 +152,10 @@ OpenLayers.Layer.prototype = {
|
||||
addOptions: function (newOptions) {
|
||||
|
||||
// update our copy for clone
|
||||
OpenLayers.Util.extend(this.options, newOptions);
|
||||
Object.extend(this.options, newOptions);
|
||||
|
||||
// add new options to this
|
||||
OpenLayers.Util.extend(this, newOptions);
|
||||
Object.extend(this, this.options);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -188,14 +169,10 @@ OpenLayers.Layer.prototype = {
|
||||
* @param {OpenLayers.Bounds} bound
|
||||
* @param {Boolean} zoomChanged tells when zoom has changed, as layers
|
||||
* have to do some init work in that case.
|
||||
* @param {Boolean} dragging
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
var display = this.visibility;
|
||||
if (!this.isBaseLayer) {
|
||||
display = display && this.inRange;
|
||||
}
|
||||
this.display(display);
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
//this function can be implemented by subclasses.
|
||||
},
|
||||
|
||||
/** Set the map property for the layer. This is done through an accessor
|
||||
@@ -210,48 +187,46 @@ OpenLayers.Layer.prototype = {
|
||||
setMap: function(map) {
|
||||
this.map = map;
|
||||
|
||||
// grab some essential layer data from the map if it hasn't already
|
||||
// been set
|
||||
this.maxExtent = this.maxExtent || this.map.maxExtent;
|
||||
this.projection = this.projection || this.map.projection;
|
||||
this.units = this.units || this.map.units;
|
||||
|
||||
this.initResolutions();
|
||||
|
||||
if (!this.isBaseLayer) {
|
||||
this.inRange = this.calculateInRange();
|
||||
var properties = new Array(
|
||||
'projection', 'units',
|
||||
'scales', 'resolutions',
|
||||
'maxScale', 'minScale',
|
||||
'maxResolution', 'minResolution',
|
||||
'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]];
|
||||
}
|
||||
}
|
||||
if (this.isBaseLayer) {
|
||||
this.initResolutions();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Whether or not the layer should be displayed (if in range)
|
||||
* @returns Whether or not the layer is visible
|
||||
* @type Boolean
|
||||
*/
|
||||
getVisibility: function() {
|
||||
return this.visibility;
|
||||
return (this.div.style.display != "none");
|
||||
},
|
||||
|
||||
/** Set the visibility flag for the layer and hide/show&redraw accordingly.
|
||||
* Fire event unless otherwise specified
|
||||
*
|
||||
* Note that visibility is no longer simply whether or not the layer's
|
||||
* style.display is set to "block". Now we store a 'visibility' state
|
||||
* property on the layer class, this allows us to remember whether or not
|
||||
* we *desire* for a layer to be visible. In the case where the map's
|
||||
* resolution is out of the layer's range, this desire may be subverted.
|
||||
*
|
||||
* @param {Boolean} visible Whether or not to display the layer
|
||||
* (if in range)
|
||||
/**
|
||||
* @param {Boolean} visible
|
||||
* @param {Boolean} noEvent
|
||||
*/
|
||||
setVisibility: function(visibility, noEvent) {
|
||||
if (visibility != this.visibility) {
|
||||
this.visibility = visibility;
|
||||
this.display(visibility);
|
||||
if (this.map != null) {
|
||||
setVisibility: function(visible, noEvent) {
|
||||
if (visible != this.getVisibility()) {
|
||||
this.div.style.display = (visible) ? "block" : "none";
|
||||
if ((visible) && (this.map != null)) {
|
||||
var extent = this.map.getExtent();
|
||||
if (extent != null) {
|
||||
this.moveTo(extent, true);
|
||||
this.moveTo(this.map.getExtent(), true);
|
||||
}
|
||||
}
|
||||
if ((this.map != null) &&
|
||||
@@ -260,32 +235,7 @@ OpenLayers.Layer.prototype = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** Hide or show the Layer
|
||||
*
|
||||
* @param {Boolean} display
|
||||
*/
|
||||
display: function(display) {
|
||||
if (display != (this.div.style.display != "none")) {
|
||||
this.div.style.display = (display) ? "block" : "none";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Whether or not the layer is displayable at the current map's
|
||||
* current resolution
|
||||
* @type Boolean
|
||||
*/
|
||||
calculateInRange: function() {
|
||||
var inRange = false;
|
||||
if (this.map) {
|
||||
var resolution = this.map.getResolution();
|
||||
inRange = ( (resolution >= this.minResolution) &&
|
||||
(resolution <= this.maxResolution) );
|
||||
}
|
||||
return inRange;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {Boolean} isBaseLayer
|
||||
*/
|
||||
@@ -317,122 +267,61 @@ OpenLayers.Layer.prototype = {
|
||||
* @private
|
||||
*/
|
||||
initResolutions: function() {
|
||||
|
||||
// These are the relevant options which are used for calculating
|
||||
// resolutions information.
|
||||
//
|
||||
var props = new Array(
|
||||
'projection', 'units',
|
||||
'scales', 'resolutions',
|
||||
'maxScale', 'minScale',
|
||||
'maxResolution', 'minResolution',
|
||||
'minExtent', 'maxExtent',
|
||||
'numZoomLevels', 'maxZoomLevel'
|
||||
);
|
||||
|
||||
// First we create a new object where we will store all of the
|
||||
// resolution-related properties that we find in either the layer's
|
||||
// 'options' array or from the map.
|
||||
//
|
||||
var confProps = new Object();
|
||||
for(var i=0; i < props.length; i++) {
|
||||
var property = props[i];
|
||||
confProps[property] = this.options[property] || this.map[property];
|
||||
}
|
||||
|
||||
// If numZoomLevels hasn't been set and the maxZoomLevel *has*,
|
||||
// then use maxZoomLevel to calculate numZoomLevels
|
||||
//
|
||||
if ( (!confProps.numZoomLevels) && (confProps.maxZoomLevel) ) {
|
||||
confProps.numZoomLevels = confProps.maxZoomLevel + 1;
|
||||
}
|
||||
|
||||
// First off, we take whatever hodge-podge of values we have and
|
||||
// calculate/distill them down into a resolutions[] array
|
||||
//
|
||||
if ((confProps.scales != null) || (confProps.resolutions != null)) {
|
||||
|
||||
if ((this.scales != null) || (this.resolutions != null)) {
|
||||
//preset levels
|
||||
if (confProps.scales != null) {
|
||||
confProps.resolutions = new Array();
|
||||
for(var i = 0; i < confProps.scales.length; i++) {
|
||||
var scale = confProps.scales[i];
|
||||
confProps.resolutions[i] =
|
||||
OpenLayers.Util.getResolutionFromScale(scale,
|
||||
confProps.units);
|
||||
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);
|
||||
}
|
||||
}
|
||||
confProps.numZoomLevels = confProps.resolutions.length;
|
||||
this.numZoomLevels = this.resolutions.length;
|
||||
|
||||
} else {
|
||||
//maxResolution and numZoomLevels based calculation
|
||||
//maxResolution and numZoomLevels
|
||||
|
||||
confProps.resolutions = new Array();
|
||||
this.resolutions = new Array();
|
||||
|
||||
// determine maxResolution
|
||||
if (confProps.minScale) {
|
||||
confProps.maxResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(confProps.minScale,
|
||||
confProps.units);
|
||||
} else if (confProps.maxResolution == "auto") {
|
||||
if (this.minScale) {
|
||||
this.maxResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(this.minScale,
|
||||
this.units);
|
||||
} else if (this.maxResolution == "auto") {
|
||||
var viewSize = this.map.getSize();
|
||||
var wRes = confProps.maxExtent.getWidth() / viewSize.w;
|
||||
var hRes = confProps.maxExtent.getHeight()/ viewSize.h;
|
||||
confProps.maxResolution = Math.max(wRes, hRes);
|
||||
var wRes = this.maxExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.maxExtent.getHeight()/ viewSize.h;
|
||||
this.maxResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine minResolution
|
||||
if (confProps.maxScale != null) {
|
||||
confProps.minResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(confProps.maxScale);
|
||||
} else if ( (confProps.minResolution == "auto") &&
|
||||
(confProps.minExtent != null) ) {
|
||||
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 = confProps.minExtent.getWidth() / viewSize.w;
|
||||
var hRes = confProps.minExtent.getHeight()/ viewSize.h;
|
||||
confProps.minResolution = Math.max(wRes, hRes);
|
||||
var wRes = this.minExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.minExtent.getHeight()/ viewSize.h;
|
||||
this.minResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine numZoomLevels
|
||||
if (confProps.minResolution != null) {
|
||||
var ratio = confProps.maxResolution / confProps.minResolution;
|
||||
confProps.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 < confProps.numZoomLevels; i++) {
|
||||
var res = confProps.maxResolution / Math.pow(2, i)
|
||||
confProps.resolutions.push(res);
|
||||
for (var i=0; i < this.numZoomLevels; i++) {
|
||||
this.resolutions.push(this.maxResolution / Math.pow(2, i));
|
||||
}
|
||||
}
|
||||
|
||||
//sort resolutions array ascendingly
|
||||
//
|
||||
confProps.resolutions.sort( function(a, b) { return(b-a); } );
|
||||
|
||||
// now set our newly calculated values back to the layer
|
||||
// Note: We specifically do *not* set them to layer.options, which we
|
||||
// will preserve as it was when we added this layer to the map.
|
||||
// this way cloned layers reset themselves to new map div
|
||||
// dimensions)
|
||||
//
|
||||
|
||||
this.resolutions = confProps.resolutions;
|
||||
this.maxResolution = confProps.resolutions[0];
|
||||
var lastIndex = confProps.resolutions.length - 1;
|
||||
this.minResolution = confProps.resolutions[lastIndex];
|
||||
|
||||
this.scales = new Array();
|
||||
for(var i = 0; i < confProps.resolutions.length; i++) {
|
||||
this.scales[i] =
|
||||
OpenLayers.Util.getScaleFromResolution(confProps.resolutions[i],
|
||||
confProps.units);
|
||||
}
|
||||
this.minScale = this.scales[0];
|
||||
this.maxScale = this.scales[this.scales.length - 1];
|
||||
|
||||
this.numZoomLevels = confProps.numZoomLevels;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -445,16 +334,35 @@ OpenLayers.Layer.prototype = {
|
||||
return this.resolutions[zoom];
|
||||
},
|
||||
|
||||
/**
|
||||
/** Calculates based on resolution, center, and mapsize
|
||||
*
|
||||
* @param {float} resolution Specific resolution to get an extent for.
|
||||
* If null, this.getResolution() is called
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function() {
|
||||
// just use stock map calculateBounds function -- passing no arguments
|
||||
// means it will user map's current center & resolution
|
||||
//
|
||||
return this.map.calculateBounds();
|
||||
getExtent: function(resolution) {
|
||||
var extent = null;
|
||||
|
||||
var center = this.map.getCenter();
|
||||
if (center != null) {
|
||||
|
||||
if (resolution == null) {
|
||||
resolution = this.getResolution();
|
||||
}
|
||||
var size = this.map.getSize();
|
||||
var w_deg = size.w * resolution;
|
||||
var h_deg = size.h * resolution;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -485,7 +393,7 @@ OpenLayers.Layer.prototype = {
|
||||
*/
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
@@ -501,19 +409,15 @@ OpenLayers.Layer.prototype = {
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if (viewPortPx != null) {
|
||||
var size = this.map.getSize();
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
var size = this.map.getSize();
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
var delta_y = viewPortPx.y - (size.h / 2);
|
||||
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
var delta_y = viewPortPx.y - (size.h / 2);
|
||||
|
||||
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
}
|
||||
return lonlat;
|
||||
return new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -524,16 +428,12 @@ OpenLayers.Layer.prototype = {
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var px = null;
|
||||
if (lonlat != null) {
|
||||
var resolution = this.map.getResolution();
|
||||
var extent = this.map.getExtent();
|
||||
px = new OpenLayers.Pixel(
|
||||
Math.round(1/resolution * (lonlat.lon - extent.left)),
|
||||
Math.round(1/resolution * (extent.top - lonlat.lat))
|
||||
);
|
||||
}
|
||||
return px;
|
||||
var resolution = this.map.getResolution();
|
||||
var extent = this.map.getExtent();
|
||||
return new OpenLayers.Pixel(
|
||||
Math.round(1/resolution * (lonlat.lon - extent.left)),
|
||||
Math.round(1/resolution * (extent.top - lonlat.lat))
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -544,19 +444,10 @@ OpenLayers.Layer.prototype = {
|
||||
this.opacity = opacity;
|
||||
for(var i=0; i<this.div.childNodes.length; ++i) {
|
||||
var element = this.div.childNodes[i];
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null,
|
||||
null, null, null, opacity);
|
||||
OpenLayers.Util.setOpacity(element, opacity);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} zIdx
|
||||
* @private
|
||||
*/
|
||||
setZIndex: function (zIdx) {
|
||||
this.div.style.zIndex = zIdx;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer"
|
||||
};
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
* @requires OpenLayers/Layer.js
|
||||
* @requires OpenLayers/Layer/Markers.js
|
||||
*/
|
||||
OpenLayers.Layer.Boxes = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Boxes = Class.create();
|
||||
OpenLayers.Layer.Boxes.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
initialize: function () {
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
|
||||
@@ -33,8 +33,7 @@ OpenLayers.Layer.Boxes.prototype =
|
||||
marker.display(false);
|
||||
} else {
|
||||
var sz = new OpenLayers.Size(
|
||||
Math.max(1, botright.x - topleft.x),
|
||||
Math.max(1, botright.y - topleft.y));
|
||||
botright.x - topleft.x, botright.y - topleft.y);
|
||||
var markerDiv = marker.draw(topleft, sz);
|
||||
if (!marker.drawn) {
|
||||
this.div.appendChild(markerDiv);
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
*/
|
||||
OpenLayers.Layer.Canvas = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Canvas = Class.create();
|
||||
OpenLayers.Layer.Canvas.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer, {
|
||||
Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** Canvas layer is never a base layer.
|
||||
*
|
||||
@@ -46,12 +46,10 @@ OpenLayers.Layer.Canvas.prototype =
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} dragging
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
||||
|
||||
this.redraw();
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
this.redraw();
|
||||
},
|
||||
|
||||
setStrokeColor: function(color) {
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
* @requires OpenLayers/Layer.js
|
||||
* @requires OpenLayers/Util.js
|
||||
*/
|
||||
OpenLayers.Layer.EventPane = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.EventPane = Class.create();
|
||||
OpenLayers.Layer.EventPane.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer, {
|
||||
Object.extend(new OpenLayers.Layer, {
|
||||
|
||||
/** EventPaned layers are always base layers, by necessity.
|
||||
*
|
||||
@@ -25,15 +25,6 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
/** @type DOMElement */
|
||||
pane: null,
|
||||
|
||||
|
||||
/** This is the object which will be used to load the 3rd party library
|
||||
* in the case of the google layer, this will be of type GMap,
|
||||
* in the case of the ve layer, this will be of type VEMap
|
||||
*
|
||||
* @type Object */
|
||||
mapObject: null,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -42,20 +33,14 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
if (this.pane == null) {
|
||||
this.pane = OpenLayers.Util.createDiv(this.div.id + "_EventPane");
|
||||
|
||||
if (arguments.length > 0) {
|
||||
if (this.pane == null) {
|
||||
this.pane = OpenLayers.Util.createDiv();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.mapObject = null;
|
||||
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
/** Set the map property for the layer. This is done through an accessor
|
||||
* so that subclasses can override this and take special action once
|
||||
* they have their map variable set.
|
||||
@@ -78,234 +63,17 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
} else {
|
||||
this.map.layerContainerDiv.appendChild(this.pane);
|
||||
}
|
||||
|
||||
// once our layer has been added to the map, we can load it
|
||||
this.loadMapObject();
|
||||
|
||||
// if map didn't load, display warning
|
||||
if (this.mapObject == null) {
|
||||
this.loadWarningMessage();
|
||||
}
|
||||
},
|
||||
|
||||
/** If we can't load the GMap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
*/
|
||||
loadWarningMessage:function() {
|
||||
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv(this.name + "_warning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = this.getWarningHTML();
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {Boolean} display
|
||||
* @param {Boolean} visible
|
||||
* @param {Boolean} noEvent
|
||||
*/
|
||||
display: function(display) {
|
||||
OpenLayers.Layer.prototype.display.apply(this, arguments);
|
||||
setVisibility: function(visible, noEvent) {
|
||||
OpenLayers.Layer.prototype.setVisibility.apply(this, arguments);
|
||||
|
||||
this.pane.style.display = this.div.style.display;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} zIndex
|
||||
*/
|
||||
setZIndex: function (zIndex) {
|
||||
OpenLayers.Layer.prototype.setZIndex.apply(this, arguments);
|
||||
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} dragging
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
||||
|
||||
if (this.mapObject != null) {
|
||||
|
||||
var newCenter = this.map.getCenter();
|
||||
var newZoom = this.map.getZoom();
|
||||
|
||||
if (newCenter != null) {
|
||||
|
||||
var moOldCenter = this.getMapObjectCenter();
|
||||
var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter);
|
||||
|
||||
var moOldZoom = this.getMapObjectZoom();
|
||||
var oldZoom= this.getOLZoomFromMapObjectZoom(moOldZoom);
|
||||
|
||||
if ( !(newCenter.equals(oldCenter)) ||
|
||||
!(newZoom == oldZoom) ) {
|
||||
|
||||
var center = this.getMapObjectLonLatFromOLLonLat(newCenter);
|
||||
var zoom = this.getMapObjectZoomFromOLZoom(newZoom);
|
||||
this.setMapObjectCenter(center, zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by GMAPS
|
||||
* If gmap is not loaded or not centered, returns null
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if ( (this.mapObject != null) &&
|
||||
(this.getMapObjectCenter() != null) ) {
|
||||
var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);
|
||||
var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel)
|
||||
lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY GMAPS
|
||||
* If gmap is not loaded or not centered, returns null
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if ( (this.mapObject != null) &&
|
||||
(this.getMapObjectCenter() != null) ) {
|
||||
|
||||
var moLonLat = this.getMapObjectLonLatFromOLLonLat(lonlat);
|
||||
var moPixel = this.getMapObjectPixelFromMapObjectLonLat(moLonLat)
|
||||
|
||||
viewPortPx = this.getOLPixelFromMapObjectPixel(moPixel);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate Map Object and */
|
||||
/* OL formats for Pixel, LonLat */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
//
|
||||
// TRANSLATION: MapObject LatLng <-> OpenLayers.LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat
|
||||
*
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in
|
||||
* MapObject LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getOLLonLatFromMapObjectLonLat: function(moLonLat) {
|
||||
var olLonLat = null;
|
||||
if (moLonLat != null) {
|
||||
var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);
|
||||
var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);
|
||||
olLonLat = new OpenLayers.LonLat(lon, lat);
|
||||
}
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns A MapObject LonLat, translated from the passed in
|
||||
* OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromOLLonLat: function(olLonLat) {
|
||||
var moLatLng = null;
|
||||
if (olLonLat != null) {
|
||||
moLatLng = this.getMapObjectLonLatFromLonLat(olLonLat.lon,
|
||||
olLonLat.lat);
|
||||
}
|
||||
return moLatLng;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: MapObject Pixel <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in
|
||||
* MapObject Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromMapObjectPixel: function(moPixel) {
|
||||
var olPixel = null;
|
||||
if (moPixel != null) {
|
||||
var x = this.getXFromMapObjectPixel(moPixel);
|
||||
var y = this.getYFromMapObjectPixel(moPixel);
|
||||
olPixel = new OpenLayers.Pixel(x, y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A MapObject Pixel, translated from the passed in
|
||||
* OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromOLPixel: function(olPixel) {
|
||||
var moPixel = null;
|
||||
if (olPixel != null) {
|
||||
moPixel = this.getMapObjectPixelFromXY(olPixel.x, olPixel.y);
|
||||
}
|
||||
return moPixel;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.EventPane"
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.FixedZoomLevels = Class.create();
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype = {
|
||||
|
||||
/********************************************************/
|
||||
@@ -67,46 +67,9 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
|
||||
// do want to put some functionality or state in here.
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
initResolutions: function() {
|
||||
|
||||
var props = new Array('minZoomLevel', 'maxZoomLevel', 'numZoomLevels');
|
||||
|
||||
for(var i=0; i < props.length; i++) {
|
||||
var property = props[i];
|
||||
this[property] = (this.options[property] != null)
|
||||
? this.options[property]
|
||||
: this.map[property];
|
||||
}
|
||||
|
||||
if ( (this.minZoomLevel == null) ||
|
||||
(this.minZoomLevel < this.MIN_ZOOM_LEVEL) ){
|
||||
this.minZoomLevel = this.MIN_ZOOM_LEVEL;
|
||||
}
|
||||
|
||||
var limitZoomLevels = this.MAX_ZOOM_LEVEL - this.minZoomLevel + 1;
|
||||
if (this.numZoomLevels != null) {
|
||||
this.numZoomLevels = Math.min(this.numZoomLevels, limitZoomLevels);
|
||||
} else {
|
||||
if (this.maxZoomLevel != null) {
|
||||
var zoomDiff = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
this.numZoomLevels = Math.min(zoomDiff, limitZoomLevels);
|
||||
} else {
|
||||
this.numZoomLevels = limitZoomLevels;
|
||||
}
|
||||
}
|
||||
|
||||
this.maxZoomLevel = this.minZoomLevel + this.numZoomLevels - 1;
|
||||
|
||||
if (this.RESOLUTIONS != null) {
|
||||
var resolutionsIndex = 0;
|
||||
this.resolutions = [];
|
||||
for(var i= this.minZoomLevel; i < this.numZoomLevels; i++) {
|
||||
this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];
|
||||
}
|
||||
}
|
||||
// resolutions are set automatically in the black-box. this is the
|
||||
// definition of a fixed-zoom-levels layer
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -114,23 +77,12 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
|
||||
* @type float
|
||||
*/
|
||||
getResolution: function() {
|
||||
|
||||
if (this.resolutions != null) {
|
||||
return OpenLayers.Layer.prototype.getResolution.apply(this, arguments);
|
||||
} else {
|
||||
var resolution = null;
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
var extent = this.getExtent();
|
||||
|
||||
if ((viewSize != null) && (extent != null)) {
|
||||
resolution = Math.max( extent.getWidth() / viewSize.w,
|
||||
extent.getHeight() / viewSize.h );
|
||||
}
|
||||
return resolution;
|
||||
}
|
||||
},
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
var extent = this.getExtent();
|
||||
return Math.max( extent.getWidth() / viewSize.w,
|
||||
extent.getHeight() / viewSize.h );
|
||||
},
|
||||
|
||||
/** Calculates using px-> lonlat translation functions on tl and br
|
||||
* corners of viewport
|
||||
*
|
||||
@@ -169,64 +121,12 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
|
||||
*/
|
||||
getZoomForResolution: function(resolution) {
|
||||
|
||||
if (this.resolutions != null) {
|
||||
return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments);
|
||||
} else {
|
||||
var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
|
||||
[resolution]);
|
||||
|
||||
return this.getZoomForExtent(extent);
|
||||
}
|
||||
var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
|
||||
[resolution]);
|
||||
|
||||
return this.getZoomForExtent(extent);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {int} gZoom
|
||||
*
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getOLZoomFromMapObjectZoom: function(moZoom) {
|
||||
var zoom = null;
|
||||
if (moZoom != null) {
|
||||
zoom = moZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns A MapObject level, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "FixedZoomLevels.js"
|
||||
};
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/Markers.js
|
||||
*/
|
||||
OpenLayers.Layer.GeoRSS = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.GeoRSS = Class.create();
|
||||
OpenLayers.Layer.GeoRSS.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** store url of text file
|
||||
* @type str */
|
||||
@@ -51,33 +51,8 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
if (!doc || ajaxRequest.fileType!="XML") {
|
||||
doc = OpenLayers.parseXMLString(ajaxRequest.responseText);
|
||||
}
|
||||
|
||||
this.name = null;
|
||||
try {
|
||||
this.name = doc.getElementsByTagNameNS('*', 'title')[0].firstChild.nodeValue;
|
||||
}
|
||||
catch (e) {
|
||||
this.name = doc.getElementsByTagName('title')[0].firstChild.nodeValue;
|
||||
}
|
||||
|
||||
/* Try RSS items first, then Atom entries */
|
||||
var itemlist = null;
|
||||
try {
|
||||
itemlist = doc.getElementsByTagNameNS('*', 'item');
|
||||
}
|
||||
catch (e) {
|
||||
itemlist = doc.getElementsByTagName('item');
|
||||
}
|
||||
|
||||
if (itemlist.length == 0) {
|
||||
try {
|
||||
itemlist = doc.getElementsByTagNameNS('*', 'entry');
|
||||
}
|
||||
catch(e) {
|
||||
itemlist = doc.getElementsByTagName('entry');
|
||||
}
|
||||
}
|
||||
|
||||
this.name = doc.getElementsByTagName("title")[0].firstChild.nodeValue;
|
||||
var itemlist = doc.getElementsByTagName('item');
|
||||
for (var i = 0; i < itemlist.length; i++) {
|
||||
var data = {};
|
||||
var point = OpenLayers.Util.getNodes(itemlist[i], 'georss:point');
|
||||
@@ -97,52 +72,44 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0]));
|
||||
|
||||
/* Provide defaults for title and description */
|
||||
var title = "Untitled";
|
||||
var title = "No title";
|
||||
try {
|
||||
title = OpenLayers.Util.getNodes(itemlist[i],
|
||||
"title")[0].firstChild.nodeValue;
|
||||
}
|
||||
catch (e) { title="Untitled"; }
|
||||
|
||||
/* First try RSS descriptions, then Atom summaries */
|
||||
var descr_nodes = null;
|
||||
catch (e) { alert(e); }
|
||||
|
||||
var description = "No description";
|
||||
try {
|
||||
descr_nodes = itemlist[i].getElementsByTagNameNS("*",
|
||||
"description");
|
||||
description = OpenLayers.Util.getNodes(itemlist[i],
|
||||
"description")[0].firstChild.nodeValue;
|
||||
}
|
||||
catch (e) {
|
||||
descr_nodes = itemlist[i].getElementsByTagName("description");
|
||||
}
|
||||
if (descr_nodes.length == 0) {
|
||||
try {
|
||||
descr_nodes = itemlist[i].getElementsByTagNameNS("*",
|
||||
"summary");
|
||||
}
|
||||
catch (e) {
|
||||
descr_nodes = itemlist[i].getElementsByTagName("summary");
|
||||
}
|
||||
}
|
||||
|
||||
var description = "No description.";
|
||||
try {
|
||||
description = descr_nodes[0].firstChild.nodeValue;
|
||||
}
|
||||
catch (e) { description="No description."; }
|
||||
catch (e) { alert(e); }
|
||||
|
||||
try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }
|
||||
data.icon = OpenLayers.Marker.defaultIcon();
|
||||
data.popupSize = new OpenLayers.Size(250, 120);
|
||||
data.popupSize = new OpenLayers.Size(250, 100);
|
||||
if ((title != null) && (description != null)) {
|
||||
contentHTML = '<div class="olLayerGeoRSSClose">[x]</div>';
|
||||
contentHTML += '<div class="olLayerGeoRSSTitle">';
|
||||
if (link) contentHTML += '<a class="link" href="'+link+'" target="_blank">';
|
||||
contentHTML += title;
|
||||
if (link) contentHTML += '</a>';
|
||||
contentHTML += '</div>';
|
||||
contentHTML += '<div style="" class="olLayerGeoRSSDescription">';
|
||||
contentHTML = "<br />";
|
||||
contentHTML += "<div style='margin: -0.5em 0.5em 0.5em 0.5em'>"
|
||||
|
||||
contentHTML += "<div style='height: 1.3em; overflow: hidden'>";
|
||||
contentHTML += "<span style='font-size: 1.2em; font-weight: bold'>";
|
||||
if (link) contentHTML += "<a href='"+link+"' target='_blank'>";
|
||||
contentHTML += title;
|
||||
if (link) contentHTML += "</a>";
|
||||
contentHTML += "</span>";
|
||||
contentHTML += "</div>";
|
||||
|
||||
|
||||
contentHTML += "<span style='font-size: 0.7em; align:center'>";
|
||||
contentHTML += description;
|
||||
contentHTML += '</div>';
|
||||
data['popupContentHTML'] = contentHTML;
|
||||
contentHTML += "</span>";
|
||||
|
||||
contentHTML += "</div>"
|
||||
data['popupContentHTML'] = contentHTML;
|
||||
|
||||
//data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
|
||||
}
|
||||
var feature = new OpenLayers.Feature(this, location, data);
|
||||
this.features.push(feature);
|
||||
@@ -163,7 +130,7 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
}
|
||||
if (!sameMarkerClicked) {
|
||||
var popup = this.createPopup();
|
||||
OpenLayers.Event.observe(popup.div, "click",
|
||||
Event.observe(popup.div, "click",
|
||||
function() {
|
||||
for(var i=0; i < this.layer.map.popups.length; i++) {
|
||||
this.layer.map.removePopup(this.layer.map.popups[i]);
|
||||
@@ -171,7 +138,7 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
}.bindAsEventListener(this));
|
||||
this.layer.map.addPopup(popup);
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -181,7 +148,7 @@ OpenLayers.Layer.GeoRSS.prototype =
|
||||
if (this.features != null) {
|
||||
while(this.features.length > 0) {
|
||||
var feature = this.features[0];
|
||||
OpenLayers.Util.removeItem(this.features, feature);
|
||||
this.features.remove(feature);
|
||||
feature.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,37 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*/
|
||||
OpenLayers.Layer.Google = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Google = Class.create();
|
||||
OpenLayers.Layer.Google.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
Object.extend( new OpenLayers.Layer.EventPane(),
|
||||
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), {
|
||||
|
||||
/** @final @type int */
|
||||
MIN_ZOOM_LEVEL: 0,
|
||||
|
||||
/** @final @type int */
|
||||
MAX_ZOOM_LEVEL: 17,
|
||||
/** @type Boolean */
|
||||
isFixed: true,
|
||||
|
||||
/** Hardcode these resolutions so that they are more closely
|
||||
* tied with the standard wms projection
|
||||
*
|
||||
* @final @type Array(float) */
|
||||
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
|
||||
/** @type GMap2 gmap stores the Google Map element */
|
||||
gmap:null,
|
||||
|
||||
/** @type GMapType */
|
||||
type: null,
|
||||
|
||||
// OPTIONS
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -37,68 +42,90 @@ OpenLayers.Layer.Google.prototype =
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
this.addContainerPxFunction();
|
||||
if (this.maxExtent == null) {
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
}
|
||||
this.addContainerPxFunction();
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.gmap = null;
|
||||
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load it
|
||||
this.loadGMap();
|
||||
},
|
||||
|
||||
/** Assuming we are not dragging (in which case GMaps is moving itself,
|
||||
* and the dragging flag is set) we need to move the gmap to the
|
||||
* new center/zoom
|
||||
*
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if ((this.gmap != null) && (!this.dragging)) {
|
||||
|
||||
var newOLCenter = this.map.getCenter();
|
||||
var newOLZoom = this.map.getZoom();
|
||||
|
||||
if (newOLCenter != null) {
|
||||
|
||||
var oldGCenter = this.gmap.getCenter();
|
||||
var oldOLCenter = this.getOLLonLatFromGLatLng(oldGCenter);
|
||||
|
||||
var oldGZoom = this.gmap.getZoom();
|
||||
var oldOLZoom = this.getOLZoomFromGZoom(oldGZoom);
|
||||
|
||||
if ( !(newOLCenter.equals(oldOLCenter)) ||
|
||||
!(newOLZoom == oldOLZoom) ) {
|
||||
|
||||
var newGCenter = this.getGLatLngFromOLLonLat(newOLCenter);
|
||||
var newGZoom = this.getGZoomFromOLZoom(newOLZoom);
|
||||
|
||||
this.gmap.setCenter(newGCenter, newGZoom);
|
||||
|
||||
if (this.type != null) {
|
||||
this.gmap.setMapType(this.type);
|
||||
this.type = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** Load the GMap and register appropriate event listeners. If we can't
|
||||
* load GMap2, then display a warning message.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
loadGMap:function() {
|
||||
|
||||
//has gmaps library has been loaded?
|
||||
try {
|
||||
// create GMap, hide nav controls
|
||||
this.mapObject = new GMap2( this.div );
|
||||
|
||||
// move the ToS and branding stuff up to the pane
|
||||
// thanks a *mil* Erik for thinking of this
|
||||
var poweredBy = this.div.lastChild;
|
||||
this.div.removeChild(poweredBy);
|
||||
this.pane.appendChild(poweredBy);
|
||||
poweredBy.className = "olLayerGooglePoweredBy gmnoprint";
|
||||
poweredBy.style.left = "";
|
||||
poweredBy.style.bottom = "";
|
||||
|
||||
var termsOfUse = this.div.lastChild;
|
||||
this.div.removeChild(termsOfUse);
|
||||
this.pane.appendChild(termsOfUse);
|
||||
termsOfUse.className = "olLayerGoogleCopyright";
|
||||
termsOfUse.style.right = "";
|
||||
termsOfUse.style.bottom = "";
|
||||
this.gmap = new GMap2( this.div );
|
||||
this.gmap.disableDragging();
|
||||
|
||||
// this causes the GMap to set itself to Map's center/zoom
|
||||
this.moveTo();
|
||||
|
||||
} catch (e) {
|
||||
// do not crash
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/** Overridden from EventPane because if a map type has been specified,
|
||||
* we need to attach a listener for the first moveend -- this is how
|
||||
* we will know that the map has been centered. Only once the map has
|
||||
* been centered is it safe to change the gmap object's map type.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
if (this.type != null) {
|
||||
this.map.events.register("moveend", this, this.setMapType);
|
||||
}
|
||||
},
|
||||
|
||||
/** The map has been centered, and a map type was specified, so we
|
||||
* set the map type on the gmap object, then unregister the listener
|
||||
* so that we dont keep doing this every time the map moves.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
setMapType: function() {
|
||||
if (this.mapObject.getCenter() != null) {
|
||||
this.mapObject.setMapType(this.type);
|
||||
this.map.events.unregister("moveend", this, this.setMapType);
|
||||
this.loadWarningMessage();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -106,120 +133,24 @@ OpenLayers.Layer.Google.prototype =
|
||||
* @param {Event} evt
|
||||
*/
|
||||
onMapResize: function() {
|
||||
this.mapObject.checkResize();
|
||||
this.gmap.checkResize();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom level for a specified Bounds.
|
||||
* If mapObject is not loaded or not centered, returns null
|
||||
* @type int
|
||||
*
|
||||
getZoomForExtent: function (bounds) {
|
||||
var zoom = null;
|
||||
if (this.mapObject != null) {
|
||||
var moBounds = this.getMapObjectBoundsFromOLBounds(bounds);
|
||||
var moZoom = this.getMapObjectZoomFromMapObjectBounds(moBounds);
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var moZoom = Math.min(Math.max(moZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromMapObjectZoom(moZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
*/
|
||||
|
||||
//
|
||||
// TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moBounds
|
||||
/** If we can't load the GMap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @returns An OpenLayers.Bounds, translated from the passed-in
|
||||
* MapObject Bounds
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getOLBoundsFromMapObjectBounds: function(moBounds) {
|
||||
var olBounds = null;
|
||||
if (moBounds != null) {
|
||||
var sw = moBounds.getSouthWest();
|
||||
var ne = moBounds.getNorthEast();
|
||||
olBounds = new OpenLayers.Bounds(sw.lng(),
|
||||
sw.lat(),
|
||||
ne.lng(),
|
||||
ne.lat() );
|
||||
}
|
||||
return olBounds;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} olBounds
|
||||
* @private
|
||||
*
|
||||
* @returns A MapObject Bounds, translated from olBounds
|
||||
* Returns null if null value is passed in
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectBoundsFromOLBounds: function(olBounds) {
|
||||
var moBounds = null;
|
||||
if (olBounds != null) {
|
||||
var sw = new GLatLng(olBounds.bottom, olBounds.left);
|
||||
var ne = new GLatLng(olBounds.top, olBounds.right);
|
||||
moBounds = new GLatLngBounds(sw, ne);
|
||||
}
|
||||
return moBounds;
|
||||
},
|
||||
|
||||
loadWarningMessage:function() {
|
||||
|
||||
|
||||
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
addContainerPxFunction: function() {
|
||||
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return String with information on why layer is broken, how to get
|
||||
* it working.
|
||||
* @type String
|
||||
*/
|
||||
getWarningHTML:function() {
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
|
||||
var html = "";
|
||||
html += "The Google Layer was unable to load correctly.<br>";
|
||||
html += "<br>";
|
||||
html += "To get rid of this message, select a new BaseLayer "
|
||||
html += "in the layer switcher in the upper-right corner.<br>";
|
||||
html += "To get rid of this message, click on the Google Layer's "
|
||||
html += "tab in the layer switcher in the upper-right corner.<br>";
|
||||
html += "<br>";
|
||||
html += "Most likely, this is because the Google Maps library";
|
||||
html += " script was either not included, or does not contain the";
|
||||
@@ -231,153 +162,282 @@ OpenLayers.Layer.Google.prototype =
|
||||
html += "click here";
|
||||
html += "</a>";
|
||||
|
||||
return html;
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv("gmapsWarning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = html;
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Interface Controls *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
// Get&Set Center, Zoom
|
||||
|
||||
/** Set the mapObject to the specified center and zoom
|
||||
*
|
||||
* @param {Object} center MapObject LonLat format
|
||||
* @param {int} zoom MapObject zoom format
|
||||
*/
|
||||
setMapObjectCenter: function(center, zoom) {
|
||||
this.mapObject.setCenter(center, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current center in Map Object format
|
||||
* @type Object
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by GMAPS
|
||||
* If gmap is not loaded or not centered, returns null
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getMapObjectCenter: function() {
|
||||
return this.mapObject.getCenter();
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
|
||||
var gPoint = this.getGPointFromOLPixel(viewPortPx);
|
||||
var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint)
|
||||
lonlat = this.getOLLonLatFromGLatLng(gLatLng);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current zoom, in Map Object format
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY GMAPS
|
||||
* If gmap is not loaded or not centered, returns null
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
|
||||
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
|
||||
|
||||
// note we use special hacked function here
|
||||
var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng);
|
||||
|
||||
viewPortPx = this.getOLPixelFromGPoint(gPoint);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom level for a specified Bounds.
|
||||
* If gmap is not loaded or not centered, returns null
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoom: function() {
|
||||
return this.mapObject.getZoom();
|
||||
getZoomForExtent: function (bounds) {
|
||||
var zoom = null;
|
||||
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;
|
||||
},
|
||||
|
||||
|
||||
// LonLat - Pixel Translation
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject LonLat translated from MapObject Pixel
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
|
||||
return this.mapObject.fromContainerPixelToLatLng(moPixel);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject Pixel translated from MapObject LonLat
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
|
||||
return this.mapObject.fromLatLngToContainerPixel(moLonLat);
|
||||
},
|
||||
|
||||
|
||||
// Bounds
|
||||
|
||||
/**
|
||||
* @param {Object} moBounds MapObject Bounds format
|
||||
*
|
||||
* @returns MapObject Zoom for specified MapObject Bounds
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectZoomFromMapObjectBounds: function(moBounds) {
|
||||
return this.mapObject.getBoundsZoomLevel(moBounds);
|
||||
},
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Primitives *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// LonLat
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns Longitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lng();
|
||||
},
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
//
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
* @param {int} gZoom
|
||||
*
|
||||
* @returns Latitude of the given MapObject LonLat
|
||||
* @type float
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lat();
|
||||
getOLZoomFromGZoom: function(gZoom) {
|
||||
var zoom = null;
|
||||
if (gZoom != null) {
|
||||
zoom = gZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} lon float
|
||||
* @param {int} lat float
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns MapObject LonLat built from lon and lat params
|
||||
* @type Object
|
||||
* @returns A GZoom level, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new GLatLng(lat, lon);
|
||||
getGZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
// Pixel
|
||||
//
|
||||
// TRANSLATION: GLatLng <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in GLatLng
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getOLLonLatFromGLatLng: function(gLatLng) {
|
||||
var olLonLat = null;
|
||||
if (gLatLng != null) {
|
||||
olLonLat = new OpenLayers.LonLat(gLatLng.lng(), gLatLng.lat());
|
||||
}
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns A GLatLng, translated from the passed in OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type GLatLng
|
||||
*/
|
||||
getGLatLngFromOLLonLat: function(olLonLat) {
|
||||
var gLatLng = null;
|
||||
if (olLonLat != null) {
|
||||
gLatLng = new GLatLng(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return gLatLng;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: GPoint <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GPoint} gPoint
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in GPoint
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromGPoint: function(gPoint) {
|
||||
var olPixel = null;
|
||||
if (gPoint != null) {
|
||||
olPixel = new OpenLayers.Pixel(gPoint.x, gPoint.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A GPoint, translated from the passed in OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type GPoint
|
||||
*/
|
||||
getGPointFromOLPixel: function(olPixel) {
|
||||
var gPoint = null;
|
||||
if (olPixel != null) {
|
||||
gPoint = new GPoint(olPixel.x, olPixel.y);
|
||||
}
|
||||
return gPoint;
|
||||
},
|
||||
|
||||
//
|
||||
// TRANSLATION: GLatLngBounds <-> OpenLayers.Bounds
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GLatLngBounds} gLatLngBounds
|
||||
*
|
||||
* @returns An OpenLayers.Bounds, translated from gLatLngBounds
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getOLBoundsFromGLatLngBounds: function(gLatLngBounds) {
|
||||
var olBounds = null;
|
||||
if (gLatLngBounds != null) {
|
||||
var sw = gLatLngBounds.getSouthWest();
|
||||
var ne = gLatLngBounds.getNorthEast();
|
||||
olBounds = new OpenLayers.Bounds(sw.lng(),
|
||||
sw.lat(),
|
||||
ne.lng(),
|
||||
ne.lat() );
|
||||
}
|
||||
return olBounds;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} olBounds
|
||||
*
|
||||
* @returns A GLatLngBounds, translated from olBounds
|
||||
* Returns null if null value is passed in
|
||||
* @type GLatLngBounds
|
||||
*/
|
||||
getGLatLngBoundsFromOLBounds: function(olBounds) {
|
||||
var gLatLngBounds = null;
|
||||
if (olBounds != null) {
|
||||
var sw = new GLatLng(olBounds.bottom, olBounds.left);
|
||||
var ne = new GLatLng(olBounds.top, olBounds.right);
|
||||
gLatLngBounds = new GLatLngBounds(sw, ne);
|
||||
}
|
||||
return gLatLngBounds;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns X value of the MapObject Pixel
|
||||
* @type int
|
||||
*/
|
||||
getXFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.x;
|
||||
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;
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns Y value of the MapObject Pixel
|
||||
* @type int
|
||||
*/
|
||||
getYFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.y;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} x
|
||||
* @param {int} y
|
||||
*
|
||||
* @returns MapObject Pixel from x and y parameters
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new GPoint(x, y);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Google"
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/HTTPRequest.js
|
||||
*/
|
||||
OpenLayers.Layer.Grid = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Grid = Class.create();
|
||||
OpenLayers.Layer.Grid.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.HTTPRequest, {
|
||||
Object.extend( new OpenLayers.Layer.HTTPRequest(), {
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
@@ -69,8 +69,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
obj.tileSize = this.tileSize.clone();
|
||||
}
|
||||
|
||||
// we do not want to copy reference to grid, so we make a new array
|
||||
obj.grid = new Array();
|
||||
// we do not want to copy reference to grid. that should stay at null
|
||||
obj.grid = null;
|
||||
|
||||
return obj;
|
||||
},
|
||||
@@ -96,8 +96,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
* @param {Boolean} dragging
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);
|
||||
|
||||
if (bounds == null) {
|
||||
bounds = this.map.getExtent();
|
||||
}
|
||||
@@ -243,7 +241,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
|
||||
var iRow = 0;
|
||||
var iCell = -1;
|
||||
var direction = OpenLayers.Util.indexOf(directions, "right");
|
||||
var direction = directions.indexOf("right");
|
||||
var directionsTried = 0;
|
||||
|
||||
while( directionsTried < directions.length) {
|
||||
@@ -324,7 +322,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
for(var iRow=0; iRow < this.grid.length; iRow++) {
|
||||
var row = this.grid[iRow];
|
||||
for(var iCol=0; iCol < row.length; iCol++) {
|
||||
OpenLayers.Util.clearArray(row[iCol]);
|
||||
row[iCol].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
*/
|
||||
OpenLayers.Layer.HTTPRequest = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.HTTPRequest = Class.create();
|
||||
OpenLayers.Layer.HTTPRequest.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer, {
|
||||
Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** @type String */
|
||||
url: null,
|
||||
@@ -17,15 +17,6 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
/** Hashtable of key/value parameters
|
||||
* @type Object */
|
||||
params: null,
|
||||
|
||||
/** Whether layer should reproject itself based on base layer locations.
|
||||
* This allows reprojection onto commercial layers. Default is false:
|
||||
* Most layers can't reproject, but layers which can create non-square
|
||||
* geographic pixels can, like WMS.
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
reproject: false,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -37,10 +28,12 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
*/
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = arguments;
|
||||
newArguments = [name, options];
|
||||
if (arguments.length > 0) {
|
||||
newArguments = [name, options];
|
||||
}
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
|
||||
this.url = url;
|
||||
this.params = OpenLayers.Util.extend( new Object(), params);
|
||||
this.params = Object.extend( new Object(), params);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -86,7 +79,7 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
* @param {Object} newParams
|
||||
*/
|
||||
mergeNewParams:function(newParams) {
|
||||
this.params = OpenLayers.Util.extend(this.params, newParams);
|
||||
this.params = Object.extend(this.params, newParams);
|
||||
},
|
||||
|
||||
|
||||
@@ -113,8 +106,8 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
|
||||
// create a new params hashtable with all the layer params and the
|
||||
// new params together. then convert to string
|
||||
var allParams = OpenLayers.Util.extend(new Object(), this.params);
|
||||
var allParams = OpenLayers.Util.extend(allParams, newParams);
|
||||
var allParams = Object.extend(new Object(), this.params);
|
||||
var allParams = Object.extend(allParams, newParams);
|
||||
var paramsString = OpenLayers.Util.getParameterString(allParams);
|
||||
|
||||
if (paramsString != "") {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/Grid.js
|
||||
*/
|
||||
OpenLayers.Layer.KaMap = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.KaMap = Class.create();
|
||||
OpenLayers.Layer.KaMap.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
|
||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||
|
||||
/** KaMap Layer is always a base layer
|
||||
*
|
||||
@@ -31,7 +31,7 @@ OpenLayers.Layer.KaMap.prototype =
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (params) {
|
||||
if (arguments.length > 0 && params) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
this.DEFAULT_PARAMS
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
// @requires OpenLayers/Layer/Grid.js
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Layer.MapServer = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.MapServer.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
|
||||
|
||||
/** @final @type hash */
|
||||
DEFAULT_PARAMS: {
|
||||
mode: "map",
|
||||
map_imagetype: "png"
|
||||
},
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {str} name
|
||||
* @param {str} url
|
||||
* @param {hash} params
|
||||
*/
|
||||
initialize: function(name, url, params) {
|
||||
var newArguments = new Array();
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: function() {
|
||||
return (this.params.TRANSPARENT != 'true');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {hash} params
|
||||
*
|
||||
* @returns A clone of this OpenLayers.Layer.MapServer, with the passed-in
|
||||
* parameters merged in.
|
||||
* @type OpenLayers.Layer.MapServer
|
||||
*/
|
||||
clone: function (name, params) {
|
||||
var mergedParams = {};
|
||||
OpenLayers.Util.extend(mergedParams, this.params);
|
||||
OpenLayers.Util.extend(mergedParams, params);
|
||||
var obj = new OpenLayers.Layer.MapServer(name, this.url, mergedParams);
|
||||
obj.setTileSize(this.tileSize);
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* addTile creates a tile, initializes it (via 'draw' in this case), and
|
||||
* adds it to the layer div.
|
||||
*
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns The added OpenLayers.Tile.Image
|
||||
* @type OpenLayers.Tile.Image
|
||||
*/
|
||||
addTile:function(bounds,position) {
|
||||
var url = this.getURL(bounds);
|
||||
return new OpenLayers.Tile.Image(this, position, bounds, url, this.tileSize);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns A string with the layer's url and parameters and also the
|
||||
* passed-in bounds and appropriate tile size specified as
|
||||
* parameters
|
||||
* @type String
|
||||
*/
|
||||
getURL: function (bounds) {
|
||||
|
||||
var url = this.getFullRequestString(
|
||||
{mapext:bounds.toBBOX().replace(/,/g,"+"),
|
||||
imgext:bounds.toBBOX().replace(/,/g,"+"),
|
||||
map_size:this.tileSize.w+'+'+this.tileSize.h,
|
||||
imgx: this.tileSize.w/2,
|
||||
imgy: this.tileSize.h/2,
|
||||
imgxy: this.tileSize.w+"+"+this.tileSize.h
|
||||
});
|
||||
return url;
|
||||
},
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.MapServer"
|
||||
});
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
*/
|
||||
OpenLayers.Layer.Markers = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Markers = Class.create();
|
||||
OpenLayers.Layer.Markers.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer, {
|
||||
Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** Markers layer is never a base layer.
|
||||
*
|
||||
@@ -45,11 +45,9 @@ OpenLayers.Layer.Markers.prototype =
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} dragging
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
||||
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
if (zoomChanged) {
|
||||
this.redraw();
|
||||
}
|
||||
@@ -70,7 +68,7 @@ OpenLayers.Layer.Markers.prototype =
|
||||
* @param {OpenLayers.Marker} marker
|
||||
*/
|
||||
removeMarker: function(marker) {
|
||||
OpenLayers.Util.removeItem(this.markers, marker);
|
||||
this.markers.remove(marker);
|
||||
if ((marker.icon != null) && (marker.icon.imageDiv != null) &&
|
||||
(marker.icon.imageDiv.parentNode == this.div) ) {
|
||||
this.div.removeChild(marker.icon.imageDiv);
|
||||
|
||||
@@ -3,63 +3,103 @@
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*/
|
||||
OpenLayers.Layer.MultiMap = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.MultiMap.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
OpenLayers.Layer.MultiMap = Class.create();
|
||||
OpenLayers.Layer.MultiMap.prototype =
|
||||
Object.extend( new OpenLayers.Layer.EventPane(), {
|
||||
|
||||
/** @type MMMap */
|
||||
multimap: null,
|
||||
|
||||
/** @final @type int */
|
||||
MIN_ZOOM_LEVEL: 1,
|
||||
/** @type int */
|
||||
minZoomLevel: 1,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/** @final @type int */
|
||||
MAX_ZOOM_LEVEL: 17,
|
||||
|
||||
/** Hardcode these resolutions so that they are more closely
|
||||
* tied with the standard wms projection
|
||||
*
|
||||
* @final @type Array(float) */
|
||||
RESOLUTIONS: [9, 1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
|
||||
|
||||
/** @type VEMapType */
|
||||
type: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
try { //crash proofing
|
||||
this.mapObject = new MultimapViewer(this.div);
|
||||
} catch (e) { }
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return String with information on why layer is broken, how to get
|
||||
* it working.
|
||||
* @type String
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
getWarningHTML:function() {
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load the multimap
|
||||
this.loadMMMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if (this.multimap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
var mmCenter = this.getMMLatLongFromOLLonLat(olCenter);
|
||||
|
||||
if (zoomChanged) {
|
||||
var olZoom = this.map.getZoom();
|
||||
var mmZoom = this.getMMZoomFromOLZoom(olZoom);
|
||||
|
||||
this.multimap.goToPosition(mmCenter, mmZoom);
|
||||
} else {
|
||||
this.multimap.goToPosition(mmCenter);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadMMMap:function() {
|
||||
|
||||
try {
|
||||
// create MMMap, hide nav controls
|
||||
this.multimap = new MultimapViewer(this.div);
|
||||
} catch (e) {
|
||||
// do nothing this is to keep from crashing
|
||||
// if the MM library was not loaded.
|
||||
}
|
||||
|
||||
|
||||
if (this.multimap == null) {
|
||||
this.loadWarningMessage();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/** If we can't load the multimap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
*/
|
||||
loadWarningMessage:function() {
|
||||
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
|
||||
var html = "";
|
||||
html += "The MM Layer was unable to load correctly.<br>";
|
||||
html += "<br>";
|
||||
html += "To get rid of this message, select a new BaseLayer "
|
||||
html += "in the layer switcher in the upper-right corner.<br>";
|
||||
html += "To get rid of this message, click on the MM Layer's "
|
||||
html += "tab in the layer switcher in the upper-right corner.<br>";
|
||||
html += "<br>";
|
||||
html += "Most likely, this is because the MM library";
|
||||
html += " script was either not correctly included.<br>";
|
||||
@@ -69,145 +109,229 @@ OpenLayers.Layer.MultiMap.prototype =
|
||||
html += "target='_blank'>";
|
||||
html += "click here";
|
||||
html += "</a>";
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
return html;
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv("mmWarning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = html;
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Interface Controls *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// Get&Set Center, Zoom
|
||||
|
||||
/** Set the mapObject to the specified center and zoom
|
||||
*
|
||||
* @param {Object} center MapObject LonLat format
|
||||
* @param {int} zoom MapObject zoom format
|
||||
*/
|
||||
setMapObjectCenter: function(center, zoom) {
|
||||
this.mapObject.goToPosition(center, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current center in Map Object format
|
||||
* @type Object
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by MM
|
||||
* If multimap is not loaded, returns null.
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getMapObjectCenter: function() {
|
||||
return this.mapObject.getCurrentPosition();
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if (this.multimap != null) {
|
||||
var pixel = this.getPixelFromOLPixel(viewPortPx);
|
||||
var zoom = this.multimap.getZoomFactor();
|
||||
pixel.x = pixel.x - (this.map.getSize().w/2);
|
||||
pixel.y = pixel.y - (this.map.getSize().h/2);
|
||||
var mmLatLong = this.multimap.getMapPositionAt(pixel);
|
||||
lonlat = this.getOLLonLatFromMMLatLong(mmLatLong);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current zoom, in Map Object format
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY MM
|
||||
* If multimap is not loaded, returns null.
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if (this.multimap != null) {
|
||||
var mmLatLong = this.getMMLatLongFromOLLonLat(lonlat);
|
||||
var pixel = this.multimap.geoPosToContainerPixels(mmLatLong);
|
||||
viewPortPx = this.getOLPixelFromPixel(pixel);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom lemml for a specified Bounds.
|
||||
* If multimap is not loaded, returns null.
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoom: function() {
|
||||
return this.mapObject.getZoomFactor();
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var zoom = null;
|
||||
if (this.multimap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var mmZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var mmZoom = Math.min(Math.max(mmZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromMMZoom(mmZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
|
||||
// LonLat - Pixel Translation
|
||||
//
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject LonLat translated from MapObject Pixel
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
|
||||
moPixel.x = moPixel.x - (this.map.getSize().w/2);
|
||||
moPixel.y = moPixel.y - (this.map.getSize().h/2);
|
||||
return this.mapObject.getMapPositionAt(moPixel);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject Pixel translated from MapObject LonLat
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
|
||||
return this.mapObject.geoPosToContainerPixels(moLonLat);
|
||||
},
|
||||
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Primitives *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// LonLat
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
* @param {int} mmZoom
|
||||
*
|
||||
* @returns Longitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lon;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns Latitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} lon float
|
||||
* @param {int} lat float
|
||||
*
|
||||
* @returns MapObject LonLat built from lon and lat params
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new MMLatLon(lat, lon);
|
||||
},
|
||||
|
||||
// Pixel
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns X value of the MapObject Pixel
|
||||
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getXFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.x;
|
||||
getOLZoomFromMMZoom: function(mmZoom) {
|
||||
if (mmZoom) return mmZoom - 1;
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns Y value of the MapObject Pixel
|
||||
* @returns A MMZoom lemml, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getYFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.y;
|
||||
getMMZoomFromOLZoom: function(olZoom) {
|
||||
if (olZoom) return olZoom + 1;
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} x
|
||||
* @param {int} y
|
||||
//
|
||||
// TRANSLATION: MMLatLong <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {MMLatLong} mmLatLong
|
||||
*
|
||||
* @returns MapObject Pixel from x and y parameters
|
||||
* @type Object
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in MMLatLong
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new MMPoint(x, y);
|
||||
getOLLonLatFromMMLatLong: function(mmLatLong) {
|
||||
var olLonLat = null;
|
||||
if (mmLatLong != null) {
|
||||
olLonLat = new OpenLayers.LonLat(mmLatLong.lon,
|
||||
mmLatLong.lat);
|
||||
}
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns A MMLatLong, translated from the passed in OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type MMLatLong
|
||||
*/
|
||||
getMMLatLongFromOLLonLat: function(olLonLat) {
|
||||
var mmLatLong = null;
|
||||
if (olLonLat != null) {
|
||||
mmLatLong = new MMLatLon(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return mmLatLong;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: Pixel <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Pixel} pixel
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromPixel: function(pixel) {
|
||||
var olPixel = null;
|
||||
if (pixel != null) {
|
||||
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
*
|
||||
* As it turns out, the only specifications we can see for the
|
||||
* MM-compatible Pixel is an x & y property, which emmry
|
||||
* OpenLayers.Pixel has by default. So just leamm it as-is.
|
||||
*
|
||||
* @type Pixel
|
||||
*/
|
||||
getPixelFromOLPixel: function(olPixel) {
|
||||
var pixel = null;
|
||||
if (olPixel != null) {
|
||||
pixel = new MMPoint(olPixel.x, olPixel.y);
|
||||
}
|
||||
return pixel;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this.multimap = null;
|
||||
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.MultiMap"
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/Markers.js
|
||||
*/
|
||||
OpenLayers.Layer.Text = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Text = Class.create();
|
||||
OpenLayers.Layer.Text.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** store url of text file - this should be specified in the
|
||||
* "options" hashtable
|
||||
@@ -145,7 +145,7 @@ OpenLayers.Layer.Text.prototype =
|
||||
if (!sameMarkerClicked) {
|
||||
this.layer.map.addPopup(this.createPopup());
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -155,14 +155,14 @@ OpenLayers.Layer.Text.prototype =
|
||||
if (this.features != null) {
|
||||
while(this.features.length > 0) {
|
||||
var feature = this.features[0];
|
||||
OpenLayers.Util.removeItem(this.features, feature);
|
||||
this.features.remove(feature);
|
||||
feature.destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Text"
|
||||
CLASS_NAME: "OpenLayers.Text"
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -3,46 +3,75 @@
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*/
|
||||
OpenLayers.Layer.VirtualEarth = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
OpenLayers.Layer.VirtualEarth = Class.create();
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
Object.extend( new OpenLayers.Layer.EventPane(),
|
||||
Object.extend( new OpenLayers.Layer.FixedZoomLevels(), {
|
||||
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/** @final @type int */
|
||||
MIN_ZOOM_LEVEL: 1,
|
||||
/** @type int */
|
||||
minZoomLevel: 1,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/** @final @type int */
|
||||
MAX_ZOOM_LEVEL: 17,
|
||||
|
||||
/** Hardcode these resolutions so that they are more closely
|
||||
* tied with the standard wms projection
|
||||
*
|
||||
* @final @type Array(float) */
|
||||
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
|
||||
|
||||
/** @type VEMapType */
|
||||
type: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load the vemap
|
||||
this.loadVEMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if (this.vemap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
var veCenter = this.getVELatLongFromOLLonLat(olCenter);
|
||||
|
||||
if (zoomChanged) {
|
||||
var olZoom = this.map.getZoom();
|
||||
var veZoom = this.getVEZoomFromOLZoom(olZoom);
|
||||
|
||||
this.vemap.SetCenterAndZoom(veCenter, veZoom);
|
||||
} else {
|
||||
this.vemap.PanToLatLong(veCenter);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
loadVEMap:function() {
|
||||
|
||||
// create div and set to same size as map
|
||||
var veDiv = OpenLayers.Util.createDiv(this.name);
|
||||
@@ -51,30 +80,47 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
veDiv.style.height = sz.h;
|
||||
this.div.appendChild(veDiv);
|
||||
|
||||
try { // crash prevention
|
||||
this.mapObject = new VEMap(this.name);
|
||||
} catch (e) { }
|
||||
try {
|
||||
|
||||
if (this.mapObject != null) {
|
||||
try { // this is to catch a Mozilla bug without falling apart
|
||||
this.mapObject.LoadMap(null, null, this.type);
|
||||
} catch (e) { }
|
||||
this.mapObject.HideDashboard();
|
||||
// create VEMap, hide nav controls
|
||||
this.vemap = new VEMap(this.name);
|
||||
} catch (e) {
|
||||
// do nothing this is to keep from crashing
|
||||
// if the VE library was not loaded.
|
||||
}
|
||||
|
||||
|
||||
if (this.vemap == null) {
|
||||
this.loadWarningMessage();
|
||||
} else {
|
||||
|
||||
|
||||
try {
|
||||
this.vemap.LoadMap();
|
||||
} catch (e) {
|
||||
// this is to catch a Mozilla bug without falling apart
|
||||
}
|
||||
|
||||
this.vemap.HideDashboard();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @return String with information on why layer is broken, how to get
|
||||
* it working.
|
||||
* @type String
|
||||
/** If we can't load the vemap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
*/
|
||||
getWarningHTML:function() {
|
||||
loadWarningMessage:function() {
|
||||
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
|
||||
var html = "";
|
||||
html += "The VE Layer was unable to load correctly.<br>";
|
||||
html += "<br>";
|
||||
html += "To get rid of this message, select a new BaseLayer "
|
||||
html += "in the layer switcher in the upper-right corner.<br>";
|
||||
html += "To get rid of this message, click on the VE Layer's "
|
||||
html += "tab in the layer switcher in the upper-right corner.<br>";
|
||||
html += "<br>";
|
||||
html += "Most likely, this is because the VE library";
|
||||
html += " script was either not correctly included.<br>";
|
||||
@@ -84,144 +130,229 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
html += "target='_blank'>";
|
||||
html += "click here";
|
||||
html += "</a>";
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
return html;
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv("veWarning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = html;
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Interface Controls *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// Get&Set Center, Zoom
|
||||
|
||||
/** Set the mapObject to the specified center and zoom
|
||||
*
|
||||
* @param {Object} center MapObject LonLat format
|
||||
* @param {int} zoom MapObject zoom format
|
||||
*/
|
||||
setMapObjectCenter: function(center, zoom) {
|
||||
this.mapObject.SetCenterAndZoom(center, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current center in Map Object format
|
||||
* @type Object
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by VE
|
||||
* If vemap is not loaded, returns null.
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getMapObjectCenter: function() {
|
||||
return this.mapObject.GetCenter();
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if (this.vemap != null) {
|
||||
var pixel = this.getPixelFromOLPixel(viewPortPx);
|
||||
var zoom = this.vemap.GetZoomLevel();
|
||||
var veLatLong = this.vemap.PixelToLatLong(pixel.x, pixel.y, zoom);
|
||||
lonlat = this.getOLLonLatFromVELatLong(veLatLong);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current zoom, in Map Object format
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY VE
|
||||
* If vemap is not loaded, returns null.
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if (this.vemap != null) {
|
||||
var veLatLong = this.getVELatLongFromOLLonLat(lonlat);
|
||||
var pixel = this.vemap.LatLongToPixel(veLatLong);
|
||||
viewPortPx = this.getOLPixelFromPixel(pixel);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom level for a specified Bounds.
|
||||
* If vemap is not loaded, returns null.
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoom: function() {
|
||||
return this.mapObject.GetZoomLevel();
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var zoom = null;
|
||||
if (this.vemap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
|
||||
// LonLat - Pixel Translation
|
||||
//
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject LonLat translated from MapObject Pixel
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
|
||||
return this.mapObject.PixelToLatLong(moPixel.x, moPixel.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject Pixel translated from MapObject LonLat
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
|
||||
return this.mapObject.LatLongToPixel(moLonLat);
|
||||
},
|
||||
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Primitives *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// LonLat
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
* @param {int} veZoom
|
||||
*
|
||||
* @returns Longitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Longitude;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns Latitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Latitude;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} lon float
|
||||
* @param {int} lat float
|
||||
*
|
||||
* @returns MapObject LonLat built from lon and lat params
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new VELatLong(lat, lon);
|
||||
},
|
||||
|
||||
// Pixel
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns X value of the MapObject Pixel
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in veZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getXFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.x;
|
||||
getOLZoomFromVEZoom: function(veZoom) {
|
||||
var zoom = null;
|
||||
if (veZoom != null) {
|
||||
zoom = veZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns Y value of the MapObject Pixel
|
||||
* @returns A VEZoom level, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getYFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.y;
|
||||
getVEZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} x
|
||||
* @param {int} y
|
||||
//
|
||||
// TRANSLATION: VELatLong <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {VELatLong} veLatLong
|
||||
*
|
||||
* @returns MapObject Pixel from x and y parameters
|
||||
* @type Object
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in VELatLong
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new Msn.VE.Pixel(x, y);
|
||||
getOLLonLatFromVELatLong: function(veLatLong) {
|
||||
var olLonLat = null;
|
||||
if (veLatLong != null) {
|
||||
olLonLat = new OpenLayers.LonLat(veLatLong.Longitude,
|
||||
veLatLong.Latitude);
|
||||
}
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns A VELatLong, translated from the passed in OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type VELatLong
|
||||
*/
|
||||
getVELatLongFromOLLonLat: function(olLonLat) {
|
||||
var veLatLong = null;
|
||||
if (olLonLat != null) {
|
||||
veLatLong = new VELatLong(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return veLatLong;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: Pixel <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Pixel} pixel
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromPixel: function(pixel) {
|
||||
var olPixel = null;
|
||||
if (pixel != null) {
|
||||
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
*
|
||||
* As it turns out, the only specifications we can see for the
|
||||
* VE-compatible Pixel is an x & y property, which every
|
||||
* OpenLayers.Pixel has by default. So just leave it as-is.
|
||||
*
|
||||
* @type Pixel
|
||||
*/
|
||||
getPixelFromOLPixel: function(olPixel) {
|
||||
var pixel = null;
|
||||
if (olPixel != null) {
|
||||
pixel = new Msn.VE.Pixel(olPixel.x, olPixel.y);
|
||||
}
|
||||
return pixel;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
* @requires OpenLayers/Layer/Grid.js
|
||||
* @requires OpenLayers/Layer/Markers.js
|
||||
*/
|
||||
OpenLayers.Layer.WFS = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.WFS = Class.create();
|
||||
OpenLayers.Layer.WFS.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid,
|
||||
OpenLayers.Layer.Markers, {
|
||||
Object.extend(new OpenLayers.Layer.Grid(),
|
||||
Object.extend(new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** WFS layer is never a base layer.
|
||||
*
|
||||
@@ -52,20 +52,26 @@ OpenLayers.Layer.WFS.prototype =
|
||||
*/
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = new Array();
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
}
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
var newArguments = new Array();
|
||||
//uppercase params
|
||||
newArguments.push(name, options);
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
newArguments.push(name, options);
|
||||
}
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -88,9 +94,9 @@ OpenLayers.Layer.WFS.prototype =
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} dragging
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments);
|
||||
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
|
||||
},
|
||||
@@ -221,4 +227,6 @@ OpenLayers.Layer.WFS.prototype =
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WFS"
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/Grid.js
|
||||
*/
|
||||
OpenLayers.Layer.WMS = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.WMS = Class.create();
|
||||
OpenLayers.Layer.WMS.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
|
||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||
|
||||
/** Hashtable of default parameter key/value pairs
|
||||
* @final @type Object */
|
||||
@@ -20,8 +20,6 @@ OpenLayers.Layer.WMS.prototype =
|
||||
exceptions: "application/vnd.ogc.se_inimage",
|
||||
format: "image/jpeg"
|
||||
},
|
||||
|
||||
reproject: true,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -33,18 +31,23 @@ OpenLayers.Layer.WMS.prototype =
|
||||
*/
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = new Array();
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
}
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
}
|
||||
|
||||
// unless explicitly set in options, if the layer is transparent,
|
||||
// it will be an overlay
|
||||
if (options == null || options.isBaseLayer == null) {
|
||||
if ((options == null) || !(options.isBaseLayer)) {
|
||||
this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
|
||||
(this.params.TRANSPARENT != true));
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
* @requires OpenLayers/Layer/HTTPRequest.js
|
||||
* @requires OpenLayers/Layer/WMS.js
|
||||
*/
|
||||
OpenLayers.Layer.WMS.Untiled = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.WMS.Untiled = Class.create();
|
||||
OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.HTTPRequest, {
|
||||
Object.extend( new OpenLayers.Layer.HTTPRequest(), {
|
||||
|
||||
/** Hashtable of default parameter key/value pairs
|
||||
* @final @type Object */
|
||||
@@ -21,14 +21,9 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
exceptions: "application/vnd.ogc.se_inimage",
|
||||
format: "image/jpeg"
|
||||
},
|
||||
reproject: true,
|
||||
|
||||
/** the ratio of image/tile size to map size (this is the untiled buffer)
|
||||
* @type int */
|
||||
ratio: 2,
|
||||
|
||||
/** @type OpenLayers.Tile.Image */
|
||||
tile: null,
|
||||
/** @type DOMElement */
|
||||
imgDiv: null,
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,15 +35,20 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
*/
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = new Array();
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params, options);
|
||||
}
|
||||
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
|
||||
newArguments);
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
}
|
||||
|
||||
// unless explicitly set in options, if the layer is transparent,
|
||||
// it will be an overlay
|
||||
@@ -62,8 +62,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.tile.destroy();
|
||||
this.tile = null;
|
||||
this.imgDiv = null;
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -97,78 +96,72 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.HTTPRequest.prototype.setMap.apply(this, arguments);
|
||||
this.loadImageDiv();
|
||||
},
|
||||
|
||||
/** When it is not a dragging move (ie when done dragging)
|
||||
/** When it is not a minor move (ie when panning or when done dragging)
|
||||
* reload and recenter the div.
|
||||
*
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} dragging
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this,arguments);
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if (!minor) {
|
||||
|
||||
if (bounds == null) {
|
||||
bounds = this.map.getExtent();
|
||||
}
|
||||
|
||||
var firstRendering = (this.tile == null);
|
||||
|
||||
//does the new bounds to which we need to move fall outside of the
|
||||
// current tile's bounds?
|
||||
var outOfBounds = (!firstRendering &&
|
||||
!this.tile.bounds.containsBounds(bounds));
|
||||
|
||||
if ( zoomChanged || firstRendering || (!dragging && outOfBounds) ) {
|
||||
|
||||
//clear out the old tile
|
||||
if (this.tile) {
|
||||
OpenLayers.Util.clearArray(this.tile);
|
||||
if (bounds == null) {
|
||||
bounds = this.map.getExtent();
|
||||
}
|
||||
|
||||
var size = this.map.getSize().clone();
|
||||
|
||||
//determine new tile bounds
|
||||
var center = bounds.getCenterLonLat();
|
||||
var tileWidth = bounds.getWidth() * this.ratio;
|
||||
var tileHeight = bounds.getHeight() * this.ratio;
|
||||
var tileBounds =
|
||||
new OpenLayers.Bounds(center.lon - (tileWidth / 2),
|
||||
center.lat - (tileHeight / 2),
|
||||
center.lon + (tileWidth / 2),
|
||||
center.lat + (tileHeight / 2));
|
||||
// get the url
|
||||
var url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
||||
WIDTH: size.w,
|
||||
HEIGHT: size.h} );
|
||||
|
||||
|
||||
//determine new tile size
|
||||
var tileSize = this.map.getSize();
|
||||
tileSize.w = tileSize.w * this.ratio;
|
||||
tileSize.h = tileSize.h * this.ratio;
|
||||
// always position at upper left corner of current viewspace
|
||||
var tl = new OpenLayers.Pixel(0,0);
|
||||
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
||||
|
||||
//formulate request url string
|
||||
var url = this.getURL(tileBounds);
|
||||
|
||||
//determine new position (upper left corner of new bounds)
|
||||
var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
|
||||
var pos = this.map.getLayerPxFromLonLat(ul);
|
||||
|
||||
if (!this.tile) {
|
||||
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
|
||||
url, tileSize);
|
||||
this.tile.draw();
|
||||
// first hide before all modifications
|
||||
Element.hide(this.imgDiv);
|
||||
|
||||
// update div
|
||||
var img = this.imgDiv;
|
||||
if (this.params.TRANSPARENT == 'true') {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
|
||||
null,
|
||||
pos,
|
||||
size,
|
||||
url);
|
||||
img = this.imgDiv.childNodes[0];
|
||||
} else {
|
||||
this.tile.moveTo(tileBounds, pos);
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv,
|
||||
null,
|
||||
pos,
|
||||
size);
|
||||
this.imgDiv.src = url;
|
||||
}
|
||||
|
||||
// wait until image is done loading to show again
|
||||
Event.observe(img,
|
||||
"load",
|
||||
this.showDiv.bindAsEventListener(this));
|
||||
}
|
||||
},
|
||||
|
||||
getURL: function(bounds) {
|
||||
var tileSize = this.map.getSize();
|
||||
tileSize.w = tileSize.w * this.ratio;
|
||||
tileSize.h = tileSize.h * this.ratio;
|
||||
return this.getFullRequestString( {'BBOX': bounds.toBBOX(),
|
||||
'WIDTH': tileSize.w,
|
||||
'HEIGHT': tileSize.h} );
|
||||
/** Helper function that allows us to first hide the imgDiv, then make all
|
||||
* the changes (position, size, url). Then when the url is done loading,
|
||||
* we call this function to show the imgDiv.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
showDiv: function() {
|
||||
Element.show(this.imgDiv);
|
||||
},
|
||||
|
||||
|
||||
/** Once HTTPRequest has updated the url, reload the image div
|
||||
* @param {String} newUrl
|
||||
@@ -208,6 +201,48 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
this, arguments);
|
||||
},
|
||||
|
||||
/** This function first removes the previous image div, then adds a new
|
||||
* one according to the transparency property.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
loadImageDiv: function() {
|
||||
|
||||
var size = this.map.getSize().clone();
|
||||
var bounds = this.map.getExtent();
|
||||
|
||||
var url = "";
|
||||
if (bounds != null) {
|
||||
url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
||||
WIDTH: size.w,
|
||||
HEIGHT: size.h} );
|
||||
}
|
||||
|
||||
//clear previous wms image (removes imgDiv)
|
||||
this.div.innerHTML = "";
|
||||
|
||||
//always position at upper left corner of current viewspace
|
||||
var tl = new OpenLayers.Pixel(0,0);
|
||||
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
||||
|
||||
//create div
|
||||
if (this.params.TRANSPARENT == 'true') {
|
||||
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
||||
pos,
|
||||
size,
|
||||
url,
|
||||
"absolute");
|
||||
} else {
|
||||
this.imgDiv = OpenLayers.Util.createImage(null,
|
||||
pos,
|
||||
size,
|
||||
url,
|
||||
"absolute");
|
||||
}
|
||||
|
||||
this.div.appendChild(this.imgDiv);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WMS.Untiled"
|
||||
});
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Layer/Grid.js
|
||||
*/
|
||||
OpenLayers.Layer.WorldWind = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.WorldWind = Class.create();
|
||||
OpenLayers.Layer.WorldWind.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, {
|
||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||
|
||||
DEFAULT_PARAMS: {
|
||||
},
|
||||
@@ -32,7 +32,7 @@ OpenLayers.Layer.WorldWind.prototype =
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (params) {
|
||||
if (arguments.length > 0 && params) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
this.DEFAULT_PARAMS
|
||||
@@ -42,20 +42,23 @@ OpenLayers.Layer.WorldWind.prototype =
|
||||
addTile:function(bounds,position) {
|
||||
if (this.map.getResolution() <= (this.lzd/512)
|
||||
&& this.getZoom() <= this.zoomLevels) {
|
||||
var url = this.getURL(bounds);
|
||||
|
||||
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||
url, this.tileSize);
|
||||
} else {
|
||||
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||
OpenLayers.Util.getImagesLocation() + "blank.gif",
|
||||
this.tileSize);
|
||||
var tile = new Object();
|
||||
tile.draw = function() {};
|
||||
tile.destroy = function() {};
|
||||
tile.bounds = bounds;
|
||||
tile.bounds = position;
|
||||
return tile;
|
||||
}
|
||||
},
|
||||
|
||||
getZoom: function () {
|
||||
var zoom = this.map.getZoom();
|
||||
var extent = this.map.getMaxExtent();
|
||||
zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2);
|
||||
zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2);
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -68,21 +71,14 @@ OpenLayers.Layer.WorldWind.prototype =
|
||||
* @type String
|
||||
*/
|
||||
getURL: function (bounds) {
|
||||
var zoom = this.getZoom();
|
||||
var extent = this.map.getMaxExtent();
|
||||
var deg = this.lzd/Math.pow(2,this.getZoom());
|
||||
var x = Math.floor((bounds.left - extent.left)/deg);
|
||||
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
|
||||
if (this.map.getResolution() <= (this.lzd/512)
|
||||
&& this.getZoom() <= this.zoomLevels) {
|
||||
return this.getFullRequestString(
|
||||
return this.getFullRequestString(
|
||||
{ L: zoom,
|
||||
X: x,
|
||||
Y: y
|
||||
});
|
||||
} else {
|
||||
return OpenLayers.Util.getImagesLocation() + "blank.gif";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -3,105 +3,207 @@
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*/
|
||||
OpenLayers.Layer.Yahoo = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Yahoo.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
OpenLayers.Layer.Yahoo = Class.create();
|
||||
OpenLayers.Layer.Yahoo.prototype =
|
||||
Object.extend( new OpenLayers.Layer.EventPane(), {
|
||||
|
||||
/** @type YMap */
|
||||
yahoomap: null,
|
||||
|
||||
/** @final @type int */
|
||||
MIN_ZOOM_LEVEL: 0,
|
||||
/** @type int */
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 15,
|
||||
|
||||
/** @final @type int */
|
||||
MAX_ZOOM_LEVEL: 15,
|
||||
|
||||
/** Hardcode these resolutions so that they are more closely
|
||||
* tied with the standard wms projection
|
||||
*
|
||||
* @final @type Array(float) */
|
||||
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
|
||||
|
||||
/** @type YahooMapType */
|
||||
type: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize: function(name, options) {
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
try { //do not crash!
|
||||
this.mapObject = new YMap(this.div, this.type);
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
|
||||
/** Overridden from EventPane because we need to remove this yahoo event
|
||||
* pane which prohibits our drag and drop, and we can only do this
|
||||
* once the map has been loaded and centered.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
this.map.events.register("moveend", this, this.fixYahooEventPane);
|
||||
},
|
||||
|
||||
/** The map has been centered, so the mysterious yahoo eventpane has been
|
||||
* added. we remove it so that it doesnt mess with *our* event pane.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
fixYahooEventPane: function() {
|
||||
var yahooEventPane = $("ygddfdiv");
|
||||
if (yahooEventPane != null) {
|
||||
if (yahooEventPane.parentNode != null)
|
||||
yahooEventPane.parentNode.removeChild(yahooEventPane);
|
||||
|
||||
this.map.events.unregister("moveend", this,
|
||||
this.fixYahooEventPane);
|
||||
}
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return String with information on why layer is broken, how to get
|
||||
* it working.
|
||||
* @type String
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
getWarningHTML:function() {
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load the yahoomap
|
||||
this.loadYMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if (this.yahoomap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
var mmCenter = this.getYLatLongFromOLLonLat(olCenter);
|
||||
|
||||
if (zoomChanged) {
|
||||
var olZoom = this.map.getZoom();
|
||||
var mmZoom = this.getYZoomFromOLZoom(olZoom);
|
||||
this.yahoomap.setZoomLevel(mmZoom);
|
||||
}
|
||||
this.yahoomap.drawZoomAndCenter(mmCenter, mmZoom);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadYMap:function() {
|
||||
this.yahoomap = new YMap(this.div);
|
||||
|
||||
|
||||
if (this.yahoomap == null) {
|
||||
this.loadWarningMessage();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/** If we can't load the yahoomap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
*/
|
||||
loadWarningMessage:function() {
|
||||
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
|
||||
var html = "";
|
||||
html += "The Yahoo Layer was unable to load correctly.<br>";
|
||||
html += "The Y Layer was unable to load correctly.<br>";
|
||||
html += "<br>";
|
||||
html += "To get rid of this message, select a new BaseLayer "
|
||||
html += "in the layer switcher in the upper-right corner.<br>";
|
||||
html += "To get rid of this message, click on the Y Layer's "
|
||||
html += "tab in the layer switcher in the upper-right corner.<br>";
|
||||
html += "<br>";
|
||||
html += "Most likely, this is because the Yahoo library";
|
||||
html += "Most likely, this is because the Y library";
|
||||
html += " script was either not correctly included.<br>";
|
||||
html += "<br>";
|
||||
html += "Developers: For help getting this working correctly, ";
|
||||
html += "Demmlopers: For help getting this working correctly, ";
|
||||
html += "<a href='http://trac.openlayers.org/wiki/YahooLayer' "
|
||||
html += "target='_blank'>";
|
||||
html += "click here";
|
||||
html += "</a>";
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
return html;
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv("mmWarning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = html;
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by Y
|
||||
* If yahoomap is not loaded, returns null.
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if (this.yahoomap != null) {
|
||||
var pixel = this.getPixelFromOLPixel(viewPortPx);
|
||||
var mmLatLong = this.yahoomap.convertXYLatLon(pixel);
|
||||
lonlat = this.getOLLonLatFromYLatLong(mmLatLong);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY Y
|
||||
* If yahoomap is not loaded, returns null.
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if (this.yahoomap != null) {
|
||||
var mmLatLong = this.getYLatLongFromOLLonLat(lonlat);
|
||||
var pixel = this.yahoomap.convertLatLonXY(mmLatLong);
|
||||
viewPortPx = this.getOLPixelFromPixel(pixel);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom lemml for a specified Bounds.
|
||||
* If yahoomap is not loaded, returns null.
|
||||
* @type int
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var zoom = null;
|
||||
if (this.yahoomap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var mmZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var mmZoom = Math.min(Math.max(mmZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromYZoom(mmZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
@@ -111,175 +213,107 @@ OpenLayers.Layer.Yahoo.prototype =
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {int} gZoom
|
||||
* @param {int} mmZoom
|
||||
*
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
|
||||
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getOLZoomFromMapObjectZoom: function(moZoom) {
|
||||
var zoom = null;
|
||||
if (moZoom != null) {
|
||||
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
|
||||
zoom = 18 - zoom;
|
||||
}
|
||||
return zoom;
|
||||
getOLZoomFromYZoom: function(mmZoom) {
|
||||
return 18 - mmZoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns A MapObject level, translated from the passed in olZoom
|
||||
* @returns A YZoom lemml, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
|
||||
zoom = 18 - zoom;
|
||||
getYZoomFromOLZoom: function(olZoom) {
|
||||
return 18 - olZoom;
|
||||
},
|
||||
|
||||
//
|
||||
// TRANSLATION: YLatLong <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {YLatLong} mmLatLong
|
||||
*
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in YLatLong
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getOLLonLatFromYLatLong: function(mmLatLong) {
|
||||
var olLonLat = null;
|
||||
if (mmLatLong != null) {
|
||||
olLonLat = new OpenLayers.LonLat(mmLatLong.Lon,
|
||||
mmLatLong.Lat);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Interface Controls *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// Get&Set Center, Zoom
|
||||
|
||||
/** Set the mapObject to the specified center and zoom
|
||||
*
|
||||
* @param {Object} center MapObject LonLat format
|
||||
* @param {int} zoom MapObject zoom format
|
||||
*/
|
||||
setMapObjectCenter: function(center, zoom) {
|
||||
this.mapObject.drawZoomAndCenter(center, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current center in Map Object format
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectCenter: function() {
|
||||
return this.mapObject.getCenterLatLon();
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns the mapObject's current zoom, in Map Object format
|
||||
* @type int
|
||||
*/
|
||||
getMapObjectZoom: function() {
|
||||
return this.mapObject.getZoomLevel();
|
||||
},
|
||||
|
||||
|
||||
// LonLat - Pixel Translation
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject LonLat translated from MapObject Pixel
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
|
||||
return this.mapObject.convertXYLatLon(moPixel);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject Pixel translated from MapObject LonLat
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
|
||||
return this.mapObject.convertLatLonXY(moLonLat);
|
||||
},
|
||||
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Primitives *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// LonLat
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns Longitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Lon;
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns Latitude of the given MapObject LonLat
|
||||
* @type float
|
||||
* @returns A YLatLong, translated from the passed in OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type YLatLong
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Lat;
|
||||
getYLatLongFromOLLonLat: function(olLonLat) {
|
||||
var mmLatLong = null;
|
||||
if (olLonLat != null) {
|
||||
mmLatLong = new YGeoPoint(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return mmLatLong;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: Pixel <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Pixel} pixel
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromPixel: function(pixel) {
|
||||
var olPixel = null;
|
||||
if (pixel != null) {
|
||||
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} lon float
|
||||
* @param {int} lat float
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns MapObject LonLat built from lon and lat params
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new YGeoPoint(lat, lon);
|
||||
},
|
||||
|
||||
// Pixel
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
*
|
||||
* @returns X value of the MapObject Pixel
|
||||
* @type int
|
||||
*/
|
||||
getXFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.x;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
* As it turns out, the only specifications we can see for the
|
||||
* Y-compatible Pixel is an x & y property, which emmry
|
||||
* OpenLayers.Pixel has by default. So just leamm it as-is.
|
||||
*
|
||||
* @returns Y value of the MapObject Pixel
|
||||
* @type int
|
||||
* @type Pixel
|
||||
*/
|
||||
getYFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.y;
|
||||
getPixelFromOLPixel: function(olPixel) {
|
||||
var pixel = null;
|
||||
if (olPixel != null) {
|
||||
pixel = new YCoordPoint(olPixel.x, olPixel.y);
|
||||
}
|
||||
return pixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} x
|
||||
* @param {int} y
|
||||
*
|
||||
* @returns MapObject Pixel from x and y parameters
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new YCoordPoint(x, y);
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Yahoo"
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
OpenLayers.Map = OpenLayers.Class.create();
|
||||
OpenLayers.Map = Class.create();
|
||||
OpenLayers.Map.TILE_WIDTH = 256;
|
||||
OpenLayers.Map.TILE_HEIGHT = 256;
|
||||
OpenLayers.Map.prototype = {
|
||||
@@ -111,8 +111,6 @@ OpenLayers.Map.prototype = {
|
||||
/** @type int */
|
||||
numZoomLevels: 16,
|
||||
|
||||
/** @type string */
|
||||
theme: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -131,7 +129,6 @@ OpenLayers.Map.prototype = {
|
||||
"hidden");
|
||||
this.viewPortDiv.style.width = "100%";
|
||||
this.viewPortDiv.style.height = "100%";
|
||||
this.viewPortDiv.className = "olMapViewport";
|
||||
this.div.appendChild(this.viewPortDiv);
|
||||
|
||||
// the layerContainerDiv is the one that holds all the layers
|
||||
@@ -155,30 +152,18 @@ OpenLayers.Map.prototype = {
|
||||
// Else updateSize on catching the window's resize
|
||||
// Note that this is ok, as updateSize() does nothing if the
|
||||
// map's size has not actually changed.
|
||||
OpenLayers.Event.observe(window, 'resize',
|
||||
Event.observe(window, 'resize',
|
||||
this.updateSize.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
//set the default options
|
||||
this.setOptions(options);
|
||||
|
||||
var cssNode = document.createElement('link');
|
||||
cssNode.setAttribute('rel', 'stylesheet');
|
||||
cssNode.setAttribute('type', 'text/css');
|
||||
cssNode.setAttribute('href', this.theme);
|
||||
document.getElementsByTagName('head')[0].appendChild(cssNode);
|
||||
|
||||
this.layers = [];
|
||||
|
||||
if (this.controls == null) {
|
||||
if (OpenLayers.Control != null) { // running full or lite?
|
||||
this.controls = [ new OpenLayers.Control.MouseDefaults(),
|
||||
new OpenLayers.Control.PanZoom(),
|
||||
new OpenLayers.Control.ArgParser()
|
||||
];
|
||||
} else {
|
||||
this.controls = [];
|
||||
}
|
||||
this.controls = [ new OpenLayers.Control.MouseDefaults(),
|
||||
new OpenLayers.Control.PanZoom()];
|
||||
}
|
||||
|
||||
for(var i=0; i < this.controls.length; i++) {
|
||||
@@ -188,7 +173,7 @@ OpenLayers.Map.prototype = {
|
||||
this.popups = new Array();
|
||||
|
||||
// always call map.destroy()
|
||||
OpenLayers.Event.observe(window,
|
||||
Event.observe(window,
|
||||
'unload',
|
||||
this.destroy.bindAsEventListener(this));
|
||||
|
||||
@@ -226,12 +211,9 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
|
||||
this.theme = OpenLayers._getScriptLocation() +
|
||||
'theme/default/style.css';
|
||||
|
||||
// now add the options declared by the user
|
||||
// (these will override defaults)
|
||||
OpenLayers.Util.extend(this, options);
|
||||
Object.extend(this, options);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -269,23 +251,14 @@ OpenLayers.Map.prototype = {
|
||||
return foundLayer;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @param {int} zIdx
|
||||
* @private
|
||||
*/
|
||||
setLayerZIndex: function (layer, zIdx) {
|
||||
layer.setZIndex(
|
||||
this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay']
|
||||
+ zIdx * 5 );
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Layer} layer
|
||||
*/
|
||||
addLayer: function (layer) {
|
||||
layer.div.style.overflow = "";
|
||||
this.setLayerZIndex(layer, this.layers.length);
|
||||
layer.div.style.zIndex =
|
||||
this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay']
|
||||
+ this.layers.length * 5;
|
||||
|
||||
if (layer.isFixed) {
|
||||
this.viewPortDiv.appendChild(layer.div);
|
||||
@@ -295,20 +268,23 @@ OpenLayers.Map.prototype = {
|
||||
this.layers.push(layer);
|
||||
layer.setMap(this);
|
||||
|
||||
if (layer.isBaseLayer) {
|
||||
this.events.triggerEvent("addlayer");
|
||||
|
||||
//make sure layer draws itself!
|
||||
if (this.center != null) {
|
||||
var bounds = this.getExtent();
|
||||
layer.moveTo(bounds, true);
|
||||
}
|
||||
|
||||
if (layer.isBaseLayer) {
|
||||
// set the first baselaye we add as the baselayer
|
||||
if (this.baseLayer == null) {
|
||||
// set the first baselaye we add as the baselayer
|
||||
this.setBaseLayer(layer);
|
||||
this.events.triggerEvent("changebaselayer");
|
||||
} else {
|
||||
layer.setVisibility(false);
|
||||
}
|
||||
} else {
|
||||
if (this.getCenter() != null) {
|
||||
layer.moveTo(this.getExtent(), true);
|
||||
}
|
||||
}
|
||||
|
||||
this.events.triggerEvent("addlayer");
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -351,7 +327,7 @@ OpenLayers.Map.prototype = {
|
||||
this.layerContainerDiv.removeChild(layer.div);
|
||||
}
|
||||
layer.map = null;
|
||||
OpenLayers.Util.removeItem(this.layers, layer);
|
||||
this.layers.remove(layer);
|
||||
|
||||
// if we removed the base layer, need to set a new one
|
||||
if (this.baseLayer == layer) {
|
||||
@@ -366,62 +342,6 @@ OpenLayers.Map.prototype = {
|
||||
}
|
||||
this.events.triggerEvent("removelayer");
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The number of layers attached to the map.
|
||||
* @type int
|
||||
*/
|
||||
getNumLayers: function () {
|
||||
return this.layers.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The current (zero-based) index of the given layer in the map's
|
||||
* layer stack. Returns -1 if the layer isn't on the map.
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @type int
|
||||
*/
|
||||
getLayerIndex: function (layer) {
|
||||
return OpenLayers.Util.indexOf(this.layers, layer);
|
||||
},
|
||||
|
||||
/** Move the given layer to the specified (zero-based) index in the layer
|
||||
* list, changing its z-index in the map display. Use
|
||||
* map.getLayerIndex() to find out the current index of a layer. Note
|
||||
* that this cannot (or at least should not) be effectively used to
|
||||
* raise base layers above overlays.
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @param {int} idx
|
||||
*/
|
||||
setLayerIndex: function (layer, idx) {
|
||||
var base = this.getLayerIndex(layer);
|
||||
if (idx < 0)
|
||||
idx = 0;
|
||||
else if (idx > this.layers.length)
|
||||
idx = this.layers.length;
|
||||
if (base != idx) {
|
||||
this.layers.splice(base, 1);
|
||||
this.layers.splice(idx, 0, layer);
|
||||
for (var i = 0; i < this.layers.length; i++)
|
||||
this.setLayerZIndex(this.layers[i], i);
|
||||
this.events.triggerEvent("changelayer");
|
||||
}
|
||||
},
|
||||
|
||||
/** Change the index of the given layer by delta. If delta is positive,
|
||||
* the layer is moved up the map's layer stack; if delta is negative,
|
||||
* the layer is moved down. Again, note that this cannot (or at least
|
||||
* should not) be effectively used to raise base layers above overlays.
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @param {int} idx
|
||||
*/
|
||||
raiseLayer: function (layer, delta) {
|
||||
var idx = this.getLayerIndex(layer) + delta;
|
||||
this.setLayerIndex(layer, idx);
|
||||
},
|
||||
|
||||
/** Allows user to specify one of the currently-loaded layers as the Map's
|
||||
* new base layer.
|
||||
@@ -430,16 +350,16 @@ OpenLayers.Map.prototype = {
|
||||
* @param {Boolean} noEvent
|
||||
*/
|
||||
setBaseLayer: function(newBaseLayer, noEvent) {
|
||||
var oldBaseLayer = this.baseLayer;
|
||||
|
||||
if (newBaseLayer != oldBaseLayer) {
|
||||
if (newBaseLayer != this.baseLayer) {
|
||||
|
||||
// is newBaseLayer an already loaded layer?
|
||||
if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
|
||||
var foundLayer = (this.layers.indexOf(newBaseLayer) != -1);
|
||||
if (foundLayer) {
|
||||
|
||||
// make the old base layer invisible
|
||||
if (oldBaseLayer != null) {
|
||||
oldBaseLayer.setVisibility(false, noEvent);
|
||||
if (this.baseLayer != null) {
|
||||
this.baseLayer.setVisibility(false, noEvent);
|
||||
}
|
||||
|
||||
// set new baselayer and make it visible
|
||||
@@ -449,13 +369,14 @@ OpenLayers.Map.prototype = {
|
||||
//redraw all layers
|
||||
var center = this.getCenter();
|
||||
if (center != null) {
|
||||
if (oldBaseLayer == null) {
|
||||
this.setCenter(center);
|
||||
} else {
|
||||
this.zoomToExtent(oldBaseLayer.getExtent());
|
||||
}
|
||||
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");
|
||||
}
|
||||
@@ -515,11 +436,9 @@ OpenLayers.Map.prototype = {
|
||||
* @param {OpenLayers.Popup} popup
|
||||
*/
|
||||
removePopup: function(popup) {
|
||||
OpenLayers.Util.removeItem(this.popups, popup);
|
||||
this.popups.remove(popup);
|
||||
if (popup.div) {
|
||||
try { this.layerContainerDiv.removeChild(popup.div); }
|
||||
catch (e) { } // Popups sometimes apparently get disconnected
|
||||
// from the layerContainerDiv, and cause complaints.
|
||||
this.layerContainerDiv.removeChild(popup.div);
|
||||
}
|
||||
popup.map = null;
|
||||
},
|
||||
@@ -534,20 +453,10 @@ OpenLayers.Map.prototype = {
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @returns {OpenLayers.Size}
|
||||
*/
|
||||
getSize: function () {
|
||||
var size = null;
|
||||
if (this.size != null) {
|
||||
size = this.size.clone();
|
||||
}
|
||||
return size;
|
||||
return this.size;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -566,20 +475,17 @@ OpenLayers.Map.prototype = {
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -596,7 +502,7 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// Workaround for the fact that hidden elements return 0 for size.
|
||||
if (size.w == 0 && size.h == 0) {
|
||||
var dim = OpenLayers.Element.getDimensions(this.div);
|
||||
var dim = Element.getDimensions(this.div);
|
||||
size.w = dim.width;
|
||||
size.h = dim.height;
|
||||
}
|
||||
@@ -607,41 +513,6 @@ OpenLayers.Map.prototype = {
|
||||
return size;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} center Default is this.getCenter()
|
||||
* @param {float} resolution Default is this.getResolution()
|
||||
*
|
||||
* @returns A Bounds based on resolution, center, and current mapsize.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
calculateBounds: function(center, resolution) {
|
||||
|
||||
var extent = null;
|
||||
|
||||
if (center == null) {
|
||||
center = this.getCenter();
|
||||
}
|
||||
if (resolution == null) {
|
||||
resolution = this.getResolution();
|
||||
}
|
||||
|
||||
if ((center != null) && (resolution != null)) {
|
||||
|
||||
var size = this.getSize();
|
||||
var w_deg = size.w * resolution;
|
||||
var h_deg = size.h * resolution;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Zoom, Center, Pan Functions */
|
||||
@@ -690,15 +561,10 @@ OpenLayers.Map.prototype = {
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {int} zoom
|
||||
* @param {Boolean} dragging Specifies whether or not to
|
||||
* trigger movestart/end events
|
||||
* @param {Boolean} minor Specifies whether or not to
|
||||
* trigger movestart/end events
|
||||
*/
|
||||
setCenter: function (lonlat, zoom, dragging) {
|
||||
|
||||
if (!this.center && !this.isValidLonLat(lonlat)) {
|
||||
lonlat = this.maxExtent.getCenterLonLat();
|
||||
}
|
||||
|
||||
setCenter: function (lonlat, zoom, minor) {
|
||||
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
|
||||
(zoom != this.getZoom());
|
||||
|
||||
@@ -707,9 +573,9 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
|
||||
// if neither center nor zoom will change, no need to do anything
|
||||
if (zoomChanged || centerChanged || !dragging) {
|
||||
if (zoomChanged || centerChanged || !minor) {
|
||||
|
||||
if (!dragging) { this.events.triggerEvent("movestart"); }
|
||||
if (!minor) { this.events.triggerEvent("movestart"); }
|
||||
|
||||
if (centerChanged) {
|
||||
if ((!zoomChanged) && (this.center)) {
|
||||
@@ -736,33 +602,13 @@ OpenLayers.Map.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
var bounds = this.getExtent();
|
||||
|
||||
//send the move call to the baselayer and all the overlays
|
||||
this.baseLayer.moveTo(bounds, zoomChanged, dragging);
|
||||
var bounds = this.getExtent();
|
||||
for (var i = 0; i < this.layers.length; i++) {
|
||||
var layer = this.layers[i];
|
||||
if (!layer.isBaseLayer) {
|
||||
|
||||
var moveLayer;
|
||||
var inRange = layer.calculateInRange();
|
||||
if (layer.inRange != inRange) {
|
||||
// Layer property has changed. We are going
|
||||
// to call moveLayer so that the layer can be turned
|
||||
// off or on.
|
||||
layer.inRange = inRange;
|
||||
moveLayer = true;
|
||||
this.events.triggerEvent("changelayer");
|
||||
} else {
|
||||
// If nothing has changed, then we only move the layer
|
||||
// if it is visible and inrange.
|
||||
moveLayer = (layer.visibility && layer.inRange);
|
||||
}
|
||||
|
||||
if (moveLayer) {
|
||||
layer.moveTo(bounds, zoomChanged, dragging);
|
||||
}
|
||||
}
|
||||
if (layer.getVisibility()) {
|
||||
layer.moveTo(bounds, zoomChanged, minor);
|
||||
}
|
||||
}
|
||||
|
||||
this.events.triggerEvent("move");
|
||||
@@ -771,7 +617,7 @@ OpenLayers.Map.prototype = {
|
||||
}
|
||||
|
||||
// even if nothing was done, we want to notify of this
|
||||
if (!dragging) { this.events.triggerEvent("moveend"); }
|
||||
if (!minor) { this.events.triggerEvent("moveend"); }
|
||||
},
|
||||
|
||||
/** This function takes care to recenter the layerContainerDiv
|
||||
@@ -818,7 +664,7 @@ OpenLayers.Map.prototype = {
|
||||
var valid = false;
|
||||
if (lonlat != null) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
valid = maxExtent.containsLonLat(lonlat);
|
||||
valid = maxExtent.contains(lonlat.lon, lonlat.lat);
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
@@ -927,7 +773,8 @@ OpenLayers.Map.prototype = {
|
||||
if (this.baseLayer != null) {
|
||||
var res = this.getResolution();
|
||||
var units = this.baseLayer.units;
|
||||
scale = OpenLayers.Util.getScaleFromResolution(res, units);
|
||||
scale = res * OpenLayers.INCHES_PER_UNIT[units] *
|
||||
OpenLayers.DOTS_PER_INCH;
|
||||
}
|
||||
return scale;
|
||||
},
|
||||
@@ -1145,11 +992,11 @@ OpenLayers.Map.prototype = {
|
||||
var dX = -parseInt(this.layerContainerDiv.style.left);
|
||||
var dY = -parseInt(this.layerContainerDiv.style.top);
|
||||
layerPx = viewPortPx.add(dX, dY);
|
||||
if (isNaN(layerPx.x) || isNaN(layerPx.y)) {
|
||||
layerPx = null;
|
||||
}
|
||||
}
|
||||
return layerPx;
|
||||
if (!isNaN(layerPx.x) && !isNaN(layerPx.y)) {
|
||||
return layerPx;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Marker = OpenLayers.Class.create();
|
||||
OpenLayers.Marker = Class.create();
|
||||
OpenLayers.Marker.prototype = {
|
||||
|
||||
/** @type OpenLayers.Icon */
|
||||
@@ -28,18 +28,11 @@ OpenLayers.Marker.prototype = {
|
||||
* @param {OpenLayers.LonLat lonlat
|
||||
*/
|
||||
initialize: function(lonlat, icon) {
|
||||
this.lonlat = lonlat;
|
||||
|
||||
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;
|
||||
if (arguments.length > 0) {
|
||||
this.lonlat = lonlat;
|
||||
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
|
||||
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
||||
}
|
||||
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
@@ -80,7 +73,7 @@ OpenLayers.Marker.prototype = {
|
||||
var onScreen = false;
|
||||
if (this.map) {
|
||||
var screenBounds = this.map.getExtent();
|
||||
onScreen = screenBounds.containsLonLat(this.lonlat);
|
||||
onScreen = screenBounds.contains(this.lonlat.lon, this.lonlat.lat);
|
||||
}
|
||||
return onScreen;
|
||||
},
|
||||
@@ -96,15 +89,6 @@ OpenLayers.Marker.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/** Change the opacity of the marker by changin the opacity of
|
||||
* its icon
|
||||
*
|
||||
* @param {float} opacity Specified as fraction (0.4, etc)
|
||||
*/
|
||||
setOpacity: function(opacity) {
|
||||
this.icon.setOpacity(opacity);
|
||||
},
|
||||
|
||||
/** Hide or show the icon
|
||||
*
|
||||
* @param {Boolean} display
|
||||
@@ -125,7 +109,11 @@ OpenLayers.Marker.prototype = {
|
||||
OpenLayers.Marker.defaultIcon = function() {
|
||||
var url = OpenLayers.Util.getImagesLocation() + "marker.png";
|
||||
var size = new OpenLayers.Size(21, 25);
|
||||
return new OpenLayers.Icon(url, size);
|
||||
var calculateOffset = function(size) {
|
||||
return new OpenLayers.Pixel(-(size.w/2), -size.h);
|
||||
};
|
||||
|
||||
return new OpenLayers.Icon(url, size, null, calculateOffset);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
*
|
||||
* @requires OpenLayers/Marker.js
|
||||
*/
|
||||
OpenLayers.Marker.Box = OpenLayers.Class.create();
|
||||
OpenLayers.Marker.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Marker, {
|
||||
OpenLayers.Marker.Box = Class.create();
|
||||
OpenLayers.Marker.Box.prototype = Object.extend( new OpenLayers.Marker(), {
|
||||
/** @type OpenLayers.LonLat */
|
||||
bounds: null,
|
||||
|
||||
@@ -21,11 +21,12 @@ OpenLayers.Marker.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Marker, {
|
||||
* @param {OpenLayers.LonLat lonlat
|
||||
*/
|
||||
initialize: function(bounds, borderColor, borderWidth) {
|
||||
this.bounds = bounds;
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.div.style.overflow = 'hidden';
|
||||
this.events = new OpenLayers.Events(this, this.div, null);
|
||||
this.setBorder(borderColor, borderWidth);
|
||||
if (arguments.length > 0) {
|
||||
this.bounds = bounds;
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.events = new OpenLayers.Events(this, this.div, null);
|
||||
this.setBorder(borderColor, borderWidth);
|
||||
}
|
||||
},
|
||||
|
||||
setBorder: function (color, width) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Popup = OpenLayers.Class.create();
|
||||
OpenLayers.Popup = Class.create();
|
||||
|
||||
OpenLayers.Popup.WIDTH = 200;
|
||||
OpenLayers.Popup.HEIGHT = 200;
|
||||
@@ -41,13 +41,6 @@ OpenLayers.Popup.prototype = {
|
||||
|
||||
/** @type String */
|
||||
border: "",
|
||||
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
/** @type int */
|
||||
padding: 5,
|
||||
|
||||
|
||||
/** this gets set in Map.js when the popup is added to the map
|
||||
* @type OpenLayers.Map */
|
||||
@@ -60,9 +53,8 @@ OpenLayers.Popup.prototype = {
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
* @param {Boolean} closeBox
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, closeBox) {
|
||||
initialize:function(id, lonlat, size, contentHTML) {
|
||||
if (id == null) {
|
||||
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
}
|
||||
@@ -82,31 +74,6 @@ OpenLayers.Popup.prototype = {
|
||||
|
||||
this.div = OpenLayers.Util.createDiv(this.id, null, null,
|
||||
null, null, null, "hidden");
|
||||
this.div.className = 'olPopup';
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(),
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
this.contentDiv.className = 'olPopupContent';
|
||||
this.div.appendChild(this.contentDiv);
|
||||
|
||||
if (closeBox == true) {
|
||||
// close icon
|
||||
var closeSize = new OpenLayers.Size(17,17);
|
||||
var img = OpenLayers.Util.getImagesLocation() + "close.gif";
|
||||
var closeImg = OpenLayers.Util.createAlphaImageDiv(this.id + "_close",
|
||||
null,
|
||||
closeSize,
|
||||
img);
|
||||
closeImg.style.right = this.padding + "px";
|
||||
closeImg.style.top = this.padding + "px";
|
||||
this.div.appendChild(closeImg);
|
||||
|
||||
var closeEvents = new OpenLayers.Events(this, closeImg);
|
||||
closeEvents.register("mousedown", this, this.hide);
|
||||
|
||||
}
|
||||
|
||||
this.registerEvents();
|
||||
},
|
||||
@@ -170,28 +137,28 @@ OpenLayers.Popup.prototype = {
|
||||
* @type Boolean
|
||||
*/
|
||||
visible: function() {
|
||||
return OpenLayers.Element.visible(this.div);
|
||||
return Element.visible(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
toggle: function() {
|
||||
OpenLayers.Element.toggle(this.div);
|
||||
Element.toggle(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
show: function() {
|
||||
OpenLayers.Element.show(this.div);
|
||||
Element.show(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
hide: function() {
|
||||
OpenLayers.Element.hide(this.div);
|
||||
Element.hide(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -252,18 +219,17 @@ OpenLayers.Popup.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
this.contentDiv.innerHTML = this.contentHTML;
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** Do this in a separate function so that subclasses can
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Popup.js
|
||||
*/
|
||||
OpenLayers.Popup.Anchored = OpenLayers.Class.create();
|
||||
OpenLayers.Popup.Anchored = Class.create();
|
||||
OpenLayers.Popup.Anchored.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Popup, {
|
||||
Object.extend( new OpenLayers.Popup(), {
|
||||
|
||||
/** "lr", "ll", "tr", "tl" - relative position of the popup.
|
||||
* @type String */
|
||||
@@ -31,10 +31,9 @@ OpenLayers.Popup.Anchored.prototype =
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
* @param {Boolean} closeBox
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
|
||||
var newArguments = new Array(id, lonlat, size, contentHTML, closeBox);
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
var newArguments = new Array(id, lonlat, size, contentHTML);
|
||||
OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
this.anchor = (anchor != null) ? anchor
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
*
|
||||
* @requires OpenLayers/Popup/Anchored.js
|
||||
*/
|
||||
OpenLayers.Popup.AnchoredBubble = OpenLayers.Class.create();
|
||||
OpenLayers.Popup.AnchoredBubble = Class.create();
|
||||
|
||||
//Border space for the rico corners
|
||||
OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;
|
||||
|
||||
OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Popup.Anchored, {
|
||||
Object.extend( new OpenLayers.Popup.Anchored(), {
|
||||
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
rounded: false,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -28,9 +30,8 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
* @param {Boolean} closeBox
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -44,10 +45,18 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
|
||||
OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);
|
||||
|
||||
// make the content Div
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize,
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
this.div.appendChild(this.contentDiv);
|
||||
this.setContentHTML();
|
||||
|
||||
this.setRicoCorners(!this.rounded);
|
||||
this.rounded = true;
|
||||
this.setRicoCorners(true);
|
||||
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
@@ -66,13 +75,11 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
contentSize.h -= (2 * this.padding);
|
||||
|
||||
this.contentDiv.style.height = contentSize.h + "px";
|
||||
|
||||
//size has changed - must redo corners
|
||||
this.setRicoCorners(!this.rounded);
|
||||
this.rounded = true;
|
||||
this.setRicoCorners(false);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -115,6 +122,19 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
this.border = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
this.contentDiv.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
@@ -155,7 +175,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
|
||||
//we want to round all the corners _except_ the opposite one.
|
||||
var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);
|
||||
OpenLayers.Util.removeItem(corners, corner);
|
||||
corners.remove(corner);
|
||||
|
||||
return corners.join(" ");
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* size - but do not add themselves to the layer div automatically, for
|
||||
* example.
|
||||
*/
|
||||
OpenLayers.Tile = OpenLayers.Class.create();
|
||||
OpenLayers.Tile = Class.create();
|
||||
OpenLayers.Tile.prototype = {
|
||||
|
||||
/** @type String */
|
||||
@@ -46,14 +46,16 @@ OpenLayers.Tile.prototype = {
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
initialize: function(layer, position, bounds, url, size) {
|
||||
this.layer = layer;
|
||||
this.position = position;
|
||||
this.bounds = bounds;
|
||||
this.url = url;
|
||||
this.size = size;
|
||||
if (arguments.length > 0) {
|
||||
this.layer = layer;
|
||||
this.position = position;
|
||||
this.bounds = bounds;
|
||||
this.url = url;
|
||||
this.size = size;
|
||||
|
||||
//give the tile a unique id based on its BBOX.
|
||||
this.id = OpenLayers.Util.createUniqueID("Tile_");
|
||||
//give the tile a unique id based on its BBOX.
|
||||
this.id = OpenLayers.Util.createUniqueID("Tile_");
|
||||
}
|
||||
},
|
||||
|
||||
/** nullify references to prevent circular references and memory leaks
|
||||
@@ -82,7 +84,7 @@ OpenLayers.Tile.prototype = {
|
||||
redraw = true;
|
||||
}
|
||||
|
||||
OpenLayers.Util.clearArray(this);
|
||||
this.clear();
|
||||
this.bounds = bounds.clone();
|
||||
this.position = position.clone();
|
||||
if (redraw) {
|
||||
@@ -96,25 +98,6 @@ OpenLayers.Tile.prototype = {
|
||||
clear: function() {
|
||||
this.drawn = false;
|
||||
},
|
||||
|
||||
getBoundsFromBaseLayer: function(position) {
|
||||
var topLeft = this.layer.map.getLonLatFromLayerPx(this.position);
|
||||
var bottomRightPx = this.position.clone();
|
||||
bottomRightPx.x += this.size.w;
|
||||
bottomRightPx.y += this.size.h;
|
||||
var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx);
|
||||
// Handle the case where the base layer wraps around the date line.
|
||||
// Google does this, and it breaks WMS servers to request bounds in that fashion.
|
||||
if (topLeft.lon > bottomRight.lon) {
|
||||
if (topLeft.lon < 0) {
|
||||
topLeft.lon = -180 - (topLeft.lon+180);
|
||||
} else {
|
||||
bottomRight.lon = 180+bottomRight.lon+180;
|
||||
}
|
||||
}
|
||||
bounds = new OpenLayers.Bounds(topLeft.lon, bottomRight.lat, bottomRight.lon, topLeft.lat);
|
||||
return bounds;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Tile"
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Tile.js
|
||||
*/
|
||||
OpenLayers.Tile.Image = OpenLayers.Class.create();
|
||||
OpenLayers.Tile.Image = Class.create();
|
||||
OpenLayers.Tile.Image.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Tile, {
|
||||
Object.extend( new OpenLayers.Tile(), {
|
||||
|
||||
/** @type DOMElement img */
|
||||
imgDiv: null,
|
||||
@@ -26,7 +26,7 @@ OpenLayers.Tile.Image.prototype =
|
||||
initialize: function(layer, position, bounds, url, size) {
|
||||
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -47,23 +47,15 @@ OpenLayers.Tile.Image.prototype =
|
||||
if (this.imgDiv == null) {
|
||||
this.initImgDiv();
|
||||
}
|
||||
if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {
|
||||
this.bounds = this.getBoundsFromBaseLayer(this.position);
|
||||
}
|
||||
|
||||
this.url = this.layer.getURL(this.bounds);
|
||||
this.imgDiv.style.display = "none";
|
||||
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
|
||||
(this.bounds.intersectsBounds(this.layer.maxExtent,false))
|
||||
)) {
|
||||
if (this.layer.alpha) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
|
||||
null, this.position, this.size, this.url);
|
||||
} else {
|
||||
this.imgDiv.src = this.url;
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv,
|
||||
null, this.position, this.size) ;
|
||||
}
|
||||
if (this.layer.alpha) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
|
||||
null, this.position, this.size, this.url);
|
||||
} else {
|
||||
this.imgDiv.src = this.url;
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv,
|
||||
null, this.position, this.size) ;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -83,9 +75,6 @@ OpenLayers.Tile.Image.prototype =
|
||||
* @param {Boolean} redraw
|
||||
*/
|
||||
moveTo: function (bounds, position, redraw) {
|
||||
if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {
|
||||
bounds = this.getBoundsFromBaseLayer(position);
|
||||
}
|
||||
this.url = this.layer.getURL(bounds);
|
||||
OpenLayers.Tile.prototype.moveTo.apply(this, arguments);
|
||||
},
|
||||
@@ -102,7 +91,6 @@ OpenLayers.Tile.Image.prototype =
|
||||
"absolute",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true);
|
||||
} else {
|
||||
this.imgDiv = OpenLayers.Util.createImage(null,
|
||||
@@ -111,41 +99,11 @@ OpenLayers.Tile.Image.prototype =
|
||||
null,
|
||||
"absolute",
|
||||
null,
|
||||
null,
|
||||
true);
|
||||
}
|
||||
|
||||
this.imgDiv.className = 'olTileImage';
|
||||
|
||||
/* checkImgURL *should* pretty predictably get called after the
|
||||
createImage / createAlphaImageDiv onLoad handler */
|
||||
|
||||
OpenLayers.Event.observe( this.imgDiv, "load",
|
||||
this.checkImgURL.bindAsEventListener(this) );
|
||||
|
||||
this.layer.div.appendChild(this.imgDiv);
|
||||
if(this.layer.opacity != null) {
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv, null, null, null,
|
||||
null, null, null,
|
||||
this.layer.opacity);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Make sure that the image that just loaded is the one this tile is meant
|
||||
* to display, since panning/zooming might have changed the tile's URL in
|
||||
* the meantime. If the tile URL did change before the image loaded, set
|
||||
* the imgDiv display to 'none', as either (a) it will be reset to visible
|
||||
* when the new URL loads in the image, or (b) we don't want to display
|
||||
* this tile after all because its new bounds are outside our maxExtent.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
checkImgURL: function () {
|
||||
var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src;
|
||||
if (loaded != this.url) {
|
||||
this.imgDiv.style.display = "none";
|
||||
OpenLayers.Util.setOpacity(this.imgDiv, this.layer.opacity);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*
|
||||
* @requires OpenLayers/Tile.js
|
||||
*/
|
||||
OpenLayers.Tile.WFS = OpenLayers.Class.create();
|
||||
OpenLayers.Tile.WFS = Class.create();
|
||||
OpenLayers.Tile.WFS.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Tile, {
|
||||
Object.extend( new OpenLayers.Tile(), {
|
||||
|
||||
/** @type Array(OpenLayers.Feature)*/
|
||||
features: null,
|
||||
@@ -28,8 +28,11 @@ OpenLayers.Tile.WFS.prototype =
|
||||
*/
|
||||
initialize: function(layer, position, bounds, urls, size) {
|
||||
var newArguments = arguments;
|
||||
newArguments = [layer, position, bounds, null, size];
|
||||
if (arguments.length > 0) {
|
||||
newArguments = [layer, position, bounds, null, size];
|
||||
}
|
||||
OpenLayers.Tile.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
this.urls = urls;
|
||||
this.features = new Array();
|
||||
},
|
||||
@@ -57,13 +60,10 @@ OpenLayers.Tile.WFS.prototype =
|
||||
*/
|
||||
draw:function() {
|
||||
if (this.drawn) {
|
||||
OpenLayers.Util.clearArray(this);
|
||||
this.clear();
|
||||
}
|
||||
OpenLayers.Tile.prototype.draw.apply(this, arguments);
|
||||
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
|
||||
this.layer.maxExtent.intersectsBounds(this.bounds, false))) {
|
||||
this.loadFeaturesForRegion(this.requestSuccess);
|
||||
}
|
||||
this.loadFeaturesForRegion(this.requestSuccess);
|
||||
},
|
||||
|
||||
/** get the full request string from the ds and the tile params
|
||||
@@ -98,7 +98,8 @@ OpenLayers.Tile.WFS.prototype =
|
||||
doc = OpenLayers.parseXMLString(request.responseText);
|
||||
}
|
||||
|
||||
var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS(doc, "http://www.opengis.net/gml","gml", "featureMember");
|
||||
var resultFeatures = doc.getElementsByTagName("featureMember");
|
||||
|
||||
this.addResults(resultFeatures);
|
||||
},
|
||||
|
||||
|
||||
@@ -7,74 +7,6 @@
|
||||
*/
|
||||
OpenLayers.Util = new Object();
|
||||
|
||||
/* from Prototype.js */
|
||||
if ($ == null) {
|
||||
var $ = function () {
|
||||
var elements = new Array();
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = arguments[i];
|
||||
if (typeof element == 'string')
|
||||
element = document.getElementById(element);
|
||||
|
||||
if (arguments.length == 1)
|
||||
return element;
|
||||
|
||||
elements.push(element);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
|
||||
/* from Prototype.js */
|
||||
OpenLayers.Util.extend = function(destination, source) {
|
||||
for (property in source) {
|
||||
destination[property] = source[property];
|
||||
}
|
||||
return destination;
|
||||
};
|
||||
|
||||
|
||||
/** Remove an object from an array. Iterates through the array
|
||||
* to find the item, then removes it.
|
||||
*
|
||||
* @param {Object} item
|
||||
*
|
||||
* @returns A reference to the array
|
||||
* @type Array
|
||||
*/
|
||||
OpenLayers.Util.removeItem = function(array, item) {
|
||||
for(var i=0; i < array.length; i++) {
|
||||
if(array[i] == item) {
|
||||
array.splice(i,1);
|
||||
//break;more than once??
|
||||
}
|
||||
}
|
||||
return array;
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
OpenLayers.Util.clearArray = function(array) {
|
||||
array.length = 0;
|
||||
};
|
||||
|
||||
/** Seems to exist already in FF, but not in MOZ.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Object} obj
|
||||
*/
|
||||
OpenLayers.Util.indexOf = function(array, obj) {
|
||||
|
||||
for(var i=0; i < array.length; i++) {
|
||||
if (array[i] == obj) return i;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.Pixel} px
|
||||
@@ -82,10 +14,9 @@ OpenLayers.Util.indexOf = function(array, obj) {
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {String} overflow
|
||||
* @param {float} opacity Fractional value (0.0 - 1.0)
|
||||
*/
|
||||
OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
||||
border, overflow, opacity) {
|
||||
border, overflow) {
|
||||
|
||||
if (id) {
|
||||
element.id = id;
|
||||
@@ -107,10 +38,6 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
||||
if (overflow) {
|
||||
element.style.overflow = overflow;
|
||||
}
|
||||
if (opacity) {
|
||||
element.style.opacity = opacity;
|
||||
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -123,16 +50,18 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {String} overflow
|
||||
* @param {float} opacity Fractional value (0.0 - 1.0)
|
||||
*
|
||||
* @returns A DOM Div created with the specified attributes.
|
||||
* @type DOMElement
|
||||
*/
|
||||
OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
|
||||
border, overflow, opacity) {
|
||||
border, overflow) {
|
||||
|
||||
var dom = document.createElement('div');
|
||||
|
||||
//set specific properties
|
||||
dom.style.padding = "0";
|
||||
dom.style.margin = "0";
|
||||
if (imgURL) {
|
||||
dom.style.backgroundImage = 'url(' + imgURL + ')';
|
||||
}
|
||||
@@ -144,8 +73,8 @@ OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
|
||||
if (!position) {
|
||||
position = "absolute";
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(dom, id, px, sz, position,
|
||||
border, overflow, opacity);
|
||||
OpenLayers.Util.modifyDOMElement(dom, id, px, sz,
|
||||
position, border, overflow);
|
||||
|
||||
return dom;
|
||||
};
|
||||
@@ -158,21 +87,20 @@ OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {Boolean} delayDisplay
|
||||
* @param {float} opacity Fractional value (0.0 - 1.0)
|
||||
*
|
||||
* @returns A DOM Image created with the specified attributes.
|
||||
* @type DOMElement
|
||||
*/
|
||||
OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
opacity, delayDisplay) {
|
||||
OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
delayDisplay) {
|
||||
|
||||
image = document.createElement("img");
|
||||
|
||||
if(delayDisplay) {
|
||||
image.style.display = "none";
|
||||
OpenLayers.Event.observe(image, "load",
|
||||
Event.observe(image, "load",
|
||||
OpenLayers.Util.onImageLoad.bindAsEventListener(image));
|
||||
OpenLayers.Event.observe(image, "error",
|
||||
Event.observe(image, "error",
|
||||
OpenLayers.Util.onImageLoadError.bindAsEventListener(image));
|
||||
|
||||
}
|
||||
@@ -191,17 +119,13 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
if (!position) {
|
||||
position = "relative";
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(image, id, px, sz, position,
|
||||
border, null, opacity);
|
||||
OpenLayers.Util.modifyDOMElement(image, id, px, sz, position, border);
|
||||
|
||||
|
||||
return image;
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated -- Use OpenLayers.Util.modifyDOMElement() or
|
||||
* OpenLayers.Util.modifyAlphaImageDiv()
|
||||
*
|
||||
* Set the opacity of a DOM Element
|
||||
* Note that for this function to work in IE, elements must "have layout"
|
||||
* according to:
|
||||
@@ -211,8 +135,8 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
* @param {Float} opacity Opacity value (0.0 - 1.0)
|
||||
*/
|
||||
OpenLayers.Util.setOpacity = function(element, opacity) {
|
||||
OpenLayers.Util.modifyDOMElement(element, null, null, null,
|
||||
null, null, null, opacity);
|
||||
element.style.opacity = opacity;
|
||||
element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||
}
|
||||
|
||||
OpenLayers.Util.onImageLoad = function() {
|
||||
@@ -224,26 +148,14 @@ OpenLayers.Util.onImageLoadErrorColor = "pink";
|
||||
|
||||
OpenLayers.Util.onImageLoadError = function() {
|
||||
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
|
||||
this.style.display = "";
|
||||
};
|
||||
|
||||
|
||||
OpenLayers.Util.alphaHack = function() {
|
||||
var arVersion = navigator.appVersion.split("MSIE");
|
||||
var version = parseFloat(arVersion[1]);
|
||||
var filter = false;
|
||||
|
||||
// IEs4Lin dies when trying to access document.body.filters, because
|
||||
// the property is there, but requires a DLL that can't be provided. This
|
||||
// means that we need to wrap this in a try/catch so that this can
|
||||
// continue.
|
||||
|
||||
try {
|
||||
filter = document.body.filters;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
return ( filter &&
|
||||
return ( (document.body.filters) &&
|
||||
(version >= 5.5) && (version < 7) );
|
||||
}
|
||||
|
||||
@@ -256,11 +168,9 @@ OpenLayers.Util.alphaHack = function() {
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {String} sizing 'crop', 'scale', or 'image'. Default is "scale"
|
||||
* @param {float} opacity Specified as fraction (0.4, etc)
|
||||
*/
|
||||
OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
position, border, sizing,
|
||||
opacity) {
|
||||
position, border, sizing) {
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(div, id, px, sz);
|
||||
|
||||
@@ -271,25 +181,15 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(img, div.id + "_innerImage", null, sz,
|
||||
"relative", border);
|
||||
if (opacity) {
|
||||
div.style.opacity = opacity;
|
||||
div.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
|
||||
}
|
||||
|
||||
if (OpenLayers.Util.alphaHack()) {
|
||||
|
||||
if (OpenLayers.Util.alphaHack()) {
|
||||
div.style.display = "inline-block";
|
||||
if (sizing == null) {
|
||||
sizing = "scale";
|
||||
}
|
||||
|
||||
div.style.filter = "progid:DXImageTransform.Microsoft" +
|
||||
".AlphaImageLoader(src='" + img.src + "', " +
|
||||
"sizingMethod='" + sizing + "')";
|
||||
if (div.style.opacity) {
|
||||
div.style.filter += " alpha(opacity=" + div.style.opacity * 100 + ")";
|
||||
}
|
||||
|
||||
img.style.filter = "progid:DXImageTransform.Microsoft" +
|
||||
".Alpha(opacity=0)";
|
||||
}
|
||||
@@ -310,8 +210,7 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
* @type DOMElement
|
||||
*/
|
||||
OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
position, border, sizing,
|
||||
opacity, delayDisplay) {
|
||||
position, border, sizing, delayDisplay) {
|
||||
|
||||
var div = OpenLayers.Util.createDiv();
|
||||
var img = OpenLayers.Util.createImage(null, null, null, null, null, null,
|
||||
@@ -320,14 +219,14 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
|
||||
if (delayDisplay) {
|
||||
img.style.display = "none";
|
||||
OpenLayers.Event.observe(img, "load",
|
||||
Event.observe(img, "load",
|
||||
OpenLayers.Util.onImageLoad.bindAsEventListener(div));
|
||||
OpenLayers.Event.observe(img, "error",
|
||||
Event.observe(img, "error",
|
||||
OpenLayers.Util.onImageLoadError.bindAsEventListener(div));
|
||||
}
|
||||
|
||||
OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL, position,
|
||||
border, sizing, opacity);
|
||||
OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL,
|
||||
position, border, sizing);
|
||||
|
||||
return div;
|
||||
};
|
||||
@@ -351,7 +250,7 @@ OpenLayers.Util.upperCaseObject = function (object) {
|
||||
};
|
||||
|
||||
/** Takes a hashtable and copies any keys that don't exist from
|
||||
* another hashtable, by analogy with OpenLayers.Util.extend() from
|
||||
* another hashtable, by analogy with Object.extend() from
|
||||
* Prototype.js.
|
||||
*
|
||||
* @param {Object} to
|
||||
@@ -390,27 +289,10 @@ OpenLayers.Util.getParameterString = function(params) {
|
||||
* @returns The fully formatted image location string
|
||||
* @type String
|
||||
*/
|
||||
|
||||
OpenLayers.ImgPath = '';
|
||||
OpenLayers.Util.getImagesLocation = function() {
|
||||
return OpenLayers.ImgPath || (OpenLayers._getScriptLocation() + "img/");
|
||||
return OpenLayers._getScriptLocation() + "img/";
|
||||
};
|
||||
|
||||
/* Originally from Prototype */
|
||||
|
||||
OpenLayers.Util.Try = function() {
|
||||
var returnValue;
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var lambda = arguments[i];
|
||||
try {
|
||||
returnValue = lambda();
|
||||
break;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
/** These could/should be made namespace aware?
|
||||
@@ -421,7 +303,7 @@ OpenLayers.Util.Try = function() {
|
||||
* @return {Array}
|
||||
*/
|
||||
OpenLayers.Util.getNodes=function(p, tagName) {
|
||||
var nodes = OpenLayers.Util.Try(
|
||||
var nodes = Try.these(
|
||||
function () {
|
||||
return OpenLayers.Util._getNodes(p.documentElement.childNodes,
|
||||
tagName);
|
||||
@@ -485,13 +367,11 @@ OpenLayers.Util.getTagText = function (parent, item, index) {
|
||||
*/
|
||||
OpenLayers.Util.getXmlNodeValue = function(node) {
|
||||
var val = null;
|
||||
OpenLayers.Util.Try(
|
||||
Try.these(
|
||||
function() {
|
||||
val = node.text;
|
||||
if (!val)
|
||||
val = node.textContent;
|
||||
if (!val)
|
||||
val = node.firstChild.nodeValue;
|
||||
},
|
||||
function() {
|
||||
val = node.textContent;
|
||||
@@ -637,26 +517,6 @@ OpenLayers.Util.getResolutionFromScale = function (scale, units) {
|
||||
return resolution;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {float} resolution
|
||||
* @param {String} units Index into OpenLayers.INCHES_PER_UNIT hashtable.
|
||||
* Default is degrees
|
||||
*
|
||||
* @returns The corresponding scale given passed-in resolution and unit
|
||||
* parameters.
|
||||
* @type float
|
||||
*/
|
||||
OpenLayers.Util.getScaleFromResolution = function (resolution, units) {
|
||||
|
||||
if (units == null) {
|
||||
units = "degrees";
|
||||
}
|
||||
|
||||
var scale = resolution * OpenLayers.INCHES_PER_UNIT[units] *
|
||||
OpenLayers.DOTS_PER_INCH;
|
||||
return scale;
|
||||
};
|
||||
|
||||
/** Safely stop the propagation of an event *without* preventing
|
||||
* the default browser action from occurring.
|
||||
*
|
||||
@@ -668,26 +528,3 @@ OpenLayers.Util.safeStopPropagation = function(evt) {
|
||||
}
|
||||
evt.cancelBubble = true;
|
||||
};
|
||||
|
||||
OpenLayers.Util.pagePosition = function(forElement) {
|
||||
var valueT = 0, valueL = 0;
|
||||
|
||||
var element = forElement;
|
||||
do {
|
||||
valueT += element.offsetTop || 0;
|
||||
valueL += element.offsetLeft || 0;
|
||||
|
||||
// Safari fix
|
||||
if (element.offsetParent==document.body)
|
||||
if (OpenLayers.Element.getStyle(element,'position')=='absolute') break;
|
||||
|
||||
} while (element = element.offsetParent);
|
||||
|
||||
element = forElement;
|
||||
do {
|
||||
valueT -= element.scrollTop || 0;
|
||||
valueL -= element.scrollLeft || 0;
|
||||
} while (element = element.parentNode);
|
||||
|
||||
return [valueL, valueT];
|
||||
};
|
||||
|
||||
1781
lib/Prototype.js
Normal file
1781
lib/Prototype.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
Rico.Color = OpenLayers.Class.create();
|
||||
Rico.Color = Class.create();
|
||||
|
||||
Rico.Color.prototype = {
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ Rico.Corner = {
|
||||
border : false,
|
||||
compact : false
|
||||
}
|
||||
OpenLayers.Util.extend(this.options, options || {});
|
||||
Object.extend(this.options, options || {});
|
||||
|
||||
this.options.numSlices = this.options.compact ? 2 : 4;
|
||||
if ( this._isTransparent() )
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<ul id="testlist">
|
||||
<li>test_Class.html</li>
|
||||
<li>test_Pixel.html</li>
|
||||
<li>test_Size.html</li>
|
||||
<li>test_LonLat.html</li>
|
||||
@@ -12,7 +11,6 @@
|
||||
<li>test_Util.html</li>
|
||||
<li>test_Layer.html</li>
|
||||
<li>test_Layer_EventPane.html</li>
|
||||
<li>test_Layer_FixedZoomLevels.html</li>
|
||||
<li>test_Layer_HTTPRequest.html</li>
|
||||
<li>test_Layer_Grid.html</li>
|
||||
<li>test_Layer_Markers.html</li>
|
||||
@@ -20,10 +18,11 @@
|
||||
<li>test_Layer_GeoRSS.html</li>
|
||||
<li>test_Layer_KaMap.html</li>
|
||||
<li>test_Layer_WMS.html</li>
|
||||
<li>test_Layer_Google.html</li>
|
||||
<li>test_Layer_MultiMap.html</li>
|
||||
<li>test_Tile.html</li>
|
||||
<li>test_Tile_Image.html</li>
|
||||
<li>test_Control.html</li>
|
||||
<li>test_Control_OverviewMap.html</li>
|
||||
<li>test_Control_MouseToolbar.html</li>
|
||||
<li>test_Control_LayerSwitcher.html</li>
|
||||
<li>test_Control_PanZoom.html</li>
|
||||
|
||||
@@ -30,7 +30,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
html { height: 99%; }
|
||||
body { height: 98%; font: normal normal 10pt sans-serif }
|
||||
#col1 { float: left; width: 27em; margin: 0 0 0 1em; overflow: visible; }
|
||||
#col2 { position: relative; height: 98%; margin: 0 0.5em 0 28em; }
|
||||
#col2 { position: relative; height: 98%; margin: 0 0.5em 0 27em; }
|
||||
#col1_header { margin-top: 0.5em; }
|
||||
#scroller { height: 550px; overflow: auto;}
|
||||
#testtable { margin: 0 0 2em 0; width: 97%; }
|
||||
@@ -785,7 +785,7 @@ Test.AnotherWay._set_iframe_location=function( iframe, loc, outside_path_correct
|
||||
Test.AnotherWay._start_loading_page=function()
|
||||
{
|
||||
var test_page=Test.AnotherWay._g_tests_queue[0];
|
||||
test_page.loading_timeout_milliseconds=6000;
|
||||
test_page.loading_timeout_milliseconds=4000;
|
||||
test_page.timeout_id=setTimeout( Test.AnotherWay._loading_timeout, Test.AnotherWay._g_timeout_granularity );
|
||||
test_page.wait_msg=Test.AnotherWay._print_counter_result( test_page.url, "loading...", test_page.loading_timeout_milliseconds, "loading" );
|
||||
if( test_page.convention=="jsan" ) {
|
||||
|
||||
@@ -41,18 +41,9 @@
|
||||
}
|
||||
|
||||
function test_02_Bounds_toBBOX(t) {
|
||||
t.plan( 5 );
|
||||
t.plan( 1 );
|
||||
bounds = new OpenLayers.Bounds(1,2,3,4);
|
||||
t.eq( bounds.toBBOX(), "1,2,3,4", "toBBOX() returns correct value." );
|
||||
bounds = new OpenLayers.Bounds(1.00000001,2,3,4);
|
||||
t.eq( bounds.toBBOX(), "1,2,3,4", "toBBOX() rounds off small differences." );
|
||||
bounds = new OpenLayers.Bounds(1.00000001,2.5,3,4);
|
||||
t.eq( bounds.toBBOX(), "1,2.5,3,4", "toBBOX() returns correct value. for a half number" );
|
||||
bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
|
||||
t.eq( bounds.toBBOX(), "1,2.555556,3,4", "toBBOX() rounds to correct value." );
|
||||
bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
|
||||
t.eq( bounds.toBBOX(1), "1,2.6,3,4", "toBBOX() rounds to correct value with power provided." );
|
||||
bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
|
||||
}
|
||||
|
||||
function test_03_Bounds_toString(t) {
|
||||
@@ -62,19 +53,12 @@
|
||||
}
|
||||
|
||||
function test_04_Bounds_contains(t) {
|
||||
t.plan( 6 );
|
||||
t.plan( 4 );
|
||||
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(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, 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) {
|
||||
@@ -116,47 +100,7 @@
|
||||
t.eq( bounds.left, 1, "changing olBounds.left does not change bounds.left" );
|
||||
}
|
||||
|
||||
function test_08a_Bounds_intersectsBounds(t) {
|
||||
t.plan( 17 );
|
||||
|
||||
var aBounds = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
|
||||
//inside
|
||||
var bBounds = new OpenLayers.Bounds(-20, -10, 20, 10);
|
||||
var cBounds = new OpenLayers.Bounds(-181,-90,180,90);
|
||||
t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
|
||||
t.eq( aBounds.intersectsBounds(cBounds, false), true, "aBounds with cBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." );
|
||||
t.eq( cBounds.intersectsBounds(aBounds, false), true, "cBounds with aBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." );
|
||||
|
||||
//outside
|
||||
bBounds = new OpenLayers.Bounds(-181, -91, 181, 91);
|
||||
t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
|
||||
|
||||
//total intersect
|
||||
bBounds = new OpenLayers.Bounds(-185, -100, 20, 50);
|
||||
t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
|
||||
|
||||
//border intersect
|
||||
bBounds = new OpenLayers.Bounds(-360, -180, -180, -90);
|
||||
t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, false), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is false" );
|
||||
|
||||
//no intersect
|
||||
bBounds = new OpenLayers.Bounds(-360, -180, -185, -95);
|
||||
t.eq( aBounds.intersectsBounds(bBounds), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + ")" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, true), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is true" );
|
||||
t.eq( aBounds.intersectsBounds(bBounds, false), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is false" );
|
||||
|
||||
}
|
||||
|
||||
function test_08b_Bounds_containsBounds(t) {
|
||||
function test_08_Bounds_containsBounds(t) {
|
||||
t.plan( 35 );
|
||||
containerBounds = new OpenLayers.Bounds(10,10,40,40);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user