Merge branch 'upstream-master' into gears

This commit is contained in:
Frederic Junod
2011-11-21 18:54:48 +01:00
10 changed files with 592 additions and 809 deletions
-126
View File
@@ -1,126 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers: OSM Layer</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
#map {
height: 350px;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer, gml;
function export_vectors() {
var x = new OpenLayers.Format.XML();
var content = x.write(gml.renderer.rendererRoot);
$("vectors").value = content;
$("vectors").style.display = "block";
$("vectorlink").href = "data:image/svg+xml," + escape(content);
$("vectorlink").style.display="block";
}
function on_feature_hover(feature) {
var text ="<ul>";
var type ="way";
if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
type = "node";
}
text += "<li>" + feature.osm_id + ": <a href='http://crschmidt.net/osm/attributes.html?type="+type+"&id="+feature.osm_id+"'>Edit</a>, <a href='http://www.openstreetmap.org/api/0.5/"+type + "/" + feature.osm_id + "'>API</a></li>";
for (var key in feature.attributes) {
text += "<li>" + key + ": " + feature.attributes[key] + "</li>";
}
text += "</ul>";
$("status").innerHTML = text;
}
function clear_data() {
gml.destroyFeatures();
}
function new_data() {
if (!check_zoom()) { return; }
clear_data();
gml.loaded = false;
gml.url = "http://www.openstreetmap.org/api/0.5/map?bbox=" + map.getExtent().toBBOX();
$("status").innerHTML = "Loading more data...";
gml.loadGML();
}
function style_osm_feature(feature) {
feature.style = OpenLayers.Util.extend({'fill':'black'}, OpenLayers.Feature.Vector.style['default']);
if (feature.attributes.highway == "motorway") {
feature.style.strokeColor = "blue";
feature.style.strokeWidth = 5;
} else if (feature.attributes.highway == "primary") {
feature.style.strokeColor = "red";
} else if (feature.attributes.highway == "secondary") {
feature.style.strokeColor = "orange";
} else if (feature.attributes.highway) {
feature.style.strokeColor = "black";
}
}
function check_zoom() {
var zoom = map.getZoom();
if (zoom >= 11) { return true; }
if (zoom >= 9) { return confirm("Loading this amount of data may slow your browser. Are you sure you want to do this?"); }
$("status").innerHTML = "Area too large. Zoom in to load data. (Current zoom level: "+ zoom + ". Must be at zoom 9+.)";
return false;
}
function init(){
OpenLayers.ProxyHost = "proxy.cgi?url=";
OpenLayers.Feature.Vector.style['default'].strokeWidth = 4;
OpenLayers.Feature.Vector.style['default'].cursor = 'pointer';
map = new OpenLayers.Map('map', {'maxResolution': 360/512/16, 'numZoomLevels':15, controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar() ]});
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Permalink());
layer = new OpenLayers.Layer.WMS( "OSM",
[
"http://t1.hypercube.telascience.org/tiles?",
"http://t2.hypercube.telascience.org/tiles?",
"http://t3.hypercube.telascience.org/tiles?",
"http://t4.hypercube.telascience.org/tiles?"
],
{layers: 'osm-4326', format: 'image/png' } );
map.addLayer(layer);
if (!map.getCenter()) {
gml = new OpenLayers.Layer.GML("OSM", "osm/sutton_coldfield.osm", {format: OpenLayers.Format.OSM});
map.zoomToExtent(new OpenLayers.Bounds(-1.819072,52.549034,-1.814341,52.551582));
} else {
if (map.getZoom() >= 11) {
gml = new OpenLayers.Layer.GML("OSM", "http://www.openstreetmap.org/api/0.5/map?bbox=" + map.getExtent().toBBOX(), {format: OpenLayers.Format.OSM});
} else {
gml = new OpenLayers.Layer.GML("OSM", "xml/cambridgeport.osm", {format: OpenLayers.Format.OSM});
}
}
gml.events.register("loadstart", null, function() { $("status").innerHTML = "Loading..."; });
gml.events.register("loadend", null, function() { $("status").innerHTML = ""; });
map.addLayer(gml);
gml.preFeatureInsert = style_osm_feature;
var sf = new OpenLayers.Control.SelectFeature(gml, {'onSelect': on_feature_hover});
map.addControl(sf);
sf.activate();
}
</script>
</head>
<body onload="init()">
<h1 id="title">Advanced OSM Layer</h1>
<div id="tags">
openstreetmap advanced
</div>
<div id="map" class="smallmap"></div>
<div id="download">
<ul>
<li><a href="javascript:new_data();">Download current view</a></li>
<li><a href="javascript:clear_data();">Clear current data</a></li>
<li><a href="javascript:export_vectors();">Export Vector Data</a></li>
</ul>
<div id="status">Loading...</div>
</div>
<a id="vectorlink" href="" style="display:none">Display via data: URL (FF Only)</a>
<textarea id="vectors" style="display:none;width:100%" rows="10"></textarea>
</body>
</html>
+3 -19
View File
@@ -20,7 +20,6 @@
</style> </style>
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script> <script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
</head> </head>
@@ -28,11 +27,11 @@
<h1 id="title">OpenLayers Spherical Mercator Example</h1> <h1 id="title">OpenLayers Spherical Mercator Example</h1>
<div id="tags"> <div id="tags">
spherical, mercator, osm, xyz, google, virtual earth, yahoo, tile spherical, mercator, osm, xyz, google, virtual earth, tile
</div> </div>
<p id="shortdesc"> <p id="shortdesc">
Shows the use of the Spherical Mercator Layers, for overlaying Shows the use of the Spherical Mercator Layers, for overlaying
Google, Yahoo, Microsoft, and other layers with XYZ tiles. Google, Microsoft, and other layers with XYZ tiles.
</p> </p>
<div id="map" class="smallmap"></div> <div id="map" class="smallmap"></div>
@@ -89,20 +88,6 @@
wrapDateLine: true wrapDateLine: true
}); });
// create Yahoo layer
var yahoo = new OpenLayers.Layer.Yahoo(
"Yahoo Street",
{sphericalMercator: true}
);
var yahoosat = new OpenLayers.Layer.Yahoo(
"Yahoo Satellite",
{'type': YAHOO_MAP_SAT, sphericalMercator: true}
);
var yahoohyb = new OpenLayers.Layer.Yahoo(
"Yahoo Hybrid",
{'type': YAHOO_MAP_HYB, sphericalMercator: true}
);
// create OSM layers // create OSM layers
var mapnik = new OpenLayers.Layer.OSM(); var mapnik = new OpenLayers.Layer.OSM();
@@ -115,8 +100,7 @@
var vector = new OpenLayers.Layer.Vector("Editable Vectors"); var vector = new OpenLayers.Layer.Vector("Editable Vectors");
map.addLayers([ map.addLayers([
gphy, gmap, gsat, ghyb, veroad, veaer, vehyb, yahoo, yahoosat, gphy, gmap, gsat, ghyb, veroad, veaer, vehyb, mapnik, osmarender, vector
yahoohyb, mapnik, osmarender, vector
]); ]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.EditingToolbar(vector)); map.addControl(new OpenLayers.Control.EditingToolbar(vector));
-52
View File
@@ -1,52 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers: Yahoo Layer</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<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">
var map, layer, velayer;
function init(){
map = new OpenLayers.Map('map');
yahooLayer = new OpenLayers.Layer.Yahoo( "Yahoo");
map.addLayer(yahooLayer);
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(-5, 40), 4);
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
</script>
</head>
<body onload="init()">
<h1 id="title">Yahoo Base Layer Example</h1>
<div id="tags">
yahoo, layer
</div>
<p id="shortdesc">
Shows how you would add a yahoo layer and add the LayerSwitcher control
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>This is an example of how to add a yahoo layer to the OpenLayers
window. In order to enable a yahoo layer, also shown in this
example is the LayerSwitcher() control for toggling between both
the yahoo layer and the OSGeo WMS.
</div>
</body>
</html>
-2
View File
@@ -128,7 +128,6 @@
"OpenLayers/Layer/FixedZoomLevels.js", "OpenLayers/Layer/FixedZoomLevels.js",
"OpenLayers/Layer/Google.js", "OpenLayers/Layer/Google.js",
"OpenLayers/Layer/Google/v3.js", "OpenLayers/Layer/Google/v3.js",
"OpenLayers/Layer/Yahoo.js",
"OpenLayers/Layer/HTTPRequest.js", "OpenLayers/Layer/HTTPRequest.js",
"OpenLayers/Layer/Grid.js", "OpenLayers/Layer/Grid.js",
"OpenLayers/Layer/MapGuide.js", "OpenLayers/Layer/MapGuide.js",
@@ -249,7 +248,6 @@
"OpenLayers/Protocol/SOS.js", "OpenLayers/Protocol/SOS.js",
"OpenLayers/Protocol/SOS/v1_0_0.js", "OpenLayers/Protocol/SOS/v1_0_0.js",
"OpenLayers/Layer/PointTrack.js", "OpenLayers/Layer/PointTrack.js",
"OpenLayers/Layer/GML.js",
"OpenLayers/Style.js", "OpenLayers/Style.js",
"OpenLayers/Style2.js", "OpenLayers/Style2.js",
"OpenLayers/StyleMap.js", "OpenLayers/StyleMap.js",
-174
View File
@@ -1,174 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Layer/Vector.js
* @requires OpenLayers/Request/XMLHttpRequest.js
* @requires OpenLayers/Console.js
*/
/**
* Class: OpenLayers.Layer.GML
* Create a vector layer by parsing a GML file. The GML file is
* passed in as a parameter.
* *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.Vector
* with Protocol.HTTP and Strategy.Fixed. Provide the protocol with a
* format parameter to get the parser you want for your data.
*
* Inherits from:
* - <OpenLayers.Layer.Vector>
*/
OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
/**
* Property: loaded
* {Boolean} Flag for whether the GML data has been loaded yet.
*/
loaded: false,
/**
* APIProperty: format
* {<OpenLayers.Format>} The format you want the data to be parsed with.
*/
format: null,
/**
* APIProperty: formatOptions
* {Object} Hash of options which should be passed to the format when it is
* created. Must be passed in the constructor.
*/
formatOptions: null,
/**
* Constructor: OpenLayers.Layer.GML
* Load and parse a single file on the web, according to the format
* provided via the 'format' option, defaulting to GML.
*
* Parameters:
* name - {String}
* url - {String} URL of a GML file.
* options - {Object} Hashtable of extra options to tag onto the layer.
*/
initialize: function(name, url, options) {
var newArguments = [];
newArguments.push(name, options);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
this.url = url;
},
/**
* APIMethod: setVisibility
* Set the visibility flag for the layer and hide/show&redraw accordingly.
* Fire event unless otherwise specified
* GML will be loaded if the layer is being made visible for the first
* time.
*
* Parameters:
* visible - {Boolean} Whether or not to display the layer
* (if in range)
* noEvent - {Boolean}
*/
setVisibility: function(visibility, noEvent) {
OpenLayers.Layer.Vector.prototype.setVisibility.apply(this, arguments);
if(this.visibility && !this.loaded){
// Load the GML
this.loadGML();
}
},
/**
* Method: moveTo
* If layer is visible and GML has not been loaded, load GML, then load GML
* and call OpenLayers.Layer.Vector.moveTo() to redraw at the new location.
*
* Parameters:
* bounds - {Object}
* zoomChanged - {Object}
* minor - {Object}
*/
moveTo:function(bounds, zoomChanged, minor) {
OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);
// Wait until initialisation is complete before loading GML
// otherwise we can get a race condition where the root HTML DOM is
// loaded after the GML is paited.
// See http://trac.openlayers.org/ticket/404
if(this.visibility && !this.loaded){
this.loadGML();
}
},
/**
* Method: loadGML
*/
loadGML: function() {
if (!this.loaded) {
this.events.triggerEvent("loadstart");
OpenLayers.Request.GET({
url: this.url,
success: this.requestSuccess,
failure: this.requestFailure,
scope: this
});
this.loaded = true;
}
},
/**
* Method: setUrl
* Change the URL and reload the GML
*
* Parameters:
* url - {String} URL of a GML file.
*/
setUrl:function(url) {
this.url = url;
this.destroyFeatures();
this.loaded = false;
this.loadGML();
},
/**
* Method: requestSuccess
* Process GML after it has been loaded.
* Called by initialize() and loadUrl() after the GML has been loaded.
*
* Parameters:
* request - {String}
*/
requestSuccess:function(request) {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
doc = request.responseText;
}
var options = {};
OpenLayers.Util.extend(options, this.formatOptions);
if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
options.externalProjection = this.projection;
options.internalProjection = this.map.getProjectionObject();
}
var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
this.addFeatures(gml.read(doc));
this.events.triggerEvent("loadend");
},
/**
* Method: requestFailure
* Process a failed loading of GML.
* Called by initialize() and loadUrl() if there was a problem loading GML.
*
* Parameters:
* request - {String}
*/
requestFailure: function(request) {
OpenLayers.Console.userError('Error in loading GML file ' + this.url);
this.events.triggerEvent("loadend");
},
CLASS_NAME: "OpenLayers.Layer.GML"
});
-431
View File
@@ -1,431 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Layer/SphericalMercator.js
* @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
* @requires OpenLayers/Lang.js
*/
/**
* Class: OpenLayers.Layer.Yahoo
*
* Inherits from:
* - <OpenLayers.Layer.EventPane>
* - <OpenLayers.Layer.FixedZoomLevels>
*/
OpenLayers.Layer.Yahoo = OpenLayers.Class(
OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {
/**
* Constant: MIN_ZOOM_LEVEL
* {Integer} 0
*/
MIN_ZOOM_LEVEL: 0,
/**
* Constant: MAX_ZOOM_LEVEL
* {Integer} 17
*/
MAX_ZOOM_LEVEL: 17,
/**
* Constant: RESOLUTIONS
* {Array(Float)} Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*/
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,
0.00002145767211914062,
0.00001072883605957031
],
/**
* APIProperty: type
* {YahooMapType}
*/
type: null,
/**
* APIProperty: wrapDateLine
* {Boolean} Allow user to pan forever east/west. Default is true.
* Setting this to false only restricts panning if
* <sphericalMercator> is true.
*/
wrapDateLine: true,
/**
* APIProperty: sphericalMercator
* {Boolean} Should the map act as a mercator-projected map? This will
* cause all interactions with the map to be in the actual map projection,
* which allows support for vector drawing, overlaying other maps, etc.
*/
sphericalMercator: false,
/**
* Constructor: OpenLayers.Layer.Yahoo
*
* Parameters:
* name - {String}
* options - {Object}
*/
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if(this.sphericalMercator) {
OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
this.initMercatorParameters();
}
},
/**
* Method: loadMapObject
*/
loadMapObject:function() {
try { //do not crash!
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
this.mapObject = new YMap(this.div, this.type, size);
this.mapObject.disableKeyControls();
this.mapObject.disableDragMap();
//can we do smooth panning? (moveByXY is not an API function)
if ( !this.mapObject.moveByXY ||
(typeof this.mapObject.moveByXY != "function" ) ) {
this.dragPanMapObject = null;
}
} catch(e) {}
},
/**
* Method: onMapResize
*
*/
onMapResize: function() {
try {
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
this.mapObject.resizeTo(size);
} catch(e) {}
},
/**
* APIMethod: setMap
* 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.
*
* Parameters:
* map - {<OpenLayers.Map>}
*/
setMap: function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
this.map.events.register("moveend", this, this.fixYahooEventPane);
},
/**
* Method: fixYahooEventPane
* The map has been centered, so the mysterious yahoo eventpane has been
* added. we remove it so that it doesnt mess with *our* event pane.
*/
fixYahooEventPane: function() {
var yahooEventPane = OpenLayers.Util.getElement("ygddfdiv");
if (yahooEventPane != null) {
if (yahooEventPane.parentNode != null) {
yahooEventPane.parentNode.removeChild(yahooEventPane);
}
this.map.events.unregister("moveend", this,
this.fixYahooEventPane);
}
},
/**
* APIMethod: getWarningHTML
*
* Returns:
* {String} String with information on why layer is broken, how to get
* it working.
*/
getWarningHTML:function() {
return OpenLayers.i18n(
"getLayerWarning", {'layerType':'Yahoo', 'layerLib':'Yahoo'}
);
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
//
/**
* APIMethod: getOLZoomFromMapObjectZoom
*
* Parameters:
* gZoom - {Integer}
*
* Returns:
* {Integer} An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in.
*/
getOLZoomFromMapObjectZoom: function(moZoom) {
var zoom = null;
if (moZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
zoom = 18 - zoom;
}
return zoom;
},
/**
* APIMethod: getMapObjectZoomFromOLZoom
*
* Parameters:
* olZoom - {Integer}
*
* Returns:
* {Integer} A MapObject level, translated from the passed in olZoom
* Returns null if null value is passed in
*/
getMapObjectZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
zoom = 18 - zoom;
}
return zoom;
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/**
* APIMethod: setMapObjectCenter
* Set the mapObject to the specified center and zoom
*
* Parameters:
* center - {Object} MapObject LonLat format
* zoom - {int} MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.drawZoomAndCenter(center, zoom);
},
/**
* APIMethod: getMapObjectCenter
*
* Returns:
* {Object} The mapObject's current center in Map Object format
*/
getMapObjectCenter: function() {
return this.mapObject.getCenterLatLon();
},
/**
* APIMethod: dragPanMapObject
*
* Parameters:
* dX - {Integer}
* dY - {Integer}
*/
dragPanMapObject: function(dX, dY) {
this.mapObject.moveByXY({
'x': -dX,
'y': dY
});
},
/**
* APIMethod: getMapObjectZoom
*
* Returns:
* {Integer} The mapObject's current zoom, in Map Object format
*/
getMapObjectZoom: function() {
return this.mapObject.getZoomLevel();
},
// LonLat - Pixel Translation
/**
* APIMethod: getMapObjectLonLatFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Object} MapObject LonLat translated from MapObject Pixel
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
return this.mapObject.convertXYLatLon(moPixel);
},
/**
* APIMethod: getMapObjectPixelFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Object} MapObject Pixel transtlated from MapObject LonLat
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.convertLatLonXY(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* APIMethod: getLongitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Longitude of the given MapObject LonLat
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lon :
moLonLat.Lon;
},
/**
* APIMethod: getLatitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Latitude of the given MapObject LonLat
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lat :
moLonLat.Lat;
},
/**
* APIMethod: getMapObjectLonLatFromLonLat
*
* Parameters:
* lon - {Float}
* lat - {Float}
*
* Returns:
* {Object} MapObject LonLat built from lon and lat params
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
var yLatLong;
if(this.sphericalMercator) {
var lonlat = this.inverseMercator(lon, lat);
yLatLong = new YGeoPoint(lonlat.lat, lonlat.lon);
} else {
yLatLong = new YGeoPoint(lat, lon);
}
return yLatLong;
},
// Pixel
/**
* APIMethod: getXFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} X value of the MapObject Pixel
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* APIMethod: getYFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} Y value of the MapObject Pixel
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* APIMethod: getMapObjectPixelFromXY
*
* Parameters:
* x - {Integer}
* y - {Integer}
*
* Returns:
* {Object} MapObject Pixel from x and y parameters
*/
getMapObjectPixelFromXY: function(x, y) {
return new YCoordPoint(x, y);
},
// Size
/**
* APIMethod: getMapObjectSizeFromOLSize
*
* Parameters:
* olSize - {<OpenLayers.Size>}
*
* Returns:
* {Object} MapObject Size from olSize parameter
*/
getMapObjectSizeFromOLSize: function(olSize) {
return new YSize(olSize.w, olSize.h);
},
CLASS_NAME: "OpenLayers.Layer.Yahoo"
});
+583 -1
View File
@@ -3636,7 +3636,6 @@ OpenLayers.Layer.VirtualEarth = OpenLayers.Class(
CLASS_NAME: "OpenLayers.Layer.VirtualEarth" CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
}); });
/* /*
* Copyright 2007, Google Inc. * Copyright 2007, Google Inc.
* *
@@ -4276,3 +4275,586 @@ OpenLayers.Protocol.SQL.Gears = OpenLayers.Class(OpenLayers.Protocol.SQL, {
CLASS_NAME: "OpenLayers.Protocol.SQL.Gears" CLASS_NAME: "OpenLayers.Protocol.SQL.Gears"
}); });
/**
* Class: OpenLayers.Layer.Yahoo
*
* Inherits from:
* - <OpenLayers.Layer.EventPane>
* - <OpenLayers.Layer.FixedZoomLevels>
*/
OpenLayers.Layer.Yahoo = OpenLayers.Class(
OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {
/**
* Constant: MIN_ZOOM_LEVEL
* {Integer} 0
*/
MIN_ZOOM_LEVEL: 0,
/**
* Constant: MAX_ZOOM_LEVEL
* {Integer} 17
*/
MAX_ZOOM_LEVEL: 17,
/**
* Constant: RESOLUTIONS
* {Array(Float)} Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*/
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,
0.00002145767211914062,
0.00001072883605957031
],
/**
* APIProperty: type
* {YahooMapType}
*/
type: null,
/**
* APIProperty: wrapDateLine
* {Boolean} Allow user to pan forever east/west. Default is true.
* Setting this to false only restricts panning if
* <sphericalMercator> is true.
*/
wrapDateLine: true,
/**
* APIProperty: sphericalMercator
* {Boolean} Should the map act as a mercator-projected map? This will
* cause all interactions with the map to be in the actual map projection,
* which allows support for vector drawing, overlaying other maps, etc.
*/
sphericalMercator: false,
/**
* Constructor: OpenLayers.Layer.Yahoo
*
* Parameters:
* name - {String}
* options - {Object}
*/
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if(this.sphericalMercator) {
OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
this.initMercatorParameters();
}
},
/**
* Method: loadMapObject
*/
loadMapObject:function() {
try { //do not crash!
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
this.mapObject = new YMap(this.div, this.type, size);
this.mapObject.disableKeyControls();
this.mapObject.disableDragMap();
//can we do smooth panning? (moveByXY is not an API function)
if ( !this.mapObject.moveByXY ||
(typeof this.mapObject.moveByXY != "function" ) ) {
this.dragPanMapObject = null;
}
} catch(e) {}
},
/**
* Method: onMapResize
*
*/
onMapResize: function() {
try {
var size = this.getMapObjectSizeFromOLSize(this.map.getSize());
this.mapObject.resizeTo(size);
} catch(e) {}
},
/**
* APIMethod: setMap
* 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.
*
* Parameters:
* map - {<OpenLayers.Map>}
*/
setMap: function(map) {
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
this.map.events.register("moveend", this, this.fixYahooEventPane);
},
/**
* Method: fixYahooEventPane
* The map has been centered, so the mysterious yahoo eventpane has been
* added. we remove it so that it doesnt mess with *our* event pane.
*/
fixYahooEventPane: function() {
var yahooEventPane = OpenLayers.Util.getElement("ygddfdiv");
if (yahooEventPane != null) {
if (yahooEventPane.parentNode != null) {
yahooEventPane.parentNode.removeChild(yahooEventPane);
}
this.map.events.unregister("moveend", this,
this.fixYahooEventPane);
}
},
/**
* APIMethod: getWarningHTML
*
* Returns:
* {String} String with information on why layer is broken, how to get
* it working.
*/
getWarningHTML:function() {
return OpenLayers.i18n(
"getLayerWarning", {'layerType':'Yahoo', 'layerLib':'Yahoo'}
);
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: MapObject Zoom <-> OpenLayers Zoom
//
/**
* APIMethod: getOLZoomFromMapObjectZoom
*
* Parameters:
* gZoom - {Integer}
*
* Returns:
* {Integer} An OpenLayers Zoom level, translated from the passed in gZoom
* Returns null if null value is passed in.
*/
getOLZoomFromMapObjectZoom: function(moZoom) {
var zoom = null;
if (moZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
zoom = 18 - zoom;
}
return zoom;
},
/**
* APIMethod: getMapObjectZoomFromOLZoom
*
* Parameters:
* olZoom - {Integer}
*
* Returns:
* {Integer} A MapObject level, translated from the passed in olZoom
* Returns null if null value is passed in
*/
getMapObjectZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
zoom = 18 - zoom;
}
return zoom;
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/**
* APIMethod: setMapObjectCenter
* Set the mapObject to the specified center and zoom
*
* Parameters:
* center - {Object} MapObject LonLat format
* zoom - {int} MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.drawZoomAndCenter(center, zoom);
},
/**
* APIMethod: getMapObjectCenter
*
* Returns:
* {Object} The mapObject's current center in Map Object format
*/
getMapObjectCenter: function() {
return this.mapObject.getCenterLatLon();
},
/**
* APIMethod: dragPanMapObject
*
* Parameters:
* dX - {Integer}
* dY - {Integer}
*/
dragPanMapObject: function(dX, dY) {
this.mapObject.moveByXY({
'x': -dX,
'y': dY
});
},
/**
* APIMethod: getMapObjectZoom
*
* Returns:
* {Integer} The mapObject's current zoom, in Map Object format
*/
getMapObjectZoom: function() {
return this.mapObject.getZoomLevel();
},
// LonLat - Pixel Translation
/**
* APIMethod: getMapObjectLonLatFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Object} MapObject LonLat translated from MapObject Pixel
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
return this.mapObject.convertXYLatLon(moPixel);
},
/**
* APIMethod: getMapObjectPixelFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Object} MapObject Pixel transtlated from MapObject LonLat
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.convertLatLonXY(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* APIMethod: getLongitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Longitude of the given MapObject LonLat
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lon :
moLonLat.Lon;
},
/**
* APIMethod: getLatitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Latitude of the given MapObject LonLat
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lat :
moLonLat.Lat;
},
/**
* APIMethod: getMapObjectLonLatFromLonLat
*
* Parameters:
* lon - {Float}
* lat - {Float}
*
* Returns:
* {Object} MapObject LonLat built from lon and lat params
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
var yLatLong;
if(this.sphericalMercator) {
var lonlat = this.inverseMercator(lon, lat);
yLatLong = new YGeoPoint(lonlat.lat, lonlat.lon);
} else {
yLatLong = new YGeoPoint(lat, lon);
}
return yLatLong;
},
// Pixel
/**
* APIMethod: getXFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} X value of the MapObject Pixel
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* APIMethod: getYFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} Y value of the MapObject Pixel
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* APIMethod: getMapObjectPixelFromXY
*
* Parameters:
* x - {Integer}
* y - {Integer}
*
* Returns:
* {Object} MapObject Pixel from x and y parameters
*/
getMapObjectPixelFromXY: function(x, y) {
return new YCoordPoint(x, y);
},
// Size
/**
* APIMethod: getMapObjectSizeFromOLSize
*
* Parameters:
* olSize - {<OpenLayers.Size>}
*
* Returns:
* {Object} MapObject Size from olSize parameter
*/
getMapObjectSizeFromOLSize: function(olSize) {
return new YSize(olSize.w, olSize.h);
},
CLASS_NAME: "OpenLayers.Layer.Yahoo"
});
/**
* Class: OpenLayers.Layer.GML
* Create a vector layer by parsing a GML file. The GML file is
* passed in as a parameter.
* *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.Vector
* with Protocol.HTTP and Strategy.Fixed. Provide the protocol with a
* format parameter to get the parser you want for your data.
*
* Inherits from:
* - <OpenLayers.Layer.Vector>
*/
OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
/**
* Property: loaded
* {Boolean} Flag for whether the GML data has been loaded yet.
*/
loaded: false,
/**
* APIProperty: format
* {<OpenLayers.Format>} The format you want the data to be parsed with.
*/
format: null,
/**
* APIProperty: formatOptions
* {Object} Hash of options which should be passed to the format when it is
* created. Must be passed in the constructor.
*/
formatOptions: null,
/**
* Constructor: OpenLayers.Layer.GML
* Load and parse a single file on the web, according to the format
* provided via the 'format' option, defaulting to GML.
*
* Parameters:
* name - {String}
* url - {String} URL of a GML file.
* options - {Object} Hashtable of extra options to tag onto the layer.
*/
initialize: function(name, url, options) {
var newArguments = [];
newArguments.push(name, options);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
this.url = url;
},
/**
* APIMethod: setVisibility
* Set the visibility flag for the layer and hide/show&redraw accordingly.
* Fire event unless otherwise specified
* GML will be loaded if the layer is being made visible for the first
* time.
*
* Parameters:
* visible - {Boolean} Whether or not to display the layer
* (if in range)
* noEvent - {Boolean}
*/
setVisibility: function(visibility, noEvent) {
OpenLayers.Layer.Vector.prototype.setVisibility.apply(this, arguments);
if(this.visibility && !this.loaded){
// Load the GML
this.loadGML();
}
},
/**
* Method: moveTo
* If layer is visible and GML has not been loaded, load GML, then load GML
* and call OpenLayers.Layer.Vector.moveTo() to redraw at the new location.
*
* Parameters:
* bounds - {Object}
* zoomChanged - {Object}
* minor - {Object}
*/
moveTo:function(bounds, zoomChanged, minor) {
OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);
// Wait until initialisation is complete before loading GML
// otherwise we can get a race condition where the root HTML DOM is
// loaded after the GML is paited.
// See http://trac.openlayers.org/ticket/404
if(this.visibility && !this.loaded){
this.loadGML();
}
},
/**
* Method: loadGML
*/
loadGML: function() {
if (!this.loaded) {
this.events.triggerEvent("loadstart");
OpenLayers.Request.GET({
url: this.url,
success: this.requestSuccess,
failure: this.requestFailure,
scope: this
});
this.loaded = true;
}
},
/**
* Method: setUrl
* Change the URL and reload the GML
*
* Parameters:
* url - {String} URL of a GML file.
*/
setUrl:function(url) {
this.url = url;
this.destroyFeatures();
this.loaded = false;
this.loadGML();
},
/**
* Method: requestSuccess
* Process GML after it has been loaded.
* Called by initialize() and loadUrl() after the GML has been loaded.
*
* Parameters:
* request - {String}
*/
requestSuccess:function(request) {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
doc = request.responseText;
}
var options = {};
OpenLayers.Util.extend(options, this.formatOptions);
if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
options.externalProjection = this.projection;
options.internalProjection = this.map.getProjectionObject();
}
var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
this.addFeatures(gml.read(doc));
this.events.triggerEvent("loadend");
},
/**
* Method: requestFailure
* Process a failed loading of GML.
* Called by initialize() and loadUrl() if there was a problem loading GML.
*
* Parameters:
* request - {String}
*/
requestFailure: function(request) {
OpenLayers.Console.userError('Error in loading GML file ' + this.url);
this.events.triggerEvent("loadend");
},
CLASS_NAME: "OpenLayers.Layer.GML"
});
@@ -1,6 +1,7 @@
<html> <html>
<head> <head>
<script src="../OLLoader.js"></script> <script src="../../OLLoader.js"></script>
<script src="../../../lib/deprecated.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var name = "GML Layer"; var name = "GML Layer";
@@ -1,7 +1,8 @@
<html> <html>
<head> <head>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script> <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<script src="../OLLoader.js"></script> <script src="../../OLLoader.js"></script>
<script src="../../../lib/deprecated.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var layer; var layer;
+2 -2
View File
@@ -148,7 +148,6 @@
<li>Layer/EventPane.html</li> <li>Layer/EventPane.html</li>
<li>Layer/FixedZoomLevels.html</li> <li>Layer/FixedZoomLevels.html</li>
<li>Layer/GeoRSS.html</li> <li>Layer/GeoRSS.html</li>
<li>Layer/GML.html</li>
<li>Layer/Google.html</li> <li>Layer/Google.html</li>
<li>Layer/Google/v3.html</li> <li>Layer/Google/v3.html</li>
<li>Layer/Grid.html</li> <li>Layer/Grid.html</li>
@@ -170,7 +169,6 @@
<li>Layer/WMTS.html</li> <li>Layer/WMTS.html</li>
<li>Layer/WrapDateLine.html</li> <li>Layer/WrapDateLine.html</li>
<li>Layer/XYZ.html</li> <li>Layer/XYZ.html</li>
<li>Layer/Yahoo.html</li>
<li>Map.html</li> <li>Map.html</li>
<li>Marker.html</li> <li>Marker.html</li>
<li>Marker/Box.html</li> <li>Marker/Box.html</li>
@@ -226,11 +224,13 @@
<li>deprecated/BaseTypes/Class.html</li> <li>deprecated/BaseTypes/Class.html</li>
<li>deprecated/BaseTypes/Element.html</li> <li>deprecated/BaseTypes/Element.html</li>
<li>deprecated/Control/MouseToolbar.html</li> <li>deprecated/Control/MouseToolbar.html</li>
<li>deprecated/Layer/GML.html</li>
<li>deprecated/Layer/MapServer/Untiled.html</li> <li>deprecated/Layer/MapServer/Untiled.html</li>
<li>deprecated/Layer/MultiMap.html</li> <li>deprecated/Layer/MultiMap.html</li>
<li>deprecated/Layer/WFS.html</li> <li>deprecated/Layer/WFS.html</li>
<li>deprecated/Layer/WMS.html</li> <li>deprecated/Layer/WMS.html</li>
<li>deprecated/Layer/WMS/Post.html</li> <li>deprecated/Layer/WMS/Post.html</li>
<li>deprecated/Protocol/SQL/Gears.html</li> <li>deprecated/Protocol/SQL/Gears.html</li>
<li>deprecated/Layer/Yahoo.html</li>
<li>deprecated/Tile/WFS.html</li> <li>deprecated/Tile/WFS.html</li>
</ul> </ul>