The OpenLayers server threw a disk, and clobbered another, resulting in a loss

of data up to our last backup. In the previous subversion repository, this was
r1694->r1777. I'm sorry to all those of you who might have checked out that 
code, as this will surely cause problems for you. We're currently working to
figure out what went wrong, and how to prevent it in the future.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1695 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-10-13 20:41:21 +00:00
parent 60ba893119
commit 7c2a8a0cab
38 changed files with 1477 additions and 1279 deletions

View File

@@ -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.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds Util"
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"
echo "<html>
<head>
<title>OpenLayers Class Reference Documentation</title>

View File

@@ -2,6 +2,7 @@
OpenLayers/SingleFile.js
OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/Util.js
Rico/Corner.js
[last]

View File

@@ -6,6 +6,8 @@ Sublass of Layer used for services which require initiating multiple HTTPRequest
OpenLayers.Layer.HTTPRequest(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer.
* Methods
initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/maxZoomLevels/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming.
initResolutions() -- none -- Based on the current minScale/maxScale/maxResolution/numZoomLevel/scales/resolutions parameters, initializes an array of 'zoom levels' as this.resolutions, which are then used as an index into when zooming.
getFullRequestString(newParams) -- {String} -- Returns the full request string for a combination of the defaults on this layer and the parameters passed via newParams.
* 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.

View File

@@ -20,6 +20,7 @@ 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.
@@ -31,6 +32,7 @@ of different layers.
minScale -- The scale at zoom level 0. If this is set on the map before the Layer is added to the map, it will inherit from the map.
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.

View File

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

View File

@@ -13,7 +13,9 @@
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
<!-- Localhost key -->
<!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>-->
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
@@ -34,15 +36,18 @@
{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]);
map.addLayers([wms, google, ve, yahoo, mm]);
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() );
}

View File

@@ -19,6 +19,7 @@
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'} );

View File

@@ -18,7 +18,7 @@
<!--
var lon = 5;
var lat = 40;
var zoom = 18;
var zoom = 17;
var map, layer;
function init(){
@@ -29,11 +29,24 @@
map.addLayers([satellite]);
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
layer.setVisibility(false);
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic', 'transparent':true},
{isBaseLayer: false} );
layer.setVisibility(false);
map.addLayer(layer);
var twms = new OpenLayers.Layer.WMS( "World Map",
"http://world.freemap.in/cgi-bin/mapserv?",
{map: '/www/freemap.in/world/map/factbooktrans.map', transparent:'true',
layers: 'factbook', 'format':'png'} );
map.addLayer(twms);
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), zoom);
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );

View File

@@ -40,7 +40,7 @@
var maxOpacity = 0.9;
var minOpacity = 0.1;
function changeOpacity(byOpacity) {
var newOpacity = (parseFloat($F('opacity')) + byOpacity).toFixed(1);
var newOpacity = (parseFloat($('opacity').value) + byOpacity).toFixed(1);
newOpacity = Math.min(maxOpacity,
Math.max(minOpacity, newOpacity));
$('opacity').value = newOpacity;

View File

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

View File

@@ -19,7 +19,7 @@
"http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"});
jpl_wms.setVisibility(false);
ka_wms.isBaseLayer = false;
ka_wms.addOptions({isBaseLayer: false});
map.addLayers([jpl_wms,ka_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MouseToolbar());

View File

@@ -27,6 +27,14 @@
velayer = new OpenLayers.Layer.VirtualEarth( "VE",
{ minZoomLevel: 4, maxZoomLevel: 6, 'type': VEMapStyle.Aerial});
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);

View File

@@ -90,6 +90,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"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",

View File

@@ -63,6 +63,7 @@ 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();

View File

@@ -179,11 +179,7 @@ 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);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.zoomToExtent(bounds);
} else {
var end = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(new OpenLayers.LonLat(

View File

@@ -191,7 +191,11 @@ OpenLayers.Layer.prototype = {
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
this.display(this.visibility && this.inRange);
var display = this.visibility;
if (!this.isBaseLayer) {
display = display && this.inRange;
}
this.display(display);
},
/** Set the map property for the layer. This is done through an accessor
@@ -206,10 +210,17 @@ 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();
this.inRange = this.calculateInRange();
if (!this.isBaseLayer) {
this.inRange = this.calculateInRange();
}
},
/**
@@ -406,8 +417,6 @@ OpenLayers.Layer.prototype = {
// this way cloned layers reset themselves to new map div
// dimensions)
//
this.projection = confProps.projection;
this.units = confProps.units;
this.resolutions = confProps.resolutions;
this.maxResolution = confProps.resolutions[0];
@@ -423,9 +432,6 @@ OpenLayers.Layer.prototype = {
this.minScale = this.scales[0];
this.maxScale = this.scales[this.scales.length - 1];
this.minExtent = confProps.minExtent;
this.maxExtent = confProps.maxExtent;
this.numZoomLevels = confProps.numZoomLevels;
},

View File

@@ -25,6 +25,15 @@ 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
*
@@ -34,10 +43,19 @@ 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.pane = OpenLayers.Util.createDiv(this.div.id + "_EventPane");
}
},
/**
*
*/
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.
@@ -60,8 +78,52 @@ 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
*/
@@ -70,11 +132,181 @@ OpenLayers.Layer.EventPane.prototype =
this.pane.style.display = this.div.style.display;
},
setZIndex: function (zIdx) {
/**
* @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"
});

View File

@@ -67,9 +67,46 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
// do want to put some functionality or state in here.
},
/**
*
*/
initResolutions: function() {
// resolutions are set automatically in the black-box. this is the
// definition of a fixed-zoom-levels layer
var props = new Array('minZoomLevel', 'maxZoomLevel', 'numZoomLevels');
for(var i=0; i < props.length; i++) {
var property = props[i];
this[property] = (this.options[property] != null)
? this.options[property]
: this.map[property];
}
if ( (this.minZoomLevel == null) ||
(this.minZoomLevel < this.MIN_ZOOM_LEVEL) ){
this.minZoomLevel = this.MIN_ZOOM_LEVEL;
}
var limitZoomLevels = this.MAX_ZOOM_LEVEL - this.minZoomLevel + 1;
if (this.numZoomLevels != null) {
this.numZoomLevels = Math.min(this.numZoomLevels, limitZoomLevels);
} else {
if (this.maxZoomLevel != null) {
var zoomDiff = this.maxZoomLevel - this.minZoomLevel + 1;
this.numZoomLevels = Math.min(zoomDiff, limitZoomLevels);
} else {
this.numZoomLevels = limitZoomLevels;
}
}
this.maxZoomLevel = this.minZoomLevel + this.numZoomLevels - 1;
if (this.RESOLUTIONS != null) {
var resolutionsIndex = 0;
this.resolutions = [];
for(var i= this.minZoomLevel; i < this.numZoomLevels; i++) {
this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];
}
}
},
/**
@@ -77,16 +114,21 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
* @type float
*/
getResolution: function() {
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 );
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;
}
return resolution;
},
/** Calculates using px-> lonlat translation functions on tl and br
@@ -127,12 +169,64 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
*/
getZoomForResolution: function(resolution) {
var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
[resolution]);
return this.getZoomForExtent(extent);
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);
}
},
/********************************************************/
/* */
/* 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"
};

View File

@@ -51,8 +51,33 @@ OpenLayers.Layer.GeoRSS.prototype =
if (!doc || ajaxRequest.fileType!="XML") {
doc = OpenLayers.parseXMLString(ajaxRequest.responseText);
}
this.name = doc.getElementsByTagName("title")[0].firstChild.nodeValue;
var itemlist = doc.getElementsByTagName('item');
this.name = null;
try {
this.name = doc.getElementsByTagNameNS('*', 'title')[0].firstChild.nodeValue;
}
catch (e) {
this.name = doc.getElementsByTagName('title')[0].firstChild.nodeValue;
}
/* Try RSS items first, then Atom entries */
var itemlist = null;
try {
itemlist = doc.getElementsByTagNameNS('*', 'item');
}
catch (e) {
itemlist = doc.getElementsByTagName('item');
}
if (itemlist.length == 0) {
try {
itemlist = doc.getElementsByTagNameNS('*', 'entry');
}
catch(e) {
itemlist = doc.getElementsByTagName('entry');
}
}
for (var i = 0; i < itemlist.length; i++) {
var data = {};
var point = OpenLayers.Util.getNodes(itemlist[i], 'georss:point');
@@ -72,44 +97,52 @@ OpenLayers.Layer.GeoRSS.prototype =
location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0]));
/* Provide defaults for title and description */
var title = "No title";
var title = "Untitled";
try {
title = OpenLayers.Util.getNodes(itemlist[i],
"title")[0].firstChild.nodeValue;
}
catch (e) { alert(e); }
var description = "No description";
catch (e) { title="Untitled"; }
/* First try RSS descriptions, then Atom summaries */
var descr_nodes = null;
try {
description = OpenLayers.Util.getNodes(itemlist[i],
"description")[0].firstChild.nodeValue;
descr_nodes = itemlist[i].getElementsByTagNameNS("*",
"description");
}
catch (e) { alert(e); }
catch (e) {
descr_nodes = itemlist[i].getElementsByTagName("description");
}
if (descr_nodes.length == 0) {
try {
descr_nodes = itemlist[i].getElementsByTagNameNS("*",
"summary");
}
catch (e) {
descr_nodes = itemlist[i].getElementsByTagName("summary");
}
}
var description = "No description.";
try {
description = descr_nodes[0].firstChild.nodeValue;
}
catch (e) { description="No description."; }
try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }
data.icon = OpenLayers.Marker.defaultIcon();
data.popupSize = new OpenLayers.Size(250, 100);
data.popupSize = new OpenLayers.Size(250, 120);
if ((title != null) && (description != null)) {
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 = '<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 += description;
contentHTML += "</span>";
contentHTML += "</div>"
data['popupContentHTML'] = contentHTML;
//data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
contentHTML += '</div>';
data['popupContentHTML'] = contentHTML;
}
var feature = new OpenLayers.Feature(this, location, data);
this.features.push(feature);

View File

@@ -2,37 +2,32 @@
* 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.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type Boolean */
isFixed: true,
/** @final @type int */
MIN_ZOOM_LEVEL: 0,
/** @final @type int */
MAX_ZOOM_LEVEL: 17,
/** @type GMap2 gmap stores the Google Map element */
gmap:null,
/** 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 GMapType */
type: null,
// OPTIONS
/** @type int */
minZoomLevel: 0,
/** @type int */
maxZoomLevel: 16,
/**
* @constructor
*
@@ -42,85 +37,20 @@ OpenLayers.Layer.Google.prototype =
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if (this.maxExtent == null) {
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
}
this.addContainerPxFunction();
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
this.addContainerPxFunction();
},
/**
*
*/
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} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
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
*
*/
loadGMap:function() {
loadMapObject:function() {
//has gmaps library has been loaded?
try {
// create GMap, hide nav controls
this.gmap = new GMap2( this.div );
this.gmap.disableDragging();
this.mapObject = new GMap2( this.div );
// move the ToS and branding stuff up to the pane
// thanks a *mil* Erik for thinking of this
@@ -138,119 +68,45 @@ OpenLayers.Layer.Google.prototype =
termsOfUse.style.right = "";
termsOfUse.style.bottom = "";
// this causes the GMap to set itself to Map's center/zoom
this.moveTo();
} catch (e) {
this.loadWarningMessage();
// do not crash
}
},
/** Overridden from EventPane because if a map type has been specified,
* we need to attach a listener for the first moveend -- this is how
* we will know that the map has been centered. Only once the map has
* been centered is it safe to change the gmap object's map type.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
if (this.type != null) {
this.map.events.register("moveend", this, this.setMapType);
}
},
/** The map has been centered, and a map type was specified, so we
* set the map type on the gmap object, then unregister the listener
* so that we dont keep doing this every time the map moves.
*
* @private
*/
setMapType: function() {
if (this.mapObject.getCenter() != null) {
this.mapObject.setMapType(this.type);
this.map.events.unregister("moveend", this, this.setMapType);
}
},
/**
* @param {Event} evt
*/
onMapResize: function() {
this.gmap.checkResize();
},
/** If we can't load the GMap, then display an error message to the
* user and tell them where to go for help.
*
* @private
*
*/
loadWarningMessage:function() {
this.div.style.backgroundColor = "darkblue";
var html = "";
html += "The Google Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the Google Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Google Maps library";
html += " script was either not included, or does not contain the";
html += " correct API key for your site.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/GoogleMapsLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
var viewSize = this.map.getSize();
msgW = Math.min(viewSize.w, 300);
msgH = Math.min(viewSize.h, 200);
var size = new OpenLayers.Size(msgW, msgH);
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
var topLeft = centerPx.add(-size.w/2, -size.h/2);
var div = OpenLayers.Util.createDiv("gmapsWarning",
topLeft,
size,
null,
null,
null,
"auto");
div.style.padding = "7px";
div.style.backgroundColor = "yellow";
div.innerHTML = html;
this.div.appendChild(div);
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gPoint = this.getGPointFromOLPixel(viewPortPx);
var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint)
lonlat = this.getOLLonLatFromGLatLng(gLatLng);
}
return lonlat;
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY GMAPS
* If gmap is not loaded or not centered, returns null
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var viewPortPx = null;
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
// note we use special hacked function here
var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng);
viewPortPx = this.getOLPixelFromGPoint(gPoint);
}
return viewPortPx;
this.mapObject.checkResize();
},
@@ -258,152 +114,43 @@ OpenLayers.Layer.Google.prototype =
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom level for a specified Bounds.
* If gmap is not loaded or not centered, returns null
* If mapObject is not loaded or not centered, returns null
* @type int
*/
*
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);
if (this.mapObject != null) {
var moBounds = this.getMapObjectBoundsFromOLBounds(bounds);
var moZoom = this.getMapObjectZoomFromMapObjectBounds(moBounds);
//make sure zoom is within bounds
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
var moZoom = Math.min(Math.max(moZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromGZoom(gZoom);
zoom = this.getOLZoomFromMapObjectZoom(moZoom);
}
return zoom;
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
/**
* @param {int} gZoom
*
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromGZoom: function(gZoom) {
var zoom = null;
if (gZoom != null) {
zoom = gZoom - this.minZoomLevel;
}
return zoom;
},
*/
/**
* @param {int} olZoom
*
* @returns A GZoom level, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getGZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
}
return zoom;
},
//
// TRANSLATION: GLatLng <-> LonLat
// TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds
//
/**
* @param {GLatLng} gLatLng
* @param {Object} moBounds
*
* @returns An OpenLayers.LonLat, translated from the passed in GLatLng
* Returns 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 An OpenLayers.Bounds, translated from the passed-in
* MapObject Bounds
* Returns null if null value is passed in
* @type OpenLayers.Bounds
*/
getOLBoundsFromGLatLngBounds: function(gLatLngBounds) {
getOLBoundsFromMapObjectBounds: function(moBounds) {
var olBounds = null;
if (gLatLngBounds != null) {
var sw = gLatLngBounds.getSouthWest();
var ne = gLatLngBounds.getNorthEast();
if (moBounds != null) {
var sw = moBounds.getSouthWest();
var ne = moBounds.getNorthEast();
olBounds = new OpenLayers.Bounds(sw.lng(),
sw.lat(),
ne.lng(),
@@ -415,47 +162,222 @@ OpenLayers.Layer.Google.prototype =
/**
* @param {OpenLayers.Bounds} olBounds
*
* @returns A GLatLngBounds, translated from olBounds
* @returns A MapObject Bounds, translated from olBounds
* Returns null if null value is passed in
* @type GLatLngBounds
* @type Object
*/
getGLatLngBoundsFromOLBounds: function(olBounds) {
var gLatLngBounds = null;
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);
gLatLngBounds = new GLatLngBounds(sw, ne);
moBounds = new GLatLngBounds(sw, ne);
}
return gLatLngBounds;
return moBounds;
},
/** Hack-on function because GMAPS does not give it to us
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
addContainerPxFunction: function() {
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
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) {
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;
};
}
// 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() {
var html = "";
html += "The Google Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, select a new BaseLayer "
html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Google Maps library";
html += " script was either not included, or does not contain the";
html += " correct API key for your site.<br>";
html += "<br>";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/GoogleMapsLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
return html;
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
*
* @param {Object} center MapObject LonLat format
* @param {int} zoom MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.setCenter(center, zoom);
},
/**
* @returns the mapObject's current center in Map Object format
* @type Object
*/
getMapObjectCenter: function() {
return this.mapObject.getCenter();
},
/**
* @returns the mapObject's current zoom, in Map Object format
* @type int
*/
getMapObjectZoom: function() {
return this.mapObject.getZoom();
},
// LonLat - Pixel Translation
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject LonLat translated from MapObject Pixel
* @type Object
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
return this.mapObject.fromContainerPixelToLatLng(moPixel);
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns MapObject Pixel translated from MapObject LonLat
* @type Object
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.fromLatLngToContainerPixel(moLonLat);
},
// Bounds
/**
* @param {Object} moBounds MapObject Bounds format
*
* @returns MapObject Zoom for specified MapObject Bounds
* @type Object
*/
getMapObjectZoomFromMapObjectBounds: function(moBounds) {
return this.mapObject.getBoundsZoomLevel(moBounds);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Longitude of the given MapObject LonLat
* @type float
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lng();
},
/**
* @param {Object} moLonLat MapObject LonLat format
*
* @returns Latitude of the given MapObject LonLat
* @type float
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.lat();
},
/**
* @param {int} lon float
* @param {int} lat float
*
* @returns MapObject LonLat built from lon and lat params
* @type Object
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
return new GLatLng(lat, lon);
},
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns Y value of the MapObject Pixel
* @type int
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {int} x
* @param {int} y
*
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getMapObjectPixelFromXY: function(x, y) {
return new GPoint(x, y);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google"
});

View File

@@ -17,6 +17,15 @@ 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

View File

@@ -3,104 +3,63 @@
* 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, {
/** @type MMMap */
multimap: null,
OpenLayers.Layer.MultiMap.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type int */
minZoomLevel: 1,
/** @type int */
maxZoomLevel: 17,
/** @final @type int */
MIN_ZOOM_LEVEL: 1,
/**
/** @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) {
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.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 the multimap
this.loadMMMap();
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
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();
}
loadMapObject:function() {
try { //crash proofing
this.mapObject = new MultimapViewer(this.div);
} catch (e) { }
},
/** If we can't load the multimap, then display an error message to the
* user and tell them where to go for help.
*
* @private
*
/**
* @return String with information on why layer is broken, how to get
* it working.
* @type String
*/
loadWarningMessage:function() {
this.div.style.backgroundColor = "darkblue";
getWarningHTML:function() {
var html = "";
html += "The MM Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the MM Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "To get rid of this message, select a new BaseLayer "
html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the MM library";
html += " script was either not correctly included.<br>";
@@ -110,230 +69,146 @@ 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);
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);
return html;
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by MM
* If multimap is not loaded, returns null.
* @type OpenLayers.LonLat
/************************************
* *
* 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
*/
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;
setMapObjectCenter: function(center, zoom) {
this.mapObject.goToPosition(center, zoom);
},
/**
* @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
* @returns the mapObject's current center in Map Object format
* @type Object
*/
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;
getMapObjectCenter: function() {
return this.mapObject.getCurrentPosition();
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom lemml for a specified Bounds.
* If multimap is not loaded, returns null.
/**
* @returns the mapObject's current zoom, in Map Object format
* @type int
*/
getZoomForExtent: function (bounds) {
var zoom = null;
if (this.multimap != null) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var mmZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
//make sure zoom is within bounds
var mmZoom = Math.min(Math.max(mmZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromMMZoom(mmZoom);
}
return zoom;
getMapObjectZoom: function() {
return this.mapObject.getZoomFactor();
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
// LonLat - Pixel Translation
/**
* @param {int} mmZoom
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
* Returns null if null value is passed in
* @type int
* @returns MapObject LonLat translated from MapObject Pixel
* @type Object
*/
getOLZoomFromMMZoom: function(mmZoom) {
if (mmZoom) return mmZoom - 1;
return null;
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 {int} olZoom
* @param {Object} moLonLat MapObject LonLat format
*
* @returns A MMZoom lemml, translated from the passed in olZoom
* Returns null if null value is passed in
* @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
* @type int
*/
getMMZoomFromOLZoom: function(olZoom) {
if (olZoom) return olZoom + 1;
return null;
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
//
// TRANSLATION: MMLatLong <-> LonLat
//
/**
* @param {MMLatLong} mmLatLong
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns An OpenLayers.LonLat, translated from the passed in MMLatLong
* Returns null if null value is passed in
* @type OpenLayers.LonLat
* @returns Y value of the MapObject Pixel
* @type int
*/
getOLLonLatFromMMLatLong: function(mmLatLong) {
var olLonLat = null;
if (mmLatLong != null) {
olLonLat = new OpenLayers.LonLat(mmLatLong.lon,
mmLatLong.lat);
}
return olLonLat;
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {OpenLayers.LonLat} olLonLat
/**
* @param {int} x
* @param {int} y
*
* @returns A MMLatLong, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type MMLatLong
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getMMLatLongFromOLLonLat: function(olLonLat) {
var mmLatLong = null;
if (olLonLat != null) {
mmLatLong = new MMLatLon(olLonLat.lat, olLonLat.lon);
}
return mmLatLong;
getMapObjectPixelFromXY: function(x, y) {
return new MMPoint(x, y);
},
//
// TRANSLATION: Pixel <-> OpenLayers.Pixel
//
/**
* @param {Pixel} pixel
*
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
* Returns null if null value is passed in
* @type OpenLayers.Pixel
*/
getOLPixelFromPixel: function(pixel) {
var olPixel = null;
if (pixel != null) {
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
* Returns null if null value is passed in
*
* As it turns out, the only specifications we can see for the
* MM-compatible Pixel is an x & y property, which emmry
* OpenLayers.Pixel has by default. So just leamm it as-is.
*
* @type Pixel
*/
getPixelFromOLPixel: function(olPixel) {
var pixel = null;
if (olPixel != null) {
pixel = new MMPoint(olPixel.x, olPixel.y);
}
return pixel;
},
destroy: function() {
this.multimap = null;
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.MultiMap"
});

View File

@@ -3,82 +3,46 @@
* 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.Layer.VirtualEarth.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type VEMap */
vemap: null,
/** @type int */
minZoomLevel: 1,
/** @final @type int */
MIN_ZOOM_LEVEL: 1,
/** @final @type int */
MAX_ZOOM_LEVEL: 17,
/** @type int */
maxZoomLevel: 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) {
initialize: function(name, options) {
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} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
if (this.vemap != null) {
if (this.type != null) {
this.vemap.SetMapStyle(this.type);
this.type = null;
}
var olCenter = this.map.getCenter();
var veCenter = this.getVELatLongFromOLLonLat(olCenter);
if (zoomChanged) {
var olZoom = this.map.getZoom();
var veZoom = this.getVEZoomFromOLZoom(olZoom);
this.vemap.SetCenterAndZoom(veCenter, veZoom);
} else {
this.vemap.PanToLatLong(veCenter);
}
}
},
/**
*
*/
loadVEMap:function() {
loadMapObject:function() {
// create div and set to same size as map
var veDiv = OpenLayers.Util.createDiv(this.name);
@@ -87,47 +51,30 @@ OpenLayers.Layer.VirtualEarth.prototype =
veDiv.style.height = sz.h;
this.div.appendChild(veDiv);
try {
try { // crash prevention
this.mapObject = new VEMap(this.name);
} catch (e) { }
// 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.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();
}
if (this.vemap == null) {
this.loadWarningMessage();
} else {
try {
this.vemap.LoadMap();
} catch (e) {
// this is to catch a Mozilla bug without falling apart
}
this.vemap.HideDashboard();
}
},
/** If we can't load the vemap, then display an error message to the
* user and tell them where to go for help.
*
* @private
*
/**
* @return String with information on why layer is broken, how to get
* it working.
* @type String
*/
loadWarningMessage:function() {
this.div.style.backgroundColor = "darkblue";
getWarningHTML:function() {
var html = "";
html += "The VE Layer was unable to load correctly.<br>";
html += "<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 += "To get rid of this message, select a new BaseLayer "
html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the VE library";
html += " script was either not correctly included.<br>";
@@ -137,229 +84,144 @@ 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);
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);
return html;
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/**
* @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
/************************************
* *
* 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
*/
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;
setMapObjectCenter: function(center, zoom) {
this.mapObject.SetCenterAndZoom(center, zoom);
},
/**
* @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
* @returns the mapObject's current center in Map Object format
* @type Object
*/
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;
getMapObjectCenter: function() {
return this.mapObject.GetCenter();
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @returns Corresponding zoom level for a specified Bounds.
* If vemap is not loaded, returns null.
/**
* @returns the mapObject's current zoom, in Map Object format
* @type int
*/
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;
getMapObjectZoom: function() {
return this.mapObject.GetZoomLevel();
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
// LonLat - Pixel Translation
/**
* @param {int} veZoom
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns An OpenLayers Zoom level, translated from the passed in veZoom
* Returns null if null value is passed in
* @type int
* @returns MapObject LonLat translated from MapObject Pixel
* @type Object
*/
getOLZoomFromVEZoom: function(veZoom) {
var zoom = null;
if (veZoom != null) {
zoom = veZoom - this.minZoomLevel;
}
return zoom;
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 {int} olZoom
* @param {Object} moLonLat MapObject LonLat format
*
* @returns A VEZoom level, translated from the passed in olZoom
* Returns null if null value is passed in
* @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
* @type int
*/
getVEZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
}
return zoom;
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
//
// TRANSLATION: VELatLong <-> LonLat
//
/**
* @param {VELatLong} veLatLong
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns An OpenLayers.LonLat, translated from the passed in VELatLong
* Returns null if null value is passed in
* @type OpenLayers.LonLat
* @returns Y value of the MapObject Pixel
* @type int
*/
getOLLonLatFromVELatLong: function(veLatLong) {
var olLonLat = null;
if (veLatLong != null) {
olLonLat = new OpenLayers.LonLat(veLatLong.Longitude,
veLatLong.Latitude);
}
return olLonLat;
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {OpenLayers.LonLat} olLonLat
/**
* @param {int} x
* @param {int} y
*
* @returns A VELatLong, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type VELatLong
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getVELatLongFromOLLonLat: function(olLonLat) {
var veLatLong = null;
if (olLonLat != null) {
veLatLong = new VELatLong(olLonLat.lat, olLonLat.lon);
}
return veLatLong;
getMapObjectPixelFromXY: function(x, y) {
return new Msn.VE.Pixel(x, y);
},
//
// 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"
});

View File

@@ -20,6 +20,8 @@ OpenLayers.Layer.WMS.prototype =
exceptions: "application/vnd.ogc.se_inimage",
format: "image/jpeg"
},
reproject: true,
/**
* @constructor
@@ -42,7 +44,7 @@ OpenLayers.Layer.WMS.prototype =
// unless explicitly set in options, if the layer is transparent,
// it will be an overlay
if ((options == null) || !(options.isBaseLayer)) {
if (options == null || options.isBaseLayer == null) {
this.isBaseLayer = ((this.params.TRANSPARENT != "true") &&
(this.params.TRANSPARENT != true));
}

View File

@@ -21,6 +21,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
exceptions: "application/vnd.ogc.se_inimage",
format: "image/jpeg"
},
reproject: true,
/** @type OpenLayers.Tile.Image */
tile: null,

View File

@@ -3,208 +3,105 @@
* 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, {
/** @type YMap */
yahoomap: null,
OpenLayers.Layer.Yahoo.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/** @type int */
minZoomLevel: 0,
/** @type int */
maxZoomLevel: 15,
/** @final @type int */
MIN_ZOOM_LEVEL: 0,
/**
/** @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) {
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.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 the yahoomap
this.loadYMap();
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
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);
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);
if (this.yahoomap == null) {
this.loadWarningMessage();
}
this.map.events.register("moveend", this, this.fixYahooEventPane);
},
/** If we can't load the yahoomap, then display an error message to the
* user and tell them where to go for help.
/** 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
*
*/
loadWarningMessage:function() {
fixYahooEventPane: function() {
var yahooEventPane = $("ygddfdiv");
if (yahooEventPane != null) {
if (yahooEventPane.parentNode != null)
yahooEventPane.parentNode.removeChild(yahooEventPane);
this.div.style.backgroundColor = "darkblue";
this.map.events.unregister("moveend", this,
this.fixYahooEventPane);
}
},
/**
* @return String with information on why layer is broken, how to get
* it working.
* @type String
*/
getWarningHTML:function() {
var html = "";
html += "The Y Layer was unable to load correctly.<br>";
html += "The Yahoo Layer was unable to load correctly.<br>";
html += "<br>";
html += "To get rid of this message, click on the Y Layer's "
html += "tab in the layer switcher in the upper-right corner.<br>";
html += "To get rid of this message, select a new BaseLayer "
html += "in the layer switcher in the upper-right corner.<br>";
html += "<br>";
html += "Most likely, this is because the Y library";
html += "Most likely, this is because the Yahoo library";
html += " script was either not correctly included.<br>";
html += "<br>";
html += "Demmlopers: For help getting this working correctly, ";
html += "Developers: For help getting this working correctly, ";
html += "<a href='http://trac.openlayers.org/wiki/YahooLayer' "
html += "target='_blank'>";
html += "click here";
html += "</a>";
var viewSize = this.map.getSize();
msgW = Math.min(viewSize.w, 300);
msgH = Math.min(viewSize.h, 200);
var size = new OpenLayers.Size(msgW, msgH);
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
var topLeft = centerPx.add(-size.w/2, -size.h/2);
var div = OpenLayers.Util.createDiv("mmWarning",
topLeft,
size,
null,
null,
null,
"auto");
div.style.padding = "7px";
div.style.backgroundColor = "yellow";
div.innerHTML = html;
this.div.appendChild(div);
return html;
},
/********************************************************/
/* */
/* 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 */
@@ -214,107 +111,175 @@ OpenLayers.Layer.Yahoo.prototype =
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
//
/**
* @param {int} mmZoom
* @param {int} gZoom
*
* @returns An OpenLayers Zoom lemml, translated from the passed in mmZoom
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in
* @type int
*/
getOLZoomFromYZoom: function(mmZoom) {
return 18 - mmZoom;
getOLZoomFromMapObjectZoom: function(moZoom) {
var zoom = null;
if (moZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
zoom = 18 - zoom;
}
return zoom;
},
/**
* @param {int} olZoom
*
* @returns A YZoom lemml, translated from the passed in olZoom
* @returns A MapObject level, translated from the passed in olZoom
* Returns null if null value is passed in
* @type int
*/
getYZoomFromOLZoom: function(olZoom) {
return 18 - olZoom;
getMapObjectZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
zoom = 18 - zoom;
}
return zoom;
},
//
// TRANSLATION: YLatLong <-> LonLat
//
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
/**
* @param {YLatLong} mmLatLong
// Get&Set Center, Zoom
/** Set the mapObject to the specified center and zoom
*
* @returns An OpenLayers.LonLat, translated from the passed in YLatLong
* Returns null if null value is passed in
* @type OpenLayers.LonLat
* @param {Object} center MapObject LonLat format
* @param {int} zoom MapObject zoom format
*/
getOLLonLatFromYLatLong: function(mmLatLong) {
var olLonLat = null;
if (mmLatLong != null) {
olLonLat = new OpenLayers.LonLat(mmLatLong.Lon,
mmLatLong.Lat);
}
return olLonLat;
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;
},
/**
* @param {OpenLayers.LonLat} olLonLat
* @param {Object} moLonLat MapObject LonLat format
*
* @returns A YLatLong, translated from the passed in OpenLayers.LonLat
* Returns null if null value is passed in
* @type YLatLong
* @returns Latitude of the given MapObject LonLat
* @type float
*/
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;
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return moLonLat.Lat;
},
/**
* @param {OpenLayers.Pixel} olPixel
* @param {int} lon float
* @param {int} lat float
*
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
* Returns null if null value is passed in
*
* As it turns out, the only specifications we can see for the
* Y-compatible Pixel is an x & y property, which emmry
* OpenLayers.Pixel has by default. So just leamm it as-is.
*
* @type Pixel
* @returns MapObject LonLat built from lon and lat params
* @type Object
*/
getPixelFromOLPixel: function(olPixel) {
var pixel = null;
if (olPixel != null) {
pixel = new YCoordPoint(olPixel.x, olPixel.y);
}
return pixel;
getMapObjectLonLatFromLonLat: function(lon, lat) {
return new YGeoPoint(lat, lon);
},
// Pixel
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns X value of the MapObject Pixel
* @type int
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* @param {Object} moPixel MapObject Pixel format
*
* @returns Y value of the MapObject Pixel
* @type int
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* @param {int} x
* @param {int} y
*
* @returns MapObject Pixel from x and y parameters
* @type Object
*/
getMapObjectPixelFromXY: function(x, y) {
return new YCoordPoint(x, y);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Yahoo"
});

View File

@@ -131,6 +131,7 @@ 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
@@ -298,14 +299,12 @@ OpenLayers.Map.prototype = {
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 {
var extent = this.getExtent();
if (extent) {
layer.moveTo(extent, true);
if (this.getCenter() != null) {
layer.moveTo(this.getExtent(), true);
}
}
@@ -450,13 +449,13 @@ OpenLayers.Map.prototype = {
//redraw all layers
var center = this.getCenter();
if (center != null) {
var zoom = null;
if (oldBaseLayer != null) {
var oldResolution = oldBaseLayer.getResolution();
zoom = this.baseLayer.getZoomForResolution(oldResolution);
if (oldBaseLayer == null) {
this.setCenter(center);
} else {
this.zoomToExtent(oldBaseLayer.getExtent());
}
this.setCenter(center, zoom);
}
if ((noEvent == null) || (noEvent == false)) {
this.events.triggerEvent("changebaselayer");
}
@@ -702,21 +701,33 @@ OpenLayers.Map.prototype = {
}
}
//send the move call to the baselayer and all the overlays
var bounds = this.getExtent();
//send the move call to the baselayer and all the overlays
this.baseLayer.moveTo(bounds, zoomChanged, dragging);
for (var i = 0; i < this.layers.length; i++) {
var layer = this.layers[i];
var inRange = layer.calculateInRange();
if (layer.inRange != inRange) {
layer.inRange = inRange;
layer.display(layer.visibility && layer.inRange);
this.events.triggerEvent("changelayer");
}
if (layer.visibility && layer.inRange) {
layer.moveTo(bounds, zoomChanged, dragging);
}
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);
}
}
}
this.events.triggerEvent("move");

View File

@@ -41,6 +41,13 @@ 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 */
@@ -74,6 +81,14 @@ 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);
this.registerEvents();
},
@@ -219,17 +234,18 @@ OpenLayers.Popup.prototype = {
},
/**
* @param {String} contentHTML
*/
* @param {String} contentHTML
*/
setContentHTML:function(contentHTML) {
if (contentHTML != null) {
this.contentHTML = contentHTML;
}
if (this.div != null) {
this.div.innerHTML = this.contentHTML;
if (this.contentDiv != null) {
this.contentDiv.innerHTML = this.contentHTML;
}
},
/** Do this in a separate function so that subclasses can

View File

@@ -15,9 +15,7 @@ OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;
OpenLayers.Popup.AnchoredBubble.prototype =
OpenLayers.Class.inherit( OpenLayers.Popup.Anchored, {
/** @type DOMElement */
contentDiv:null,
rounded: false,
/**
* @constructor
@@ -45,18 +43,10 @@ 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(true);
this.setRicoCorners(!this.rounded);
this.rounded = true;
//set the popup color and opacity
this.setBackgroundColor();
@@ -75,11 +65,13 @@ 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(false);
this.setRicoCorners(!this.rounded);
this.rounded = true;
}
},
@@ -122,19 +114,6 @@ 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
*

View File

@@ -96,6 +96,25 @@ 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"

View File

@@ -26,7 +26,7 @@ OpenLayers.Tile.Image.prototype =
initialize: function(layer, position, bounds, url, size) {
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
},
/**
*
*/
@@ -47,7 +47,11 @@ 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))
@@ -79,6 +83,9 @@ 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);
},
@@ -107,6 +114,15 @@ OpenLayers.Tile.Image.prototype =
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) {
@@ -116,6 +132,23 @@ OpenLayers.Tile.Image.prototype =
}
},
/**
* 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";
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Tile.Image"
}

View File

@@ -133,9 +133,6 @@ OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
var dom = document.createElement('div');
//set specific properties
dom.style.padding = "0";
dom.style.margin = "0";
if (imgURL) {
dom.style.backgroundImage = 'url(' + imgURL + ')';
}

View File

@@ -12,6 +12,7 @@
<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>
@@ -19,11 +20,10 @@
<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>

View File

@@ -57,18 +57,32 @@
// t.plan( 2 );
if (document.createEventObject) {
t.plan(2);
t.plan(4);
} else {
t.plan(1);
t.plan(3);
}
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.EventPane('Test Layer');
//give dummy function so test wont bomb on layer.setMap()
layer.loadMapObject = function() { };
layer.getWarningHTML = function() { this.warning = true; return ""; };
map.addLayer(layer);
t.eq( parseInt(layer.pane.style.zIndex) - parseInt(layer.div.style.zIndex),
1, "layer pane is 1 z-level above its div" );
t.ok( layer.warning, "warning correctly registered on no mapObject load" );
layer2 = new OpenLayers.Layer.EventPane('Test Layer');
//give dummy function so test wont bomb on layer.setMap()
layer2.loadMapObject = function() { this.mapObject = new Object(); };
layer2.getWarningHTML = function() { this.warning = true; return ""; }
map.addLayer(layer2);
t.ok( !layer2.warning, "warning not registered on mapObject load" );
map.events.register("mousemove", map, function () {
t.ok(true, "got mouse move");
});

View File

@@ -1,6 +1,7 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var layer;
@@ -91,23 +92,19 @@
}
function test_05_Layer_WMS_isBaseLayer(t) {
t.plan(2);
t.plan(3);
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url, params);
t.ok( layer.isBaseLayer, "baselayer is true by default");
var newParams = OpenLayers.Util.extend(new Object(), params);
newParams.transparent = "true";
layer = new OpenLayers.Layer.WMS(name, url, newParams);
t.ok( !layer.isBaseLayer, "baselayer is false when transparent is set to true");
layer = new OpenLayers.Layer.WMS(name, url, params, {isBaseLayer: false});
t.ok( !layer.isBaseLayer, "baselayer is false when option is set to false" );
}
function test_06_Layer_WMS_mergeNewParams (t) {
@@ -173,7 +170,29 @@
t.eq(tile.imgDiv.style.opacity, "0.6", "Tile opacity is set correctly");
}
function test_20_Layer_WMS_Reproject (t) {
t.plan(5);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.Google("Google");
map.addLayer(layer);
layer = new OpenLayers.Layer.WMS(name, url, params, {isBaseLayer: false});
layer.isBaseLayer=false;
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0];
t.eq( tile.bounds.left, -22.5, "left side matches" );
t.eq( tile.bounds.right, -11.25, "top side matches" );
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS(name, url, params);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0];
t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay");
}
function test_99_Layer_WMS_destroy (t) {
@@ -194,10 +213,11 @@
t.ok( layer.grid == null, "grid set to null");
}
// -->
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px;display:none"></div>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>

View File

@@ -78,7 +78,7 @@
t.eq(popup.div.style.top, y + "px", "top position of popup.div set correctly");
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly");
t.eq(popup.div.style.height, h + "px", "heightposition of popup.div set correctly");
t.eq(popup.div.innerHTML, content, "good default popup.contentHTML");
t.eq(popup.div.innerHTML, '<div class="olPopupContent" style="overflow: hidden; width: 200px; height: 200px; position: relative;" id="chicken_contentDiv">charlie</div>', "good default popup.contentHTML");
t.eq(popup.div.style.backgroundColor, color, "good default popup.backgroundColor");
if (navigator.appName.indexOf("Microsoft") == -1) {

View File

@@ -27,8 +27,10 @@
function test_02_Tile_Image_draw (t) {
t.plan( 5 );
var layer = {maxExtent:new OpenLayers.Bounds(-180,-90,180,90)}; //bogus layer
layer.div = document.createElement("div");
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS("Name", "http://labs.metacarta.com/TESTURL");
map.addLayer(layer);
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var url = "http://www.openlayers.org/dev/tests/tileimage";
@@ -36,7 +38,6 @@
tile = new OpenLayers.Tile.Image(layer, position, bounds, url, size);
tile.draw();
var img = tile.imgDiv;
if (!isMozilla)
@@ -47,7 +48,7 @@
t.ok( true, "skipping element test outside of Mozilla");
else
t.ok( img instanceof HTMLImageElement, "tile.draw creates an image");
t.eq( img.src, "http://www.openlayers.org/dev/tests/tileimage", "tile.draw creates an image");
t.eq( img.src, "http://labs.metacarta.com/TESTURL?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "tile.draw creates an image");
t.eq( tile.imgDiv.style.width, "5px", "Image width is correct" );
t.eq( tile.imgDiv.style.height, "6px", "Image height is correct" );
}
@@ -59,44 +60,69 @@
var size = new OpenLayers.Size(5,6);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {reproject:false});
map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "", "Images against side of maxextent don't load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-91,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-91,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-90,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=256&HEIGHT=256", "Image covering all of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering small part of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-80,-45,80,45&WIDTH=256&HEIGHT=256", "Image covering small part of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering more than all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-95,185,95&WIDTH=256&HEIGHT=256", "Image covering more than all of extent loads");
layer.displayOutsideMaxExtent=1;
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images against side of maxextent do load with displayOutsideMaxExtent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-90,-180,90&WIDTH=256&HEIGHT=256", "Images against side of maxextent do load with displayOutsideMaxExtent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load with displayOutsideMaxExtent set");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-181,-90,180,90&WIDTH=256&HEIGHT=256", "Images over edges of maxextent do load with displayOutsideMaxExtent set");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering all of extent loads with display outside max extent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=256&HEIGHT=256", "Image covering all of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering small part of extent loads with display outside max extent");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-80,-45,80,45&WIDTH=256&HEIGHT=256", "Image covering small part of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering more than all of extent loads");
t.eq(tile.imgDiv.src, "http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/jpeg&SRS=EPSG:4326&BBOX=-185,-95,185,95&WIDTH=256&HEIGHT=256", "Image covering more than all of extent loads");
}
function test_04_Tile_Image_Display_After_Move(t) {
t.plan(3);
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var url = "http://www.openlayers.org/dev/tests/tileimage";
var size = new OpenLayers.Size(5,6);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
map.addLayer(layer);
map.zoomToMaxExtent();
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true);
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, 'none', "Tile display is set to none.") } );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'alpha':true});
map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true)
t.ok(tile.imgDiv.firstChild.src != tile.url, "Check to make sure that the alpha image URL really is different");
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, 'none', "Alpha tile display is set to none.") } );
}
// -->
</script>
</head>

View File

@@ -1,3 +1,16 @@
div.olMapViewport {
-moz-user-select: none
}
.olLayerGoogleCopyright {
left: 2px;
bottom: 2px;
}
.olLayerGooglePoweredBy {
left: 2px;
bottom: 15px;
}
.olControlScale {
right: 3px;
bottom: 3em;
@@ -10,14 +23,7 @@
display: block;
position: absolute;
}
.olLayerGoogleCopyright {
left: 2px;
bottom: 2px;
}
.olLayerGooglePoweredBy {
left: 2px;
bottom: 15px;
}
div.olControlMousePosition {
bottom: 0em;
right: 3px;
@@ -26,3 +32,48 @@ div.olControlMousePosition {
font-family: Arial;
font-size: smaller;
}
.olControlOverviewMapContainer {
position: absolute;
bottom: 0px;
right: 0px;
}
.olControlOverviewMapElement {
padding: 10px 18px 10px 10px;
background-color: #00008B;
-moz-border-radius: 1em 0 0 0;
}
.olControlOverviewMapMinimizeButton {
right: 0px;
bottom: 80px;
}
.olControlOverviewMapMaximizeButton {
right: 0px;
bottom: 80px;
}
.olControlOverviewMapExtentRectangle {
border: 2px dotted red;
}
.olLayerGeoRSSDescription {
float:left;
width:100%;
overflow:auto;
font-size:1.0em;
}
.olLayerGeoRSSClose {
float:right;
color:gray;
font-size:1.2em;
font-family:sans-serif;
}
.olLayerGeoRSSTitle {
float:left;font-size:1.2em;
}
.olPopupContent {
padding:5px;
}