Merge vector-2.4 branch back to trunk.

svn merge sandbox/vector-2.4/@2307 sandbox/vector-2.4/@HEAD trunk/openlayers/


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2803 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-03-16 13:23:56 +00:00
parent 8b9d974dc2
commit 3ca974acec
159 changed files with 10193 additions and 343 deletions

12
build/full.cfg Normal file
View File

@@ -0,0 +1,12 @@
[first]
OpenLayers/SingleFile.js
OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/Util.js
Rico/Corner.js
[last]
[include]
[exclude]

View File

@@ -10,4 +10,38 @@ Rico/Corner.js
[include]
[exclude]
OpenLayers/Control/KeyboardDefaults.js
OpenLayers/Format/GeoRSS.js
OpenLayers/Format/GML.js
OpenLayers/Format/JSON.js
OpenLayers/Format/KML.js
OpenLayers/Format/WFS.js
OpenLayers/Format.js
OpenLayers/Handler/Path.js
OpenLayers/Handler/Point.js
OpenLayers/Handler/Polygon.js
OpenLayers/Handler/Select.js
OpenLayers/Geometry/Collection.js
OpenLayers/Geometry/Curve.js
OpenLayers/Geometry/LinearRing.js
OpenLayers/Geometry/LineString.js
OpenLayers/Geometry/MultiLineString.js
OpenLayers/Geometry/MultiPoint.js
OpenLayers/Geometry/MultiPolygon.js
OpenLayers/Geometry/Point.js
OpenLayers/Geometry/Polygon.js
OpenLayers/Geometry/Rectangle.js
OpenLayers/Geometry/Surface.js
OpenLayers/Geometry.js
OpenLayers/Layer/GML.js
OpenLayers/Layer/Vector.js
OpenLayers/Control/DrawFeature.js
OpenLayers/Control/EditingToolbar.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Feature/Vector.js
OpenLayers/Renderer
OpenLayers/Renderer/Elements.js
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/VML.js
OpenLayers/Renderer.js

33
examples/GMLParser.html Normal file
View File

@@ -0,0 +1,33 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function parseData(req) {
g = new OpenLayers.Format.GML();
html = ""
features = g.read(req.responseText);
for(var feat in features) {
html += "Feature: Geometry: "+ features[feat].geometry+",";
html += "<ul>";
for (var j in features[feat].attributes) {
html += "<li>"+j+":"+features[feat].attributes[j]+"</li>";
}
html += "</ul>"
}
document.body.innerHTML = html;
}
function load() {
OpenLayers.loadURL("gml/owls.xml", "", null, parseData);
}
</script>
</head>
<body onload="load()">
</body>
</html>

33
examples/KMLParser.html Normal file
View File

@@ -0,0 +1,33 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function parseData(req) {
g = new OpenLayers.Format.KML();
html = ""
features = g.read(req.responseText);
for(var feat in features) {
html += "Feature: Geometry: "+ features[feat].geometry+",";
html += "<ul>";
for (var j in features[feat].attributes) {
html += "<li>"+j+":"+features[feat].attributes[j]+"</li>";
}
html += "</ul>"
}
document.body.innerHTML = html;
}
function load() {
OpenLayers.loadURL("kml/mc-search.kml", "", null, parseData);
}
</script>
</head>
<body onload="load()">
</body>
</html>

View File

@@ -20,6 +20,8 @@
map.addControl(new OpenLayers.Control.Permalink('permalink'));
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.KeyboardDefaults());
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} );

View File

@@ -0,0 +1,49 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
var control = new OpenLayers.Control();
OpenLayers.Util.extend(control, {
draw: function () {
// this Handler.Box will intercept the shift-mousedown
// before Control.MouseDefault gets to see it
this.box = new OpenLayers.Handler.Box( control,
{"done": this.notice},
{keyMask: OpenLayers.Handler.MOD_SHIFT});
this.box.activate();
},
notice: function (bounds) {
alert(bounds);
}
});
map.addLayer(layer);
map.addControl(control);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,96 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 350px;
border: 1px solid gray;
}
#controlToggle li {
list-style: none;
}
p {
width: 512px;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, drawControls;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
function init(){
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
map.addLayers([wmsLayer, pointLayer, lineLayer, polygonLayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
var options = {handlerOptions: {freehand: true}};
drawControls = {
point: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Point),
line: new OpenLayers.Control.DrawFeature(lineLayer,
OpenLayers.Handler.Path, options),
polygon: new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.Polygon, options)
};
for(var key in drawControls) {
map.addControl(drawControls[key]);
}
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
document.getElementById('noneToggle').checked = true;
}
function toggleControl(element) {
for(key in drawControls) {
var control = drawControls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Draw Feature Example</h1>
<div id="map"></div>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="none" id="noneToggle"
onclick="toggleControl(this);" checked="checked" />
<label for="noneToggle">navigate</label>
</li>
<li>
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
<label for="pointToggle">draw point</label>
</li>
<li>
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
<label for="lineToggle">draw line</label>
</li>
<li>
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
<label for="polygonToggle">draw polygon</label>
</li>
</ul>
<p>Feature digitizing is in freehand mode by default. In freehand mode, the mouse is treated as a pen.
Drawing begins on mouse down, continues with every mouse move, and ends with mouse up.</p>
<p>To turn freehand mode off, hold down the shift key while digitizing. With freehand mode off, one
vertex is added with each click and double-clicks finish drawing. Freehand mode can be toggled on and off
at any time while drawing.</p>
</body>
</html>

View File

@@ -0,0 +1,38 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script src="../lib/Firebug/debug.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( 'map', { controls: [] } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
vlayer = new OpenLayers.Layer.Vector( "Editable" );
map.addLayer(vlayer);
map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="panel"></div>
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 350px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, drawControl, g;
function serialize(feature) {
feature.attributes = {};
var name = prompt("Title for feature?");
feature.attributes['title'] = name;
s = new XMLSerializer();
var data = g.write(feature.layer.features);
$("gml").value = s.serializeToString(data);
}
function init(){
g = new OpenLayers.Format.GeoRSS();
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
pointLayer.onFeatureInsert = serialize;
map.addLayers([wmsLayer, pointLayer]);
map.addControl(new OpenLayers.Control.EditingToolbar(pointLayer));
map.addControl(new OpenLayers.Control.MousePosition());
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Draw Point Example</h1>
<div style="float:right">
<textarea id="gml" cols="80" rows="30"></textarea>
</div>
<div id="map"></div>
</body>
</html>

32
examples/gml-layer.html Normal file
View File

@@ -0,0 +1,32 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.zoomToExtent(new OpenLayers.Bounds(-3.922119,44.335327,4.866943,49.553833));
map.addLayer(new OpenLayers.Layer.GML("GML", "gml/polygon.xml"));
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,86 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 350px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, drawControl, g;
function serialize(feature) {
feature.attributes = {};
var name = prompt("Name for feature?");
feature.attributes['name'] = name;
s = new XMLSerializer();
var data = g.write(feature.layer.features);
$("gml").value = s.serializeToString(data);
}
function init(){
g = new OpenLayers.Format.GML();
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
pointLayer.onFeatureInsert = serialize;
map.addLayers([wmsLayer, pointLayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
drawControls = {
point: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Point),
line: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Path)
};
for(var key in drawControls) {
map.addControl(drawControls[key]);
}
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
}
function toggleControl(element) {
for(key in drawControls) {
var control = drawControls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Draw Point Example</h1>
<div style="float:right">
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="none" id="noneToggle"
onclick="toggleControl(this);" checked="checked" />
<label for="noneToggle">navigate</label>
</li>
<li>
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
<label for="pointToggle">draw point</label>
</li>
<li>
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
<label for="lineToggle">draw line</label>
</li>
</ul>
<p>Check the box to draw points. Uncheck to navigate normally.</p>
<textarea id="gml" cols="80" rows="30"></textarea>
</div>
<div id="map"></div>
</body>
</html>

42
examples/gml/line.xml Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=line&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-3.924027,46.037889 2.193186,47.897181</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:line fid="1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.631235,46.037889 2.193186,46.704963</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:LineString srsName="EPSG:4326">
<gml:coordinates>-0.631235,46.307557 -0.262215,46.577225 0.106805,46.477874 0.220349,46.293364 0.475824,46.406909 0.887424,46.350136 1.029354,46.563032 1.213864,46.648191 1.526112,46.421102 1.795780,46.066275 2.108028,46.037889 2.178993,46.250785 2.193186,46.492067 2.193186,46.492067 2.051255,46.704963 2.051255,46.704963 </gml:coordinates>
</gml:LineString>
</ms:msGeometry>
<ms:ogc_fid>1</ms:ogc_fid>
<ms:name/>
<ms:id>0</ms:id>
</ms:line>
</gml:featureMember>
<gml:featureMember>
<ms:line fid="2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-3.924027,46.279171 -1.127992,47.897181</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:LineString srsName="EPSG:4326">
<gml:coordinates>-1.127992,46.279171 -1.369275,46.364329 -1.624750,46.406909 -1.866032,46.492067 -1.993770,46.704963 -2.178280,46.846894 -1.979577,47.059790 -2.164087,47.144948 -2.135700,47.215914 -2.093121,47.357844 -2.277631,47.258493 -2.391176,47.301072 -2.490527,47.315265 -2.476334,47.443003 -2.575686,47.599127 -2.703423,47.542354 -2.873740,47.471389 -3.285339,47.670092 -3.597587,47.769443 -3.824676,47.840409 -3.924027,47.897181 </gml:coordinates>
</gml:LineString>
</ms:msGeometry>
<ms:ogc_fid>2</ms:ogc_fid>
<ms:name/>
<ms:id>0</ms:id>
</ms:line>
</gml:featureMember>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=multipoint&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>0.490018,45.001795 3.016384,45.839186</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:multipoint fid="1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>0.930003,45.001795 3.016384,45.541131</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPoint srsName="EPSG:4326">
<gml:pointMember>
<gml:Point>
<gml:coordinates>2.079641,45.001795</gml:coordinates>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coordinates>2.718330,45.541131</gml:coordinates>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coordinates>3.016384,45.143725</gml:coordinates>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coordinates>0.930003,45.001795</gml:coordinates>
</gml:Point>
</gml:pointMember>
</gml:MultiPoint>
</ms:msGeometry>
<ms:ogc_fid>1</ms:ogc_fid>
<ms:name>4 points</ms:name>
<ms:id>1</ms:id>
</ms:multipoint>
</gml:featureMember>
<gml:featureMember>
<ms:multipoint fid="2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>0.490018,45.654676 1.157092,45.839186</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPoint srsName="EPSG:4326">
<gml:pointMember>
<gml:Point>
<gml:coordinates>0.490018,45.654676</gml:coordinates>
</gml:Point>
</gml:pointMember>
<gml:pointMember>
<gml:Point>
<gml:coordinates>1.157092,45.839186</gml:coordinates>
</gml:Point>
</gml:pointMember>
</gml:MultiPoint>
</ms:msGeometry>
<ms:ogc_fid>2</ms:ogc_fid>
<ms:name>2 points</ms:name>
<ms:id>2</ms:id>
</ms:multipoint>
</gml:featureMember>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=multipolygon&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-1.738295,46.307557 3.754424,47.244300</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:multipolygon fid="1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-1.738295,46.605612 1.767394,47.244300</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPolygon srsName="EPSG:4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>1.313216,46.690770 1.000968,46.861087 0.887424,47.059790 1.142899,47.244300 1.355795,47.244300 1.554498,47.017211 1.710622,47.059790 1.767394,46.747542 1.313216,46.690770 1.313216,46.690770 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>0.731300,46.605612 -0.191250,46.704963 -0.191250,46.846894 0.177770,46.988824 0.447438,46.960438 0.589369,46.804315 0.688721,46.832701 0.731300,46.605612 0.731300,46.605612 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>-1.610557,46.733349 -1.184765,46.704963 -1.198958,46.704963 -0.943483,46.619805 -0.915096,46.818508 -0.659621,46.775928 -0.688007,47.017211 -0.943483,47.003018 -1.127992,47.088176 -1.397661,47.102369 -1.624750,47.073983 -1.738295,46.917859 -1.610557,46.733349 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</ms:msGeometry>
<ms:ogc_fid>1</ms:ogc_fid>
<ms:name>My first Multipolygon</ms:name>
<ms:id>0</ms:id>
</ms:multipolygon>
</gml:featureMember>
<gml:featureMember>
<ms:multipolygon fid="2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>2.789295,46.392716 3.754424,46.903666</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Polygon srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>2.959612,46.392716 2.789295,46.775928 3.172508,46.903666 3.498949,46.903666 3.498949,46.662384 3.754424,46.563032 2.959612,46.392716 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ms:msGeometry>
<ms:ogc_fid>2</ms:ogc_fid>
<ms:name>My second Multipolygon</ms:name>
<ms:id>0</ms:id>
</ms:multipolygon>
</gml:featureMember>
<gml:featureMember>
<ms:multipolygon fid="3">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>2.207379,46.307557 2.803488,47.045597</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPolygon srsName="EPSG:4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>2.292538,46.804315 2.207379,47.017211 2.391889,47.045597 2.562206,46.832701 2.292538,46.804315 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>2.789295,46.307557 2.789295,46.307557 2.803488,46.506260 2.618978,46.676577 2.349310,46.633998 2.448661,46.392716 2.789295,46.307557 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</ms:msGeometry>
<ms:ogc_fid>3</ms:ogc_fid>
<ms:name>My third Multipolygon</ms:name>
<ms:id>0</ms:id>
</ms:multipolygon>
</gml:featureMember>
</wfs:FeatureCollection>

156
examples/gml/owls.xml Normal file
View File

@@ -0,0 +1,156 @@
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:bsc="http://www.bsc-eoc.org/bsc"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd
http://www.bsc-eoc.org/bsc http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=OWLS&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-89.817223,45.005555 -74.755001,51.701388</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember><bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-79.771668,45.891110 -79.771668,45.891110</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-79.771668,45.891110</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-83.755834,46.365277 -83.755834,46.365277</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:owlname>owl</bsc:owlname>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-83.755834,46.365277</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-83.808612,46.175277 -83.808612,46.175277</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-83.808612,46.175277</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-84.111112,46.309166 -84.111112,46.309166</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-84.111112,46.309166</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-83.678612,46.821110 -83.678612,46.821110</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-83.678612,46.821110</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-83.664445,46.518888 -83.664445,46.518888</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-83.664445,46.518888</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-80.613334,46.730277 -80.613334,46.730277</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-80.613334,46.730277</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-79.676946,45.428054 -79.676946,45.428054</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-79.676946,45.428054</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-83.853056,46.236944 -83.853056,46.236944</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-83.853056,46.236944</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
<gml:featureMember>
<bsc:OWLS>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-82.289167,45.896388 -82.289167,45.896388</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<bsc:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-82.289167,45.896388</gml:coordinates>
</gml:Point>
</bsc:msGeometry>
</bsc:OWLS>
</gml:featureMember>
</wfs:FeatureCollection>

42
examples/gml/point.xml Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=point&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.608315,44.857522 -0.021418,45.477577</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:point fid="1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.608315,44.857522 -0.608315,44.857522</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-0.608315,44.857522</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:ogc_fid>1</ms:ogc_fid>
<ms:name>Bordeaux</ms:name>
<ms:id>124</ms:id>
</ms:point>
</gml:featureMember>
<gml:featureMember>
<ms:point fid="2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.021418,45.477577 -0.021418,45.477577</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-0.021418,45.477577</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:ogc_fid>2</ms:ogc_fid>
<ms:name>Barbezieux</ms:name>
<ms:id>0</ms:id>
</ms:point>
</gml:featureMember>
</wfs:FeatureCollection>

89
examples/gml/polygon.xml Normal file
View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://mapserver.gis.umn.edu/mapserver http://aneto.oco/cgi-bin/worldwfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=polygon&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.768746,47.003018 3.002191,47.925567</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:polygon fid="1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.768746,47.003018 0.532597,47.925567</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPolygon srsName="EPSG:4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>-0.318987,47.003018 -0.768746,47.358268 -0.574463,47.684285 -0.347374,47.854602 -0.006740,47.925567 0.135191,47.726864 0.149384,47.599127 0.419052,47.670092 0.532597,47.428810 0.305508,47.443003 0.475824,47.144948 0.064225,47.201721 -0.318987,47.003018 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>-0.035126,47.485582 -0.035126,47.485582 -0.049319,47.641706 -0.233829,47.655899 -0.375760,47.457196 -0.276408,47.286879 -0.035126,47.485582 </gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</ms:msGeometry>
<ms:ogc_fid>1</ms:ogc_fid>
<ms:name>My Polygon with hole</ms:name>
<ms:id>0</ms:id>
</ms:polygon>
</gml:featureMember>
<gml:featureMember>
<ms:polygon fid="2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>1.511919,47.088176 3.002191,47.882988</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Polygon srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>1.625463,47.357844 1.511919,47.741057 1.880938,47.882988 2.420275,47.797830 2.789295,47.485582 3.002191,47.457196 2.874453,47.088176 2.178993,47.343651 1.625463,47.357844 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ms:msGeometry>
<ms:ogc_fid>2</ms:ogc_fid>
<ms:name>My simple Polygon</ms:name>
<ms:id>0</ms:id>
</ms:polygon>
</gml:featureMember>
<gml:featureMember>
<ms:polygon fid="3">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>0.000000,45.000000 2.000000,47.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:MultiPolygon srsName="EPSG:4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>0.000000,45.000000 2.000000,45.000000 2.000000,47.000000 0.000000,47.000000 0.000000,45.000000 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
<gml:innerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>0.500000,45.500000 1.500000,45.500000 1.500000,46.500000 0.500000,46.500000 0.500000,45.500000 </gml:coordinates>
</gml:LinearRing>
</gml:innerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</ms:msGeometry>
<ms:ogc_fid>3</ms:ogc_fid>
<ms:name>my polygon with hole</ms:name>
<ms:id>3</ms:id>
</ms:polygon>
</gml:featureMember>
</wfs:FeatureCollection>

View File

@@ -0,0 +1,32 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.addLayer(new OpenLayers.Layer.GML("KML", "kml/lines.kml", {format: OpenLayers.Format.KML}));
map.zoomToExtent(new OpenLayers.Bounds(-112.292744,36.068477,-112.22408,36.109246));
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

32
examples/kml-layer.html Normal file
View File

@@ -0,0 +1,32 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.addLayer(new OpenLayers.Layer.GML("KML", "kml/mc-search.kml", {format: OpenLayers.Format.KML}));
map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

267
examples/kml/lines.kml Normal file
View File

@@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<name>KML Samples</name>
<open>1</open>
<description>Unleash your creativity with the help of these examples!</description>
<Style id="downArrowIcon">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon28.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="globeIcon">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal3/icon19.png</href>
</Icon>
</IconStyle>
<LineStyle>
<width>2</width>
</LineStyle>
</Style>
<Style id="transPurpleLineGreenPoly">
<LineStyle>
<color>7fff00ff</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<Style id="yellowLineGreenPoly">
<LineStyle>
<color>7f00ffff</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<Style id="thickBlackLine">
<LineStyle>
<color>87000000</color>
<width>10</width>
</LineStyle>
</Style>
<Style id="redLineBluePoly">
<LineStyle>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<color>ffff0000</color>
</PolyStyle>
</Style>
<Style id="blueLineRedPoly">
<LineStyle>
<color>ffff0000</color>
</LineStyle>
<PolyStyle>
<color>ff0000ff</color>
</PolyStyle>
</Style>
<Style id="transRedPoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d0000ff</color>
</PolyStyle>
</Style>
<Style id="transBluePoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7dff0000</color>
</PolyStyle>
</Style>
<Style id="transGreenPoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d00ff00</color>
</PolyStyle>
</Style>
<Style id="transYellowPoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d00ffff</color>
</PolyStyle>
</Style>
<Style id="noDrivingDirections">
<BalloonStyle>
<text><![CDATA[
<b>$[name]</b>
<br /><br />
$[description]
]]></text>
</BalloonStyle>
</Style>
<Folder>
<name>Paths</name>
<visibility>0</visibility>
<description>Examples of paths. Note that the tessellate tag is by default
set to 0. If you want to create tessellated lines, they must be authored
(or edited) directly in KML.</description>
<Placemark>
<name>Tessellated</name>
<visibility>0</visibility>
<description><![CDATA[If the <tessellate> tag has a value of 1, the line will contour to the underlying terrain]]></description>
<LookAt>
<longitude>-112.0822680013139</longitude>
<latitude>36.09825589333556</latitude>
<altitude>0</altitude>
<range>2889.145007690472</range>
<tilt>62.04855796276328</tilt>
<heading>103.8120432044965</heading>
</LookAt>
<LineString>
<tessellate>1</tessellate>
<coordinates> -112.0814237830345,36.10677870477137,0
-112.0870267752693,36.0905099328766,0 </coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Untessellated</name>
<visibility>0</visibility>
<description><![CDATA[If the <tessellate> tag has a value of 0, the line follow a simple straight-line path from point to point]]></description>
<LookAt>
<longitude>-112.0822680013139</longitude>
<latitude>36.09825589333556</latitude>
<altitude>0</altitude>
<range>2889.145007690472</range>
<tilt>62.04855796276328</tilt>
<heading>103.8120432044965</heading>
</LookAt>
<LineString>
<tessellate>0</tessellate>
<coordinates> -112.080622229595,36.10673460007995,0
-112.085242575315,36.09049598612422,0 </coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Absolute</name>
<visibility>0</visibility>
<description>Transparent purple line</description>
<LookAt>
<longitude>-112.2719329043177</longitude>
<latitude>36.08890633450894</latitude>
<altitude>0</altitude>
<range>2569.386744398339</range>
<tilt>44.60763714063257</tilt>
<heading>-106.8161545998597</heading>
</LookAt>
<styleUrl>#transPurpleLineGreenPoly</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates> -112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357 </coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Absolute Extruded</name>
<visibility>0</visibility>
<description>Transparent green wall with yellow outlines</description>
<LookAt>
<longitude>-112.2643334742529</longitude>
<latitude>36.08563154742419</latitude>
<altitude>0</altitude>
<range>4451.842204068102</range>
<tilt>44.61038665812578</tilt>
<heading>-125.7518698668815</heading>
</LookAt>
<styleUrl>#yellowLineGreenPoly</styleUrl>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates> -112.2550785337791,36.07954952145647,2357
-112.2549277039738,36.08117083492122,2357
-112.2552505069063,36.08260761307279,2357
-112.2564540158376,36.08395660588506,2357
-112.2580238976449,36.08511401044813,2357
-112.2595218489022,36.08584355239394,2357
-112.2608216347552,36.08612634548589,2357
-112.262073428656,36.08626019085147,2357
-112.2633204928495,36.08621519860091,2357
-112.2644963846444,36.08627897945274,2357
-112.2656969554589,36.08649599090644,2357 </coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Relative</name>
<visibility>0</visibility>
<description>Black line (10 pixels wide), height tracks terrain</description>
<LookAt>
<longitude>-112.2580438551384</longitude>
<latitude>36.1072674824385</latitude>
<altitude>0</altitude>
<range>2927.61105910266</range>
<tilt>44.61324882043339</tilt>
<heading>4.947421249553717</heading>
</LookAt>
<styleUrl>#thickBlackLine</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates> -112.2532845153347,36.09886943729116,645
-112.2540466121145,36.09919570465255,645
-112.254734666947,36.09984998366178,645
-112.255493345654,36.10051310621746,645
-112.2563157098468,36.10108441943419,645
-112.2568033076439,36.10159722088088,645
-112.257494011321,36.10204323542867,645
-112.2584106072308,36.10229131995655,645
-112.2596588987972,36.10240001286358,645
-112.2610581199487,36.10213176873407,645
-112.2626285262793,36.10157011437219,645 </coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Relative Extruded</name>
<visibility>0</visibility>
<description>Opaque blue walls with red outline, height tracks terrain</description>
<LookAt>
<longitude>-112.2683594333433</longitude>
<latitude>36.09884362144909</latitude>
<altitude>0</altitude>
<range>2184.193522571467</range>
<tilt>44.60855445139561</tilt>
<heading>-72.24271551768405</heading>
</LookAt>
<styleUrl>#redLineBluePoly</styleUrl>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates> -112.2656634181359,36.09445214722695,630
-112.2652238941097,36.09520916122063,630
-112.2645079986395,36.09580763864907,630
-112.2638827428817,36.09628572284063,630
-112.2635746835406,36.09679275951239,630
-112.2635711822407,36.09740038871899,630
-112.2640296531825,36.09804913435539,630
-112.264327720538,36.09880337400301,630
-112.2642436562271,36.09963644790288,630
-112.2639148687042,36.10055381117246,630
-112.2626894973474,36.10149062823369,630 </coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>

332
examples/kml/mc-search.kml Normal file
View File

@@ -0,0 +1,332 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<!--MetaCarta GTS v3.7.0, KML Search API v1.0.0-->
<name><![CDATA[MetaCarta: ]]></name>
<description><![CDATA[Labeling <b>28</b> locations. Of 27,281,538 total documents, <b>~26,900,000</b> documents match <i>&lt;no keywords&gt;</i> in this region.]]></description>
<visibility>1</visibility>
<LookAt>
<longitude>-82.575000</longitude>
<latitude>27.498610</latitude>
<range>6000000.0</range>
<tilt>0.0</tilt>
<heading>0.0</heading>
</LookAt>
<Style id="rel1.0">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc1.0.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.9">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.9.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.8">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.8.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.7">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.7.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.6">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.6.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.5">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.5.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.4">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.4.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.3">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.3.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.2">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.2.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.1">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.1.png</href>
</Icon>
</IconStyle>
</Style>
<Style id="rel0.0">
<IconStyle>
<Icon>
<href>http://developers.metacarta.com/img/symbols/mc0.0.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<!-- OGM5MmVhYTI3MTRkNzY2NDQ5YzgzMjBkYzQ3M2Q1YzYsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzBfMTE2MzYyMjk0MV8xMTcyNjg1ODk5XzAwOjE4OjhiOjM4OjM2OjQ3LDE2NjI2ODQ=, 0.959452 -->
<name><![CDATA[Bradenton]]></name>
<description><![CDATA[<a href="http://www.fhp.state.fl.us/html/TroopF/Bradenton.html">FHP: Troop F Bradenton District</a><br>FHP: Troop F <font color="red">Bradenton</font> District Bradento<br>FHP: Troop F Bradenton District Bradenton District The Bradenton District is located at Troop F Headquarters and includes all of Manatee County. The Bradenton District ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-82.575000, 27.498610</coordinates>
</Point>
</Placemark><Placemark>
<!-- N2M0OTk4NzMxMWFjOGQ1MzgwY2NmNzBlOWIzODg3OGYsdW1icm86MTYxMzlfMTE2OTg0MDM4MV8xMTY5ODQ1MDQ5XzAwOjE4OjhiOjNhOjcwOmZkLDE4NTQzNw==, 0.959452 -->
<name><![CDATA[Pezinok]]></name>
<description><![CDATA[<a href="http://en.wikipedia.org/wiki/Pezinok"> Pezinok</a><br><font color="red">Pezinok</font> Coor titl<br>Pezinok Coor title dm4616N1716Etype:cityregion:SK Infobox Slovak town image_coat_of_arms subject_name Pezinok slovak_region Bratislava Region slovak_district ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>17.266666, 48.283333</coordinates>
</Point>
</Placemark><Placemark>
<!-- MzE1OWQ0MTUwNTUzOGQxODBiNGYwZjU3MThmYzMwY2IsanVsaWEubWV0YWNhcnRhLmNvbToxNjAzNl8xMTYzNjM0MjI4XzExNjU5Nzk3MTVfMDA6MTg6OGI6MzU6MDA6ZGMsNzQ3MzQ2, 0.959452 -->
<name><![CDATA[Purcellville]]></name>
<description><![CDATA[<a href="http://www.loudoun.gov:80/compplan/purcellville.htm">Purcellville Urban Growth Area Management Plan</a><br><font color="red">Purcellville</font> Urban Growth Are<br>Purcellville Urban Growth Area Management Plan Skip Navigation Purcellville Urban Growth Area Management Plan Welcome to the Purcellville Urban Growth Area Management ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-77.715000, 39.136670</coordinates>
</Point>
</Placemark><Placemark>
<!-- N2UxY2EwYzY0YzBhMTAzNTg1NWFkY2YzZWU2NjdhZWIsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSw5MzY1NDI=, 0.958984 -->
<name><![CDATA[Calaveras County]]></name>
<description><![CDATA[<a href="http://www.co.calaveras.ca.us:80/departments/pub_health/PHD_WNV.html">Calaveras County Public Health</a><br><font color="red">Calaveras County</font> Public Healt<br>Calaveras County Public Health County of Calaveras Public Health Department West Nile Virus (WNV) WNV is a disease that is spread to ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-120.583330, 38.166670</coordinates>
</Point>
</Placemark><Placemark>
<!-- ZWFhZDJkYTk0MmNlMWU4Yzc1OWViODIyYzU5ZGE4ZDcsdW1icm86MTYxNDFfMTE2OTg0ODM4M18xMTY5ODUxMDgxXzAwOjE4OjhiOjNhOjcwOmZkLDUxNTIw, 0.958964 -->
<name><![CDATA[Kolkata]]></name>
<description><![CDATA[<a href="http://en.wikipedia.org/wiki/Kolkata_Film_Festival"> Kolkata Film Festival</a><br><font color="red">Kolkata</font> Film Festiva<br>Kolkata Film Festival '''Kolkata Film Festival''' is an annual international film festival held in Kolkata in the Indian state of West Bengal ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>88.369722, 22.569722</coordinates>
</Point>
</Placemark><Placemark>
<!-- ZDhiYjJhNTZlNmM1ZGU4YjAzOWZiNTc5NzAxM2RlNWYsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzJfMTE2MzY4NTU2MV8xMTcyNjg1OTAyXzAwOjE4OjhiOjM4OjM2OjQ3LDk2NTMxOA==, 0.958964
ZDEwNjIwYTdjMjc2MmM4MDQ3NWNjYTY0ZWVjZDI4MjAsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzBfMTE2MzYyMjk0MV8xMTcyNjg1ODk5XzAwOjE4OjhiOjM4OjM2OjQ3LDMwNTU0OQ==, 0.958475
YmVjMjRjZTYxZDJhYjMyYTE3MjY0YzNkNTg4ODMyYzIsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAwXzExNjM2MzI4MDhfMTE2NzM0NjY3Ml8wMDoxODo4YjozODozNjo3OSw4ODg2Mw==, 0.958475 -->
<name><![CDATA[South Yorkshire]]></name>
<description><![CDATA[<a href="http://www.southyorkshire.nhs.uk:80/strategy/index.htm">South Yorkshire Strategic Health Authority - Events - Deliver...</a><br><font color="red">South Yorkshire</font> Strategic Healt<br>South Yorkshire Strategic Health Authority - Events - Delivering Excellence event 12th June 2003 Welcome What's new Local services Performance --&gt; Strategy Service redesign ...<br><br><a href="http://www.southyorkshire.nhs.uk:80/">South Yorkshire Strategic Health Authority - Welcome</a><br><font color="red">South Yorkshire</font> Strategic Healt<br>South Yorkshire Strategic Health Authority - Welcome --&gt; Welcome What's new Local services Performance --&gt; Strategy Service redesign Franchise plan Local delivery plan Structure ...<br><br><a href="http://www.southyorkshire.nhs.uk:80/index.html">South Yorkshire Strategic Health Authority - Welcome</a><br><font color="red">South Yorkshire</font> Strategic Healt<br>South Yorkshire Strategic Health Authority - Welcome --&gt; Welcome What's new Local services Performance --&gt; Strategy Service redesign Franchise plan Local delivery plan Structure ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-1.250000, 53.450000</coordinates>
</Point>
</Placemark><Placemark>
<!-- MWE4NWQ2N2U4ZmI3MDk5MjNiNmJlYzE4NzMxOTdhOTIsanVsaWEubWV0YWNhcnRhLmNvbToxNjUyNF8xMTY5ODQzMzQ1XzExNjk4NDg2OTRfMDA6MTg6OGI6MzU6MDA6ZGMsNTI1OTcx, 0.958964
ZDZjY2I2Mjk2OTNmMmVjMGJhMzY1NTIyMGEzZGZjYTQsanVsaWEubWV0YWNhcnRhLmNvbToxNjUwMl8xMTY5ODMwMDU5XzExNjk4MzU0MThfMDA6MTg6OGI6MzU6MDA6ZGMsMjMwNjQw, 0.958475 -->
<name><![CDATA[Gaithersburg]]></name>
<description><![CDATA[<a href="http://alert.gaithersburgmd.gov/faq.php">Frequently Asked Questions</a><br>What is Alert <font color="red">Gaithersburg</font>? What is an Aler<br>... email address password Lost password? Gaithersburg Home Alert Home New User Learn More FAQ Support Frequently Asked Questions What is Alert Gaithersburg? What is an Alert Gaithersburg account? How does Alert Gaithersburg work? Will my cell phone work? What is text messaging and ...<br><br><a href="http://alert.gaithersburgmd.gov/index.php?CCheck=1">Alert Gaithersburg</a><br>Alert <font color="red">Gaithersburg</font> USER LOGIN emai<br>Alert Gaithersburg USER LOGIN email address password Lost password? Gaithersburg Home Alert Home New User Learn More FAQ Support This application requires Javascript ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-77.201670, 39.143330</coordinates>
</Point>
</Placemark><Placemark>
<!-- ZjQ4MDJjN2FiNzMxNjk3NzNkN2ZhNDQzZDk5OTkxYTgsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzJfMTE2MzY4NTU2MV8xMTcyNjg1OTAyXzAwOjE4OjhiOjM4OjM2OjQ3LDU4OTU1Mw==, 0.958964 -->
<name><![CDATA[Pocatello]]></name>
<description><![CDATA[<a href="http://www.idahoparks.org/about/permits/bannock_ski.html">Bannock</a><br>Cycle 404 S Arthur <font color="red">Pocatello</font> 232.3711 City o<br>Bannock Bannock County Gateway Cycle 404 S Arthur Pocatello 232.3711 City of Pocatello 902 Sherman St Pocatello 234.6237 ISU Outdoor Program Student Union Bldg Pocatello 236.3912 The ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-112.444720, 42.871390</coordinates>
</Point>
</Placemark><Placemark>
<!-- MjY4NTdkZmI2NWU3YjFiNGY3MzExZTY5N2FlYTVhMGYsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzNfMTE2MzY5OTA3OF8xMTcyNjg1OTAyXzAwOjE4OjhiOjM4OjM2OjQ3LDMwNjE2, 0.958964 -->
<name><![CDATA[le Cambodge]]></name>
<description><![CDATA[<a href="http://www.who.int/www.who.int/mediacentre/news/releases/2004/pr46/fr/index.html">OMS | Avec 75 % des enfants protA<74>gA<67>s contre les parasites, ...</a><br>les parasites, <font color="red">le Cambodge</font> est le premier pay<br>OMS | Avec 75 % des enfants protA<74>gA<67>s contre les parasites, le Cambodge est le premier pays A<> atteindre l'objectif Ensemble de l'OMS Ce site seulement Page d'accueil OMS Pays ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>105.000000, 13.000000</coordinates>
</Point>
</Placemark><Placemark>
<!-- N2Y2NTdhYmM5MzExOTgwZDc1ODFiZTk2MDMyZmMxN2UsanVsaWEubWV0YWNhcnRhLmNvbToxNjQ5MV8xMTY5ODIzMzkxXzExNjk4MjkyMDJfMDA6MTg6OGI6MzU6MDA6ZGMsNDIyNTIw, 0.958964 -->
<name><![CDATA[firenze]]></name>
<description><![CDATA[<a href="http://groups.google.it:80/group/italia.firenze.discussioni/browse_thread/thread/39c8b8700af2691b/b53d680269651f65#b53d680269651f65">Google Gruppi : italia.firenze.discussioni</a><br>Gruppi : italia.<font color="red">firenze</font>.discussioni Hom<br>Google Gruppi : italia.firenze.discussioni Home page di Gruppi | Guida | Entra Web Immagini Gruppi Directory News altro <20> Ricerca avanzata nei Gruppi Preferenze Membri: Entra ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>11.250000, 43.766666</coordinates>
</Point>
</Placemark><Placemark>
<!-- YTU5NzdlYmNkNmUzYWM4MTQzODY4MjFiMmQ5OWQzMzIsanVsaWEubWV0YWNhcnRhLmNvbToxNjUxM18xMTY5ODM2NjAxXzExNjk4NDIzNzZfMDA6MTg6OGI6MzU6MDA6ZGMsNDU2NjYz, 0.958475
ZDNlZTdjNTM1OTRhOTk5MDUyMjAzNzIwMGMxNGQ3NWMsa3VwYS5tZXRhY2FydGEuY29tOjE2MDE1XzExNjQ1MTMzODRfMTE2NzM0NjY3NV8wMDoxODo4YjozODozNjo3OSwyOTgyOTU=, 0.958964
MDVhNjNkMGUxMzZlODMwNGRjNTViZGJhOTdiYWRmZjksanVsaWEubWV0YWNhcnRhLmNvbToxNjAzNl8xMTYzNjM0MjI4XzExNjU5Nzk3MTVfMDA6MTg6OGI6MzU6MDA6ZGMsMzk5MzY3, 0.958475
OWEwOTE2NWYyZGM1ZDkwNTI3MWE0YzBhNjI3MTdlODUsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSw1MTY4MjU=, 0.958475
MDEwNmJhOTFlMGFhM2Q0OTUxYmUxNTRlZTU4MjViYjEsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSw1MjI4MTk=, 0.958475
Zjk1MzY0ZmQ0OTc5ODgwOTQ1MWVjYzM3ZTEzYjFhYTEsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSw0Njc3OTE=, 0.958475
YjZmZWIzZTc5MGI5N2MwM2MyYTE5ZWM1NDk1MTdmZDUsanVsaWEubWV0YWNhcnRhLmNvbToxNjUwMl8xMTY5ODMwMDU5XzExNjk4MzU0MThfMDA6MTg6OGI6MzU6MDA6ZGMsMTkxMDcx, 0.958964 -->
<name><![CDATA[Fairfax County]]></name>
<description><![CDATA[<a href="http://www.fairfaxcounty.gov:80/demogrph/emplbut.htm">Employment Statistics & Information - Fairfax County, Virginia</a><br>Information - <font color="red">Fairfax County</font>, Virginia Busines<br>Employment Statistics & Information - Fairfax County, Virginia Business & Nonresidential Gross Floor Area Census Information & Other Government Agencies Economic Information Employment Information General Overview Glossary Housing Immigration ...<br><br><a href="http://www.fairfaxcounty.gov:80/contact/search.asp">Search Fairfax County Contacts - Fairfax County, Virginia</a><br>Search <font color="red">Fairfax County</font> Contacts - Fairfa<br>Search Fairfax County Contacts - Fairfax County, Virginia Search Fairfax County Contacts you are here : homepage &gt; fairfax county contacts To search for an agency ...<br><br><a href="http://www.fairfaxcounty.gov:80/demogrph/othrbut.htm">Other Information - Fairfax County, Virginia</a><br>Information - <font color="red">Fairfax County</font>, Virginia Averag<br>Other Information - Fairfax County, Virginia Average Household Size Health Insurance Age Distribution Persons Speaking Languages Other than English Prior Place of Residence Educational Attainment ...<br><br><a href="http://www.fairfaxcounty.gov:80/demogrph/housebut.htm">Housing Information - Fairfax County, Virginia</a><br>Information - <font color="red">Fairfax County</font>, Virginia Busines<br>Housing Information - Fairfax County, Virginia Business & Nonresidential Gross Floor Area Census Information & Other Government Agencies Economic Information Employment Information General Overview Glossary Housing Immigration ...<br><br><a href="http://www.fairfaxcounty.gov:80/demogrph/popbut.htm">Population Information - Fairfax County, Virginia</a><br>Information - <font color="red">Fairfax County</font>, Virginia Busines<br>Population Information - Fairfax County, Virginia Business & Nonresidential Gross Floor Area Census Information & Other Government Agencies Economic Information Employment Information General Overview Glossary Housing Immigration ...<br><br><a href="http://www.fairfaxcounty.gov:80/business/services/">Business Services and Resources - Doing Business - Fairfax Co...</a><br>Doing Business - <font color="red">Fairfax County</font>, Virginia Busines<br>Business Services and Resources - Doing Business - Fairfax County, Virginia Business Services & Resources you are here : homepage &gt; doing business &gt; business services and resources Fairfax County has a diverse and ...<br><br><a href="http://www.fairfaxcounty.gov/contact/search.asp">Search Fairfax County Contacts - Fairfax County, Virginia</a><br>Search <font color="red">Fairfax County</font> Contacts - Fairfa<br>Search Fairfax County Contacts - Fairfax County, Virginia Search Fairfax County Contacts you are here : homepage &gt; fairfax county contacts To search for an agency ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-77.350000, 38.850000</coordinates>
</Point>
</Placemark><Placemark>
<!-- Mjg2NGM5N2YzNmYyNGFlZmQ0ZjE5N2Y4ZDBmNzFkMzIscGxhdmlzLm1ldGFjYXJ0YS5jb206MTY2NzNfMTE3MzU3NTg2MF8xMTczNTc4MTgwXzAwOjE4OjhiOjNhOjNkOjQwLDIyODM5NA==, 0.958964 -->
<name><![CDATA[Nassau Bahamas]]></name>
<description><![CDATA[<a href="http://topix.net/r/05j525XYQmo8VlBBUPUWa9G9bOa4kVTdx1LNqTqvWxejdQKhnOECcVfVuSMlxL3OXjYCfywPCSSyfl9UdTX6h1yipv285=2Fc6S3ylpt=2BXwfI1uhZS8L=2BM4gKSAUReNk868Hwh3guBbo1qfQ0=2B3LQrtt7d7LDiFk3qO1TN1RWjhlpU=3D">Nassau Bahamas Vacation <20> Crawfish Production Declines In The...</a><br><font color="red">Nassau Bahamas</font> Vacation <20> Crawfis<br>Nassau Bahamas Vacation <20> Crawfish Production Declines In The Bahamas Nassau Bahamas Vacation Crawfish Production Declines In The Bahamas June 15, 2006 ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-77.350000, 25.083333</coordinates>
</Point>
</Placemark><Placemark>
<!-- OWNkOGUyZGEyNGJiODcxYWVmODUwMWE0MzcwY2MxMzksZWxiZS5tZXRhY2FydGEuY29tOjE2MDYzXzExNzI3ODU1NDNfMTE3Mjc5MzIyOF8wMDoxODo4YjozNzpmZDo1YSwxMzI1ODU=, 0.958964 -->
<name><![CDATA[Front Royal]]></name>
<description><![CDATA[<a href="https://yosemite.epa.gov/opei/ptrack.nsf/vRenewalViewPrintView/B72E7B83510A37AC8525718E0051F7C3">Membership Renewal Print/View</a><br>Application DuPont <font color="red">Front Royal</font> E.I. Du Pont d<br>Membership Renewal Print/View OMB No. 2010-0032 Expiration Date 08/30/06 Performance Track Membership Renewal Application DuPont Front Royal E.I. Du Pont de Nemours and Company, Inc. Member since 2002 A030029 Facility Contact &nbsp&nbsp Name: Mr. James ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-78.194720, 38.918060</coordinates>
</Point>
</Placemark><Placemark>
<!-- NTNjNzZkNWY4NzNmY2JlNTY2ZGRjNTRiYjU3N2IwNDEsanVsaWEubWV0YWNhcnRhLmNvbToxNjAzNl8xMTYzNjM0MjI4XzExNjU5Nzk3MTVfMDA6MTg6OGI6MzU6MDA6ZGMsMTU5MDI1, 0.957987
N2FjZGY0YzM2ZTU4NzE1Y2Q2MGVmNmQ0ZjZkYjI3MjUsanVsaWEubWV0YWNhcnRhLmNvbToxNjAzNl8xMTYzNjM0MjI4XzExNjU5Nzk3MTVfMDA6MTg6OGI6MzU6MDA6ZGMsMzM2MTAz, 0.958475 -->
<name><![CDATA[WESTCHESTER COUNTY]]></name>
<description><![CDATA[<a href="http://schumer.senate.gov:80/SchumerWebsite/pressroom/press_releases/PR01140.html">SCHUMER, CLINTON SECURE $1.5 MILLION FOR NEW BUSES IN WESTCHE...</a><br>FOR NEW BUSES IN <font color="red">WESTCHESTER COUNTY</font> TOPICS Latest New<br>SCHUMER, CLINTON SECURE $1.5 MILLION FOR NEW BUSES IN WESTCHESTER COUNTY TOPICS Latest News Press Release Archive Special Reports Photo Downloads Schumer Around NY About Chuck | Senate Floor | Press Room | Services ...<br><br><a href="http://schumer.senate.gov:80/SchumerWebsite/pressroom/press_releases/PR01996.html">SCHUMER, CLINTON SECURE $3 MILLION FOR NEW BUSES IN WESTCHEST...</a><br>FOR NEW BUSES IN <font color="red">WESTCHESTER COUNTY</font> TOPICS Latest New<br>SCHUMER, CLINTON SECURE $3 MILLION FOR NEW BUSES IN WESTCHESTER COUNTY TOPICS Latest News Press Release Archive Special Reports Photo Downloads Schumer Around NY About Chuck | Senate Floor | Press Room | Services ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-73.800000, 41.116670</coordinates>
</Point>
</Placemark><Placemark>
<!-- ZWQwMTUwYjI4N2ZlZTg4MmI4N2EyZTU5YjU1ZjlkMjMsa3VwYS5tZXRhY2FydGEuY29tOjE2OTI0XzExNzM1NzA1NzBfMTE3MzU3NTk0Nl8wMDoxODo4YjozODozNjo3OSwyODYzOTE=, 0.958475
YzBlZGZhY2IxOGNkNmEyNzI3OWEwZTNkNjRhM2Q4MGYsanVsaWEubWV0YWNhcnRhLmNvbToxNjUwMl8xMTY5ODMwMDU5XzExNjk4MzU0MThfMDA6MTg6OGI6MzU6MDA6ZGMsNTQzMDk4, 0.957987 -->
<name><![CDATA[Oswego County]]></name>
<description><![CDATA[<a href="http://www.valleynewsonline.com:80/news/2004/0117/Oswego_News/">Restaurant makes donation to Friends of Oswego County Hospice</a><br>to Friends of <font color="red">Oswego County</font> Hospice Fulton, N<br>Restaurant makes donation to Friends of Oswego County Hospice Fulton, NY Front Page Viewpoints Hannibal News Phoenix News Oswego News Local News & Photos Obituaries Entertainment and Arts Church ...<br><br><a href="http://www.valleynewsonline.com:80/news/2004/0925/Local_News-Photos/030.html">Fund-raiser held for Oswego County Hospice</a><br>raiser held for <font color="red">Oswego County</font> Hospice Fulton, N<br>Fund-raiser held for Oswego County Hospice Fulton, NY Front Page Viewpoints Hannibal News Phoenix News Oswego News Local News & Photos Obituaries Entertainment and Arts Church ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-76.150000, 43.450000</coordinates>
</Point>
</Placemark><Placemark>
<!-- NjE2OTE2N2U3ZDlmZGFkMTkzYWYzNjViZjQ2OGNlODcsa3VwYS5tZXRhY2FydGEuY29tOjE2NDI5XzExNjk4NzA4OTNfMTE2OTg3NjQyNl8wMDoxODo4YjozODozNjo3OSw1NzEzMzk=, 0.958475 -->
<name><![CDATA[Hood River Memorial Hospital]]></name>
<description><![CDATA[<a href="http://www.providence.org:80/hoodriver/foundation/default.htm">Providence Hood River Memorial Hospital Foundation</a><br>Providence <font color="red">Hood River Memorial Hospital</font> Foundatio<br>Providence Hood River Memorial Hospital Foundation Healthwise Medical Reference Library --&gt; Home | Services | Physicians & Clinics | Education | Patient Information | News & Events | Foundation | Employment Site Search ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-121.523610, 45.704720</coordinates>
</Point>
</Placemark><Placemark>
<!-- YTQwNjQwNzM4YTEzMzFiN2Q5YzExZTlkMWMxMGZmZTgsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzRfMTE2MzcxNDQ4OF8xMTcyNjg1OTAzXzAwOjE4OjhiOjM4OjM2OjQ3LDY2ODQzNA==, 0.958475 -->
<name><![CDATA[Leavenworth County]]></name>
<description><![CDATA[<a href="http://leavenworthcounty.redcross.org/PR17jan01.htm">ARC-Leavworth County: Press Release January 17, 2001</a><br>January 17, 2001 <font color="red">Leavenworth County</font> Chapter Return t<br>ARC-Leavworth County: Press Release January 17, 2001 Press Release January 17, 2001 Leavenworth County Chapter Return to Media Page APPLICATIONS FOR NEW GAS ASSISTANCE PROGRAM NOW AVAILABLE THROUGH THE AMERICAN RED CROSS LEAVENWORTH - The ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-95.033330, 39.233330</coordinates>
</Point>
</Placemark><Placemark>
<!-- YzhhNTNkZDlmMzFhMDA2NGM4NzExNTNiMTIyYzg2MTUsdW1icm86MTY0ODlfMTE3MTk5Nzc3OV8xMTcyMDAwOTQwXzAwOjE4OjhiOjNhOjcwOmZkLDYwNTU4, 0.958475 -->
<name><![CDATA[Blancheville]]></name>
<description><![CDATA[<a href="http://en.wikipedia.org/wiki/Andelot-Blancheville"> Andelot-Blancheville</a><br>Andelot-<font color="red">Blancheville</font> French commun<br>Andelot-Blancheville French commune nomcommuneAndelot-Blancheville rA<72>gionChampagne-Ardenne dA<64>partementHaute-Marne arrondissementChaumont cantonCanton of Andelot-BlanchevilleAndelot-Blancheville insee52008 cp52700 maire mandat intercomm longitude05A<35> 17 ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>5.266666, 48.216666</coordinates>
</Point>
</Placemark><Placemark>
<!-- YTBlMTIwMTVhYTUyNTlkYTM5MDI3ZGQ2NDk2N2QzYzYsa3VwYS5tZXRhY2FydGEuY29tOjE2NDI5XzExNjk4NzA4OTNfMTE2OTg3NjQyNl8wMDoxODo4YjozODozNjo3OSwzMzUwMjM=, 0.958475 -->
<name><![CDATA[Platte City]]></name>
<description><![CDATA[<a href="http://www.plattecountylandmark.com:80/Article371.htm">The Landmark Newspaper - Platte County (Platte City wants str...</a><br>Platte County (<font color="red">Platte City</font> wants stree<br>The Landmark Newspaper - Platte County (Platte City wants street sweeping grant) Covering Platte County, Missouri Weekly Since 1865 Local News Between the Lines by Ivan Foley Off ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-94.782220, 39.370280</coordinates>
</Point>
</Placemark><Placemark>
<!-- NzY0NTY1YzZjNzE5MTViYjU1NmNmMTJjYjc5NDdjMGEsanVsaWEubWV0YWNhcnRhLmNvbToxNjUxM18xMTY5ODM2NjAxXzExNjk4NDIzNzZfMDA6MTg6OGI6MzU6MDA6ZGMsNjA0NTE2, 0.958475 -->
<name><![CDATA[Macomb County]]></name>
<description><![CDATA[<a href="http://macombdaily.com:80/stories/080404/loc_antosk001.shtml">Macomb Daily : Sports : Retiring juvenile court worker an 'in...</a><br>an 'institution in <font color="red">Macomb County</font>' 08/04/04 SUBSCRIB<br>Macomb Daily : Sports : Retiring juvenile court worker an 'institution in Macomb County' 08/04/04 SUBSCRIBE TO SITE MENU: Select... HOME Local News State/Nation/World Sports Obituaries Election Center Newspaper In ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-82.950000, 42.700000</coordinates>
</Point>
</Placemark><Placemark>
<!-- NzUxNjI3MGNjZjg4OTEzMGEwMDU4YzQ2ZTQ5ZjM3MjAsdW1icm86MTY0ODlfMTE3MTk5Nzc3OV8xMTcyMDAwOTQwXzAwOjE4OjhiOjNhOjcwOmZkLDE0NDIxMA==, 0.958475 -->
<name><![CDATA[Voronezh]]></name>
<description><![CDATA[<a href="http://en.wikipedia.org/wiki/FC_Fakel_Voronezh"> FC Fakel Voronezh</a><br>FC Fakel <font color="red">Voronezh</font> Football clu<br>FC Fakel Voronezh Football club infobox clubname Fakel image Club logo fullname Football Club Fakel Voronezh nickname founded 1947 ground Tsentralnyi Profsoyuz StadionTsentralnyi Profsoyuz ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>39.170000, 51.666388</coordinates>
</Point>
</Placemark><Placemark>
<!-- YzkxOWI2MmRkZjYzNGFmMzY5MmNkYmJmMzUwMDkwZjEsanVsaWEubWV0YWNhcnRhLmNvbToxNjUwMl8xMTY5ODMwMDU5XzExNjk4MzU0MThfMDA6MTg6OGI6MzU6MDA6ZGMsMTYyNjk1, 0.958475 -->
<name><![CDATA[Loudoun County]]></name>
<description><![CDATA[<a href="http://www.loudoun.gov/main/new.htm">What's New in Loudoun County</a><br>What's New in <font color="red">Loudoun County</font> Skip Navigatio<br>What's New in Loudoun County Skip Navigation What's New News Releases Loudoun County in the News New on the Loudoun County Website Job Announcements ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-77.650000, 39.083330</coordinates>
</Point>
</Placemark><Placemark>
<!-- Yjc1NjQ5MjgwNTIzMTJhNjYxM2U3ZGJiYmZkNjQ4ZmEsaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzBfMTE2MzYyMjk0MV8xMTcyNjg1ODk5XzAwOjE4OjhiOjM4OjM2OjQ3LDEyMjI2NTI=, 0.958027
ZDYyZDRlMTRjYTU5ZmM0YjlhMDg4YWEzZGM4ZjUyNGUsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSwxODI2MTg=, 0.958027 -->
<name><![CDATA[San Joaquin County]]></name>
<description><![CDATA[<a href="http://www.oes.ca.gov/Operational/OESHome.nsf/PrintView/C4F1A8E5BF70A1D088256EAA00198EF3OpenDocument"> Levee Break San Joaquin County Levee Break and Fl...</a><br>Levee Break <font color="red">San Joaquin County</font> Levee Break an<br>Levee Break San Joaquin County Levee Break and Flooding The Governor's Office of Emergency Services activated the State Operations Center and the Inland ...<br><br><a href="http://www.oes.ca.gov:80/Operational/OESHome.nsf/PrintView/C4F1A8E5BF70A1D088256EAA00198EF3?OpenDocument"> Levee Break San Joaquin County Levee Break and Fl...</a><br>Levee Break <font color="red">San Joaquin County</font> Levee Break an<br>Levee Break San Joaquin County Levee Break and Flooding The Governor's Office of Emergency Services activated the State Operations Center and the Inland ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-121.300000, 37.933330</coordinates>
</Point>
</Placemark><Placemark>
<!-- YTcwMjgxMzFhYjQ5NDdiMjkzZGM0ODkwODlkNjBiOTEsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAwXzExNjM2MzI4MDhfMTE2NzM0NjY3Ml8wMDoxODo4YjozODozNjo3OSw2MzM5NDk=, 0.957987 -->
<name><![CDATA[Gibellina]]></name>
<description><![CDATA[<a href="http://www.archidose.org:80/Apr00/041700.html">Cretto</a><br>Cretto Cretto <font color="red">Gibellina</font>, Sicily Italia<br>Cretto Cretto Gibellina, Sicily Italian artist Alberto Burri is known for a series of works titled Cretti , monochrome pieces composed of paste left to ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>12.966666, 37.783333</coordinates>
</Point>
</Placemark><Placemark>
<!-- N2MwN2NjOWI2ZDhjZjNlNDFhYzhjMjAwOGYzOWNmYzgsdW1icm86MTY0ODlfMTE3MTk5Nzc3OV8xMTcyMDAwOTQwXzAwOjE4OjhiOjNhOjcwOmZkLDQ0ODAz, 0.957987 -->
<name><![CDATA[Sunnhordland]]></name>
<description><![CDATA[<a href="http://en.wikipedia.org/wiki/Stord_Sunnhordland_F.K."> Stord Sunnhordland F.K.</a><br>Stord <font color="red">Sunnhordland</font> F.K. Infobo<br>Stord Sunnhordland F.K. Infobox Football club clubname Stord Sunnhordland F.K. image logo fullname Stord Sunnhordland Fotballklubb Norwegian nickname founded December 18 ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>5.500000, 59.916666</coordinates>
</Point>
</Placemark><Placemark>
<!-- YTYyNmE1ZjQ4NjQ0MTA0MGFlZTkyZGU2OWExOTM4ODgsZWxiZS5tZXRhY2FydGEuY29tOjE2MDM5XzExNjk3NzY4NjRfMTE2OTc4NjY1Nl8wMDoxODo4YjozNzpmZDo1YSwxNTM4MTQ5, 0.957987 -->
<name><![CDATA[Zagreb]]></name>
<description><![CDATA[<a href="http://www.rwe.de/generator.aspx/icw-aqua/beteiligungen/zagrebacke-odpadne-vode-doo/language=de/id=362866/zagrebacke-odpadne-vode-doo.html">RWE Aqua - Zentralklaranlage Zagreb (ZOV)</a><br>Zentralklaranlage <font color="red">Zagreb</font> (ZOV) Home Englis<br>RWE Aqua - Zentralklaranlage Zagreb (ZOV) Home English Suchen Produkte & Services Konzern Presse/News Investor Relations Info-Welt fur Privatkunden fur Geschaftskunden fur Stadtwerke/Versorger fur ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>16.000000, 45.800000</coordinates>
</Point>
</Placemark><Placemark>
<!-- NmZlOTJiY2YwNTQzNTQ0MGRkNjhkZGQ0Y2FiN2JiMzYsa3VwYS5tZXRhY2FydGEuY29tOjE2MDAxXzExNjM2NjM1MjRfMTE2NzM0NjY3NF8wMDoxODo4YjozODozNjo3OSw3Mzc=, 0.957987 -->
<name><![CDATA[Burien]]></name>
<description><![CDATA[<a href="http://www.metrokc.gov:80/kcdot/news/2005/nr050310_burientc.htm">Open house features design ideas for new Burien Transit Center</a><br>ideas for new <font color="red">Burien</font> Transit Center DO<br>Open house features design ideas for new Burien Transit Center DOT Home What's Happening Transportation Today In the News Hot Topics Current Projects Inside Transportation on CTV Regional ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-122.345560, 47.470560</coordinates>
</Point>
</Placemark><Placemark>
<!-- NzExYjkwZThmOTI4YzQ5OThkYzg5NzJiMmQ0N2JlZjksaWJlcnVzLm1ldGFjYXJ0YS5jb206MTYwNzBfMTE2MzYyMjk0MV8xMTcyNjg1ODk5XzAwOjE4OjhiOjM4OjM2OjQ3LDEyNjk2NjI=, 0.957987 -->
<name><![CDATA[Galveston County]]></name>
<description><![CDATA[<a href="http://galvestondailynews.com/mobile/index.lasso">The Daily News: Mobile Edition</a><br>Mobile Edition The <font color="red">Galveston County</font> Daily News - MOBIL<br>The Daily News: Mobile Edition The Galveston County Daily News - MOBILE EDITION - Today is Sunday, September 25, 2005 Buses return with tired, hot evacuees GALVESTON - Some complain about ...<br><br>]]></description>
<styleUrl>#rel1.0</styleUrl>
<Point>
<coordinates>-94.966670, 29.366670</coordinates>
</Point>
</Placemark>
</Document>
</kml>

37
examples/navtoolbar.html Normal file
View File

@@ -0,0 +1,37 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
float:right;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( 'map', { controls: [new OpenLayers.Control.PanZoom()] } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
var panel = new OpenLayers.Control.NavToolbar();
map.addControl(panel);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

113
examples/openmnnd.html Normal file
View File

@@ -0,0 +1,113 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer;
function init(){
OpenLayers.ProxyHost="proxy.cgi?url=";
map = new OpenLayers.Map( $('map'), {'maxResolution':'auto', maxExtent: new OpenLayers.Bounds(-203349.72008129774,4816309.33,1154786.8041952979,5472346.5), projection: 'EPSG:26915' } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
["http://geoint.lmic.state.mn.us/cgi-bin/wms"], {layers: 'fsa'} );
map.addLayer(layer);
wfs_url = "http://prototype.openmnnd.org/cgi-bin/mapserv.exe?map=openmnndwfs/openmnndwfs.map";
wms = new OpenLayers.Layer.WMS("Minnesota Parcels (WMS)", wfs_url, {'layers':'streams', 'transparent': true, 'format':'image/gif'});
map.addLayer(wms);
wfs = new OpenLayers.Layer.WFS("Minnesota Streams (WFS)", wfs_url, {'typename':'streams'}, {ratio:1.25, minZoomLevel:4});
wfs.onFeatureInsert= function(feature) { feature.style.strokeWidth="3"; feature.style.strokeColor="blue"; feature.layer.renderer.drawGeometry(feature.geometry,feature.style); $('stream_features').innerHTML = feature.layer.features.length;}
map.addLayer(wfs);
pwfs = new OpenLayers.Layer.WFS("Minnesota Plat (WFS)", wfs_url, {'typename':'plat'}, {ratio:1.25, minZoomLevel:8, extractAttributes: true});
pwfs.onFeatureInsert= function(feature) { feature.style.fillColor="green"; feature.layer.renderer.drawGeometry(feature.geometry,feature.style); $('plat_features').innerHTML = feature.layer.features.length;}
map.addLayer(pwfs);
rwfs = new OpenLayers.Layer.WFS("Minnesota Roads (WFS)", wfs_url, {'typename':'roads'}, {ratio:1.25, minZoomLevel:7, extractAttributes: true});
rwfs.onFeatureInsert= function(feature) { feature.style.strokeColor="white"; feature.style.strokeWidth="4"; feature.layer.renderer.drawGeometry(feature.geometry,feature.style); $('road_features').innerHTML = feature.layer.features.length; }
map.addLayer(rwfs);
map.events.register('moveend', null, function() {
$('stream_features').innerHTML = "0";
$('road_features').innerHTML = "0";
$('plat_features').innerHTML = "0";
});
var ls = new OpenLayers.Control.LayerSwitcher();
map.addControl(ls);
drawControls = {
selectPlat: new OpenLayers.Control.SelectFeature(pwfs, {callbacks: {'up':feature_info,'move':feature_info_hover}}),
selectRoad: new OpenLayers.Control.SelectFeature(rwfs, {callbacks: {'up':feature_info,'move':feature_info_hover}})
};
for(var key in drawControls) {
map.addControl(drawControls[key]);
}
drawControls.selectPlat.activate();
map.zoomToExtent(new OpenLayers.Bounds(303232.550864,5082911.694856,305885.161263,5084486.682281));
}
function toggleControl(element) {
for(key in drawControls) {
var control = drawControls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}
var displayedGeom = null;
function feature_info_hover(geometry) {
if (displayedGeom != geometry &&
(!geometry.feature.layer.selectedFeatures.length ||
(geometry.feature.layer.selectedFeatures[0].geometry == geometry))) {
feature_info(geometry);
displaydGeom = geometry;
}
}
function feature_info(geometry) {
var html = "<ul>";
for(var i in geometry.feature.attributes)
html += "<li><b>" + i + "</b>: "+ geometry.feature.attributes[i] + "</li>";
html += "</ul>";
$('feature_info').innerHTML = html;
}
// -->
</script>
</head>
<body onload="init()">
<div style="right: 20px; width: 350px; position:absolute;">
<ul>
<li>Streams: Feature Count <span id="stream_features">0</span></li>
<li>Plat: Feature Count <span id="plat_features">0</span></li>
<li>Roads: Feature Count <span id="road_features">0</span></li>
</ul>
<div id="feature_info">
</div>
<ul>
<li>
<input type="radio" name="type" value="selectRoad" id="selectToggle" onclick="toggleControl(this);" />
<label for="selectToggle">select road</label>
</li>
<li>
<input type="radio" name="type" value="selectPlat" id="selectToggle" onclick="toggleControl(this);" checked=checked />
<label for="selectToggle">select polygon</label>
</li>
</ul>
</div>
<div id="map"></div>
</body>
</html>

90
examples/panel.html Normal file
View File

@@ -0,0 +1,90 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
.olControlPanel div {
display:block;
width: 24px;
height: 24px;
margin: 5px;
background-color:red;
}
.olControlPanel .olControlMouseDefaultsItemActive {
background-color: orange;
background-image: url("../../oterral/ButtonBar/vector/img/PanEnable.png");
}
.olControlPanel .olControlMouseDefaultsItemInactive {
background-color: orange;
background-image: url("../../oterral/ButtonBar/vector/img/PanDisable.png");
}
.olControlPanel .olControlDrawFeatureItemActive {
width: 22px;
height: 22px;
background-image: url("../../oterral/ButtonBar/vector/img/EditLineEnable.png");
}
.olControlPanel .olControlDrawFeatureItemInactive {
width: 22px;
height: 22px;
background-image: url("../../oterral/ButtonBar/vector/img/EditLineDisable.png");
}
.olControlPanel .olControlZoomBoxItemInactive {
width: 22px;
height: 22px;
background-color: blue;
}
.olControlPanel .olControlZoomBoxItemActive {
width: 22px;
height: 22px;
background-color: orange;
}
.olControlPanel .olControlZoomToMaxExtentItemInactive {
width: 18px;
height: 18px;
background-image: url("../img/zoom-world-mini.png");
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script src="../lib/Firebug/debug.js"></script>
<script type="text/javascript">
<!--
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( 'map', { controls: [] } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
vlayer = new OpenLayers.Layer.Vector( "Editable" );
map.addLayer(vlayer);
zb = new OpenLayers.Control.ZoomBox();
panel = new OpenLayers.Control.Panel({defaultControl: zb});
panel.addControls([
new OpenLayers.Control.MouseDefaults(),
zb,
new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path),
new OpenLayers.Control.ZoomToMaxExtent()
]);
map.addControl(panel);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="panel"></div>
<div id="map"></div>
</body>
</html>

View File

@@ -20,7 +20,8 @@ url = fs.getvalue('url', "http://openlayers.org")
# Designed to prevent Open Proxy type stuff.
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in']
allowedHosts = ['www.openlayers.org', 'openlayers.org', 'octo.metacarta.com', 'merrimack.metacarta.com', 'labs.metacarta.com', 'world.freemap.in',
'prototype.openmnnd.org']
try:
host = url.split("/")[2]

View File

@@ -0,0 +1,87 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 350px;
border: 1px solid gray;
}
#controlToggle li {
list-style: none;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, drawControls, select;
function init(){
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
map.addLayers([wmsLayer, pointLayer, lineLayer, polygonLayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
drawControls = {
point: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Point),
line: new OpenLayers.Control.DrawFeature(lineLayer,
OpenLayers.Handler.Path),
polygon: new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.Polygon),
select: new OpenLayers.Control.SelectFeature(polygonLayer)
};
for(var key in drawControls) {
map.addControl(drawControls[key]);
}
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
}
function toggleControl(element) {
for(key in drawControls) {
var control = drawControls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Draw Feature Example</h1>
<div id="map"></div>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="none" id="noneToggle"
onclick="toggleControl(this);" checked="checked" />
<label for="noneToggle">navigate</label>
</li>
<li>
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
<label for="pointToggle">draw point</label>
</li>
<li>
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
<label for="lineToggle">draw line</label>
</li>
<li>
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
<label for="polygonToggle">draw polygon</label>
</li>
<li>
<input type="radio" name="type" value="select" id="selectToggle" onclick="toggleControl(this);" />
<label for="selectToggle">select polygon</label>
</li>
</ul>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<html>
<head>
<script>
function set() {
if (document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG", "1.1") ) {
document.getElementById("svg11").style.background="green";
}
if (document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVGDOM", "1.1") ) {
document.getElementById("svgdom").style.background="green";
}
}
</script>
</head>
<body onload="set()">
Vector Support:
<br />
Supports SVG 1.1: <div id="svg11" style="width:100px;height:100px;background-color:red"></div>
<br />
Supports SVG DOM: <div id="svgdom" style="width:100px;height:100px;background-color:red"></div>
</body>
</html>

View File

@@ -0,0 +1,64 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script src="../lib/Firebug/debug.js"></script>
<script type="text/javascript">
<!--
var map;
function init(){
map = new OpenLayers.Map( $('map') );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry");
// create a point feature
var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
var pointFeature = new OpenLayers.Feature.Vector(point);
// create a line feature from a list of points
var pointList = [];
var newPoint = point;
for(var p=0; p<5; ++p) {
newPoint = new OpenLayers.Geometry.Point(newPoint.x + Math.random(1),
newPoint.y + Math.random(1));
pointList.push(newPoint);
}
var lineFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(pointList));
// create a polygon feature from a linear ring of points
var pointList = [];
for(var p=0; p<6; ++p) {
var a = p * (2 * Math.PI) / 7;
var r = Math.random(1) + 1;
var newPoint = new OpenLayers.Geometry.Point(point.x + (r * Math.cos(a)),
point.y + (r * Math.sin(a)));
pointList.push(newPoint);
}
pointList.push(pointList[0]);
var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
var polygonFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([linearRing]));
map.addLayer(vectorLayer);
map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);
vectorLayer.addFeatures([pointFeature, lineFeature, polygonFeature]);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

44
examples/webcam.html Normal file
View File

@@ -0,0 +1,44 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
p {
width: 512px;
}
#map {
width: 640px;
height: 480px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map;
function init(){
map = new OpenLayers.Map('map',
{maxExtent: new OpenLayers.Bounds(0, 0, 640, 480)});
var options = {maxResolution: 'auto', numZoomLevels: 3};
var webcam = new OpenLayers.Layer.Image(
'OL Webcam',
'http://crschmidt.net/~crschmidt/openlayers.jpg',
new OpenLayers.Bounds(0, 0, 640, 480),
new OpenLayers.Size(640, 480),
options);
map.addLayers([webcam]);
map.zoomToMaxExtent();
window.setInterval(refresh, 10000, webcam);
}
function refresh(layer) {
layer.moveTo(layer.map.getExtent(), true);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Webcam</h1>
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,79 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 100%;
height: 80%;
border: 1px solid black;
}
</style>
<title>Scribble on a WFS</title>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer;
function init(){
map = new OpenLayers.Map( $('map'), {controls: [ new OpenLayers.Control.PanZoom(), new OpenLayers.Control.Permalink() ]} );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms-c/Basic.py",
{layers: 'basic'} );
map.addLayer(layer);
layer = new OpenLayers.Layer.WFS( "Scribble WFS",
"http://dev.openlayers.org/geoserver/wfs",
{ typename: 'topp:line' },
{
typename: 'line',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
} );
map.addLayer(layer);
var p = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
df = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {handlerOptions: {'freehand': false}, 'displayClass': 'olControlDrawFeaturePath'});
df.featureAdded = function(feature) {
feature.state = OpenLayers.State.INSERT;
feature.style['strokeColor'] = "#ff0000";
feature.layer.renderer.drawGeometry(feature.geometry, feature.style);
}
p.addControls([ new OpenLayers.Control.Navigation(), df ]);
map.addControl(p);
p.activateControl(p.controls[0])
map.setCenter(new OpenLayers.LonLat(0,0), 3);
}
function save() {
for(var i = 0; i < map.layers[1].features.length; i++) {
var f = map.layers[1].features[i];
f.style['strokeColor'] = '#ee9900';
map.layers[1].renderer.drawGeometry(f.geometry, f.style);
}
map.layers[1].commit();
return false;
}
function serialize(type) {
var xmls = new XMLSerializer();
var serialize = new OpenLayers.Format[type]({},map.layers[1]);
var data = serialize.write(map.layers[1].features);
$('serialize').value = xmls.serializeToString(data);
$('serialize').style.display='block';
}
</script>
</head>
<body onload="init()">
<h2>Draw Lines, Save to GeoServer</h2>
<p>Using GeoServer and the WFS-T support in OpenLayers, draw on a map,
save the results, reload the page and see the results still there!<br />
Hold shift to turn on freehand mode while drawing.</p>
<div style="float:right; text-align:right;">
<a href="#serialize" onclick="serialize('WFS')">Show WFS Transaction</a> |
<a href="#serialize" onclick="serialize('GML')">Export GML</a> |
<a href="#serialize" onclick="serialize('GeoRSS')">Export GeoRSS</a> |
<a href="#" onclick="return save()">Save</a> |
<a href="#" onclick="map.layers[1].refresh(); return false">Refresh</a> (removes all newly added lines)</div><br />
<div id="map"></div>
<textarea style="display:none" id="serialize" cols="100" rows="10">
</textarea>
</body>
</html>

36
examples/wfs-states.html Normal file
View File

@@ -0,0 +1,36 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 100%;
height: 80%;
border: 1px solid black;
}
</style>
<title>WFS: United States (GeoServer)</title>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer;
function init(){
OpenLayers.ProxyHost="/cgi-bin/proxy.cgi?url=";
map = new OpenLayers.Map( $('map'), {controls: [ new OpenLayers.Control.PanZoom(), new OpenLayers.Control.Permalink(), new OpenLayers.Control.MouseDefaults() ]} );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms-c/Basic.py",
{layers: 'basic'} );
map.addLayer(layer);
layer = new OpenLayers.Layer.WFS( "States WFS",
"http://dev.openlayers.org/geoserver/wfs",
{ typename: 'topp:states' } );
map.addLayer(layer);
map.zoomToExtent(new OpenLayers.Bounds(-140.444336,25.115234,-44.438477,50.580078));
}
</script>
</head>
<body onload="init()">
<h2>GeoServer WFS</h2>
<div id="map"></div>
</body>
</html>

71
examples/wfs-t.html Normal file
View File

@@ -0,0 +1,71 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "State",
"http://dev.openlayers.org/geoserver/wms", {layers: 'topp:tasmania_state_boundaries'} );
map.addLayer(layer);
layer = new OpenLayers.Layer.WMS( "Water",
"http://dev.openlayers.org/geoserver/wms", {layers: 'topp:tasmania_water_bodies', 'transparent': true, format: 'image/gif' } );
map.addLayer(layer);
rlayer = new OpenLayers.Layer.WFS( "Roads",
"http://dev.openlayers.org/geoserver/wfs", {typename: 'topp:tasmania_roads'},
{
typename: 'tasmania_roads',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
} );
rlayer.onFeatureInsert=function(feature) { feature.style.strokeColor = "#ff0000"; feature.layer.renderer.drawGeometry(feature.geometry, feature.style); }
map.addLayer(rlayer);
layer = new OpenLayers.Layer.WFS( "Cities",
"http://dev.openlayers.org/geoserver/wfs", {typename: 'topp:tasmania_cities'},
{
typename: 'tasmania_cities',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
} );
map.addLayer(layer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var p = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
df = new OpenLayers.Control.DrawFeature(rlayer, OpenLayers.Handler.Path, {handlerOptions: {'freehand': false}, 'displayClass': 'olControlDrawFeaturePath'});
df.featureAdded = function(feature) {
feature.state = OpenLayers.State.INSERT;
feature.style['strokeColor'] = "#0000ff";
feature.layer.renderer.drawGeometry(feature.geometry, feature.style);
}
dp = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {handlerOptions: {'freehand': false}, 'displayClass': 'olControlDrawFeaturePoint'});
dp.featureAdded = function(feature) {
var oldgeom = feature.geometry;
feature.layer.renderer.eraseGeometry(oldgeom);
feature.geometry = new OpenLayers.Geometry.MultiPoint(oldgeom);
feature.state = OpenLayers.State.INSERT;
feature.style['strokeColor'] = "#0000ff";
feature.layer.renderer.drawGeometry(feature.geometry, feature.style);
}
p.addControls([ new OpenLayers.Control.Navigation(), df, dp ]);
map.addControl(p);
map.zoomToExtent(new OpenLayers.Bounds(145.51045,-44.0,149.0,-40.5));
}
// -->
</script>
</head>
<body onload="init()">
<a href="#" onclick="map.layers[2].commit();return false">Save Roads</a><br />
<a href="#" onclick="map.layers[3].commit();return false">Save Cities</a><br />
<div id="map"></div>
</body>
</html>

View File

@@ -66,6 +66,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Popup.js",
"OpenLayers/Tile.js",
"OpenLayers/Feature.js",
"OpenLayers/Feature/Vector.js",
"OpenLayers/Feature/WFS.js",
"OpenLayers/Tile/Image.js",
"OpenLayers/Tile/WFS.js",
@@ -84,7 +85,6 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Layer/Text.js",
"OpenLayers/Layer/WorldWind.js",
"OpenLayers/Layer/WMS.js",
"OpenLayers/Layer/WFS.js",
"OpenLayers/Layer/WMS/Untiled.js",
"OpenLayers/Layer/GeoRSS.js",
"OpenLayers/Layer/Boxes.js",
@@ -92,9 +92,21 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Layer/TMS.js",
"OpenLayers/Popup/Anchored.js",
"OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Handler.js",
"OpenLayers/Handler/Point.js",
"OpenLayers/Handler/Path.js",
"OpenLayers/Handler/Polygon.js",
"OpenLayers/Handler/Select.js",
"OpenLayers/Handler/Drag.js",
"OpenLayers/Handler/Box.js",
"OpenLayers/Handler/MouseWheel.js",
"OpenLayers/Handler/Keyboard.js",
"OpenLayers/Control.js",
"OpenLayers/Control/ZoomBox.js",
"OpenLayers/Control/ZoomToMaxExtent.js",
"OpenLayers/Control/DragPan.js",
"OpenLayers/Control/Navigation.js",
"OpenLayers/Control/MouseDefaults.js",
"OpenLayers/Control/MouseToolbar.js",
"OpenLayers/Control/MousePosition.js",
"OpenLayers/Control/OverviewMap.js",
"OpenLayers/Control/KeyboardDefaults.js",
@@ -103,7 +115,37 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
"OpenLayers/Control/ArgParser.js",
"OpenLayers/Control/Permalink.js",
"OpenLayers/Control/Scale.js",
"OpenLayers/Control/LayerSwitcher.js"
"OpenLayers/Control/LayerSwitcher.js",
"OpenLayers/Control/DrawFeature.js",
"OpenLayers/Control/Panel.js",
"OpenLayers/Control/SelectFeature.js",
"OpenLayers/Geometry.js",
"OpenLayers/Geometry/Rectangle.js",
"OpenLayers/Geometry/Collection.js",
"OpenLayers/Geometry/Point.js",
"OpenLayers/Geometry/MultiPoint.js",
"OpenLayers/Geometry/Curve.js",
"OpenLayers/Geometry/LineString.js",
"OpenLayers/Geometry/LinearRing.js",
"OpenLayers/Geometry/Polygon.js",
"OpenLayers/Geometry/MultiLineString.js",
"OpenLayers/Geometry/MultiPolygon.js",
"OpenLayers/Geometry/Surface.js",
"OpenLayers/Renderer.js",
"OpenLayers/Renderer/Elements.js",
"OpenLayers/Renderer/SVG.js",
"OpenLayers/Renderer/VML.js",
"OpenLayers/Layer/Vector.js",
"OpenLayers/Layer/GML.js",
"OpenLayers/Format.js",
"OpenLayers/Format/GML.js",
"OpenLayers/Format/KML.js",
"OpenLayers/Format/GeoRSS.js",
"OpenLayers/Format/WFS.js",
"OpenLayers/Layer/WFS.js",
"OpenLayers/Control/MouseToolbar.js",
"OpenLayers/Control/NavToolbar.js",
"OpenLayers/Control/EditingToolbar.js"
); // etc.
var allScriptTags = "";

View File

@@ -221,7 +221,7 @@ OpenLayers.Ajax.Request.prototype = OpenLayers.Class.inherit( OpenLayers.Ajax.Ba
['X-Requested-With', 'XMLHttpRequest',
'X-Prototype-Version', 'OpenLayers'];
if (this.options.method == 'post') {
if (this.options.method == 'post' && !this.options.postBody) {
requestHeaders.push('Content-type',
'application/x-www-form-urlencoded');
@@ -306,3 +306,17 @@ OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri, nsprefix,
parentnode.getElementsByTagNameNS(nsuri, tagname)
: parentnode.getElementsByTagName(nsprefix + ':' + tagname);
}
/**
* Wrapper function around XMLSerializer, which doesn't exist/work in
* IE/Safari. We need to come up with a way to serialize in those browser:
* for now, these browsers will just fail.
* #535, #536
*
* @param {XMLNode} xmldom xml dom to serialize
*/
OpenLayers.Ajax.serializeXMLToString = function(xmldom) {
var serializer = new XMLSerializer();
data = serializer.serializeToString(xmldom);
return data;
}

View File

@@ -388,7 +388,7 @@ OpenLayers.Bounds.prototype = {
* (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
* @type String
*/
toString:function(){
toString:function() {
return ( "left-bottom=(" + this.left + "," + this.bottom + ")"
+ " right-top=(" + this.right + "," + this.top + ")" );
},
@@ -464,11 +464,46 @@ OpenLayers.Bounds.prototype = {
* but shifted by the passed-in x and y values
* @type OpenLayers.Bounds
*/
add:function(x, y){
add:function(x, y) {
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
this.right + x, this.top + y);
},
/**
* Extend the bounds to include the point, lonlat, or bounds specified.
*
* This function assumes that left<right and bottom<top.
*
* @param {OpenLayers.Bounds|OpenLayers.LonLat|OpenLayers.Geometry.Point} object
*/
extend:function(object) {
var bounds = null;
if (object) {
switch(object.CLASS_NAME) {
case "OpenLayers.Geometry.Point":
case "OpenLayers.LonLat":
bounds = new OpenLayers.Bounds(object.lon, object.lat,
object.lon, object.lat);
break;
case "OpenLayers.Bounds":
bounds = object;
break;
}
if (bounds) {
this.left = (bounds.left < this.left) ? bounds.left
: this.left;
this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom
: this.bottom;
this.right = (bounds.right > this.right) ? bounds.right
: this.right;
this.top = (bounds.top > this.top) ? bounds.top
: this.top;
}
}
},
/**
* @param {OpenLayers.LonLat} ll
* @param {Boolean} inclusive Whether or not to include the border.
@@ -781,7 +816,7 @@ OpenLayers.Element = {
* @returns Whether or not this string starts with the string passed in.
* @type Boolean
*/
String.prototype.startsWith = function(sStart){
String.prototype.startsWith = function(sStart) {
return (this.substr(0,sStart.length) == sStart);
};
@@ -791,7 +826,7 @@ String.prototype.startsWith = function(sStart){
* @returns Whether or not this string contains with the string passed in.
* @type Boolean
*/
String.prototype.contains = function(str){
String.prototype.contains = function(str) {
return (this.indexOf(str) != -1);
};

View File

@@ -2,11 +2,15 @@
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*/
OpenLayers.Control = OpenLayers.Class.create();
OpenLayers.Control.TYPE_BUTTON = 1;
OpenLayers.Control.TYPE_TOGGLE = 2;
OpenLayers.Control.TYPE_TOOL = 3;
OpenLayers.Control.prototype = {
/** @type String */
@@ -19,11 +23,27 @@ OpenLayers.Control.prototype = {
/** @type DOMElement */
div: null,
/** @type OpenLayers.Pixel */
position: null,
/**
* Controls can have a 'type'. The type determines the type of interactions
* which are possible with them when they are placed into a toolbar.
* @type OpenLayers.Control.TYPES
*/
type: null,
/** @type OpenLayers.Pixel */
mouseDragStart: null,
/** This property is used for CSS related to the drawing of the Control.
* @type string
*/
displayClass: "",
/**
* @type boolean
*/
active: null,
/**
* @type OpenLayers.Handler
*/
handler: null,
/**
* @constructor
@@ -31,6 +51,10 @@ OpenLayers.Control.prototype = {
* @param {Object} options
*/
initialize: function (options) {
// We do this before the extend so that instances can override
// className in options.
this.displayClass = this.CLASS_NAME.replace("OpenLayers.", "ol").replace(".","");
OpenLayers.Util.extend(this, options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
@@ -52,6 +76,9 @@ OpenLayers.Control.prototype = {
*/
setMap: function(map) {
this.map = map;
if (this.handler) {
this.handler.setMap(map);
}
},
/**
@@ -64,7 +91,7 @@ OpenLayers.Control.prototype = {
if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.div.id = this.id;
this.div.className = 'olControl';
this.div.className = this.displayClass;
}
if (px != null) {
this.position = px.clone();
@@ -83,6 +110,34 @@ OpenLayers.Control.prototype = {
}
},
/**
* @type boolean
*/
activate: function () {
if (this.active) {
return false;
}
if (this.handler) {
this.handler.activate();
}
this.active = true;
return true;
},
/**
* @type boolean
*/
deactivate: function () {
if (this.active) {
if (this.handler) {
this.handler.deactivate();
}
this.active = false;
return true;
}
return false;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control"
};

View File

@@ -0,0 +1,59 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/Handler/Drag.js
*/
OpenLayers.Control.DragPan = OpenLayers.Class.create();
OpenLayers.Control.DragPan.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.Control.TYPES */
type: OpenLayers.Control.TYPE_TOOL,
/**
*
*/
draw: function() {
this.handler = new OpenLayers.Handler.Drag( this,
{"move": this.panMap, "up": this.panMapDone } );
},
/**
* @param {OpenLayers.Pixel} xy Pixel of the up position
*/
panMap: function (xy) {
var deltaX = this.handler.start.x - xy.x;
var deltaY = this.handler.start.y - xy.y;
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true);
// this assumes xy won't be changed inside Handler.Drag
// a safe bet for now, and saves us the extra call to clone().
this.handler.start = xy;
},
/**
* @param {OpenLayers.Pixel} xy Pixel of the up position
*/
panMapDone: function (xy) {
var deltaX = this.handler.start.x - xy.x;
var deltaY = this.handler.start.y - xy.y;
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, false);
// this assumes xy won't be changed inside Handler.Drag
// a safe bet for now, and saves us the extra call to clone().
this.handler.start = xy;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.DragPan"
});

View File

@@ -0,0 +1,63 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Draws features on a vector layer when active.
*
* @class
* @requires OpenLayers/Control.js
* @requires OpenLayers/Feature/Vector.js
*/
OpenLayers.Control.DrawFeature = OpenLayers.Class.create();
OpenLayers.Control.DrawFeature.prototype =
OpenLayers.Class.inherit(OpenLayers.Control, {
/**
* @type OpenLayers.Layer.Vector
*/
layer: null,
/**
* @type {Object} The functions that are sent to the handler for callback
*/
callbacks: {},
/**
* @type {Function} Called after each feature is added
*/
featureAdded: function() {},
/**
* Used to set non-default properties on the control's handler
*
* @type Object
*/
handlerOptions: null,
/**
* @param {OpenLayers.Layer.Vector} layer
* @param {OpenLayers.Handler} handler
* @param {Object} options
*/
initialize: function(layer, handler, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.callbacks = OpenLayers.Util.extend({done: this.drawFeature},
this.callbacks);
this.layer = layer;
this.handler = new handler(this, this.callbacks, this.handlerOptions);
},
/**
*
*/
drawFeature: function(geometry) {
var feature = new OpenLayers.Feature.Vector(geometry);
this.layer.addFeatures([feature]);
this.featureAdded(feature);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.DrawFeature"
});

View File

@@ -0,0 +1,48 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control/Panel.js
* @requires OpenLayers/Control/Navigation.js
* @requires OpenLayers/Control/DrawFeature.js
*/
OpenLayers.Control.EditingToolbar = OpenLayers.Class.create();
OpenLayers.Control.EditingToolbar.prototype =
OpenLayers.Class.inherit( OpenLayers.Control.Panel, {
/**
* Create an editing toolbar for a given layer.
* @param OpenLayers.Layer.Vector layer
* @param Object options
*/
initialize: function(layer, options) {
OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
this.addControls(
[ new OpenLayers.Control.Navigation() ]
);
var controls = [
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'}),
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'}),
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {'displayClass': 'olControlDrawFeaturePolygon'})
];
for (var i = 0; i < controls.length; i++) {
controls[i].featureAdded = function(feature) { feature.state = OpenLayers.State.INSERT; }
}
this.addControls(controls);
},
/**
* calls the default draw, and then activates mouse defaults.
*/
draw: function() {
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
this.activateControl(this.controls[0]);
return div;
},
CLASS_NAME: "OpenLayers.Control.EditingToolbar"
});

View File

@@ -7,6 +7,7 @@
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/Handler/Keyboard.js
*/
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
OpenLayers.Control.KeyboardDefaults.prototype =
@@ -26,16 +27,16 @@ OpenLayers.Control.KeyboardDefaults.prototype =
*
*/
draw: function() {
OpenLayers.Event.observe(document,
'keypress',
this.defaultKeyDown.bindAsEventListener(this));
this.handler = new OpenLayers.Handler.Keyboard( this, {
"keypress": this.defaultKeyPress });
this.activate();
},
/**
* @param {Event} evt
* @param {Integer} code
*/
defaultKeyDown: function (evt) {
switch(evt.keyCode) {
defaultKeyPress: function (code) {
switch(code) {
case OpenLayers.Event.KEY_LEFT:
this.map.pan(-50, 0);
break;
@@ -49,17 +50,11 @@ OpenLayers.Control.KeyboardDefaults.prototype =
this.map.pan(0, 50);
break;
case 33: // Page Up
this.map.zoomIn();
break;
case 34: // Page Down
this.map.zoomOut();
break;
}
switch(evt.charCode) {
case 43: // +
this.map.zoomIn();
break;
case 45: // -
case 34: // Page Down
this.map.zoomOut();
break;
}

View File

@@ -6,6 +6,7 @@
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
OpenLayers.Control.LayerSwitcher.prototype =

View File

@@ -2,7 +2,6 @@
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
@@ -12,6 +11,10 @@ OpenLayers.Control.MouseDefaults = OpenLayers.Class.create();
OpenLayers.Control.MouseDefaults.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** WARNING WARNING WARNING!!!
This class is DEPRECATED in 2.4 and will be removed by 3.0.
If you need this functionality, use Control.Navigation instead!!! */
/** @type Boolean */
performedDrag: false,

View File

@@ -51,7 +51,7 @@ OpenLayers.Control.MousePosition.prototype =
if (!this.element) {
this.div.left = "";
this.div.top = "";
this.div.className = "olControlMousePosition";
this.div.className = this.displayClass;
this.element = this.div;
}

View File

@@ -15,6 +15,10 @@ OpenLayers.Control.MouseToolbar.Y = 300;
OpenLayers.Control.MouseToolbar.prototype =
OpenLayers.Class.inherit( OpenLayers.Control.MouseDefaults, {
/** WARNING WARNING WARNING!!!
This class is DEPRECATED in 2.4 and will be removed by 3.0.
If you need this functionality, use Control.NavToolbar instead!!! */
mode: null,
buttons: null,

View File

@@ -0,0 +1,37 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control/Panel.js
* @requires OpenLayers/Control/Navigation.js
* @requires OpenLayers/Control/ZoomBox.js
*/
OpenLayers.Control.NavToolbar = OpenLayers.Class.create();
OpenLayers.Control.NavToolbar.prototype =
OpenLayers.Class.inherit( OpenLayers.Control.Panel, {
/**
* Add our two mousedefaults controls.
*/
initialize: function(options) {
OpenLayers.Control.Panel.prototype.initialize.apply(this, arguments);
this.addControls([
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.ZoomBox()
]);
},
/**
* calls the default draw, and then activates mouse defaults.
*/
draw: function() {
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
this.activateControl(this.controls[0]);
return div;
},
CLASS_NAME: "OpenLayers.Control.NavToolbar"
});

View File

@@ -0,0 +1,80 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control/ZoomBox.js
* @requires OpenLayers/Control/DragPan.js
* @requires OpenLayers/Handler/MouseWheel.js
*/
OpenLayers.Control.Navigation = OpenLayers.Class.create();
OpenLayers.Control.Navigation.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.Control.ZoomBox */
dragPan: null,
/** @type OpenLayers.Control.ZoomBox */
zoomBox: null,
/** @type OpenLayers.Handler.MouseWheel */
wheelHandler: null,
activate: function() {
this.dragPan.activate();
this.wheelHandler.activate();
this.zoomBox.activate();
return OpenLayers.Control.prototype.activate.apply(this,arguments);
},
deactivate: function() {
this.zoomBox.deactivate();
this.dragPan.deactivate();
this.wheelHandler.deactivate();
return OpenLayers.Control.prototype.deactivate.apply(this,arguments);
},
draw: function() {
this.map.events.register( "dblclick", this, this.defaultDblClick );
this.dragPan = new OpenLayers.Control.DragPan({map: this.map});
this.zoomBox = new OpenLayers.Control.ZoomBox(
{map: this.map, keyMask: OpenLayers.Handler.MOD_SHIFT});
this.dragPan.draw();
this.zoomBox.draw();
this.wheelHandler = new OpenLayers.Handler.MouseWheel(
this, {"up" : this.wheelUp,
"down": this.wheelDown} );
this.activate();
},
/**
* @param {Event} evt
*/
defaultDblClick: function (evt) {
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1);
OpenLayers.Event.stop(evt);
return false;
},
/** User spun scroll wheel up
*
*/
wheelUp: function(evt) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() + 1);
},
/** User spun scroll wheel down
*
*/
wheelDown: function(evt) {
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
this.map.getZoom() - 1);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.Navigation"
});

View File

@@ -10,6 +10,8 @@
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/BaseTypes.js
* @requires OpenLayers/Events.js
*/
OpenLayers.Control.OverviewMap = OpenLayers.Class.create();
@@ -31,7 +33,7 @@ OpenLayers.Control.OverviewMap.prototype =
/**
* The overvew map size in pixels. Note that this is the size of the map
* itself - the element that contains the map (class name
* itself - the element that contains the map (default class name
* olControlOverviewMapElement) may have padding or other style attributes
* added via CSS.
* @type OpenLayers.Size
@@ -93,7 +95,7 @@ OpenLayers.Control.OverviewMap.prototype =
// create overview map DOM elements
this.element = document.createElement('div');
this.element.className = 'olControlOverviewMapElement';
this.element.className = this.displayClass + 'Element';
this.element.style.display = 'none';
this.mapDiv = document.createElement('div');
@@ -110,7 +112,7 @@ OpenLayers.Control.OverviewMap.prototype =
this.extentRectangle.style.backgroundImage = 'url(' +
OpenLayers.Util.getImagesLocation() +
'/blank.png)';
this.extentRectangle.className = 'olControlOverviewMapExtentRectangle';
this.extentRectangle.className = this.displayClass+'ExtentRectangle';
this.mapDiv.appendChild(this.extentRectangle);
this.element.appendChild(this.mapDiv);
@@ -148,18 +150,18 @@ OpenLayers.Control.OverviewMap.prototype =
// Optionally add min/max buttons if the control will go in the
// map viewport.
if(!this.outsideViewport) {
this.div.className = 'olControlOverviewMapContainer';
this.div.className = this.displayClass + 'Container';
var imgLocation = OpenLayers.Util.getImagesLocation();
// maximize button div
var img = imgLocation + 'layer-switcher-maximize.png';
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
'olControlOverviewMapMaximizeButton',
this.displayClass + 'MaximizeButton',
null,
new OpenLayers.Size(18,18),
img,
'absolute');
this.maximizeDiv.style.display = 'none';
this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton';
this.maximizeDiv.className = this.displayClass + 'MaximizeButton';
OpenLayers.Event.observe(this.maximizeDiv,
'click',
this.maximizeControl.bindAsEventListener(this));
@@ -179,7 +181,7 @@ OpenLayers.Control.OverviewMap.prototype =
img,
'absolute');
this.minimizeDiv.style.display = 'none';
this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton';
this.minimizeDiv.className = this.displayClass + 'MinimizeButton';
OpenLayers.Event.observe(this.minimizeDiv,
'click',
this.minimizeControl.bindAsEventListener(this));

View File

@@ -0,0 +1,132 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.Panel = OpenLayers.Class.create();
OpenLayers.Control.Panel.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/**
* @type Array(OpenLayers.Control)
*/
controls: null,
/**
* The control which is activated when the control is activated (turned
* on), which also happens at instantiation.
* @type OpenLayers.Control
*/
defaultControl: null,
/**
* @constructor
*
* @param {DOMElement} element
* @param {String} base
*/
initialize: function(element) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.controls = [];
},
activate: function() {
OpenLayers.Control.prototype.activate.apply(this, arguments);
for(var i = 0; i < this.controls.length; i++) {
if (this.controls[i] == this.defaultControl) {
this.controls[i].activate();
}
}
this.redraw();
},
deactivate: function() {
OpenLayers.Control.prototype.deactivate.apply(this, arguments);
for(var i = 0; i < this.controls.length; i++) {
this.controls[i].deactivate();
}
this.redraw();
},
/**
* @type DOMElement
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
for (var i = 0; i < this.controls.length; i++) {
this.map.addControl(this.controls[i]);
this.controls[i].deactivate();
}
this.activate();
return this.div;
},
/**
* @private
*/
redraw: function() {
this.div.innerHTML = "";
if (this.active) {
for (var i = 0; i < this.controls.length; i++) {
var element = document.createElement("div");
var textNode = document.createTextNode(" ");
if (this.controls[i].active) {
element.className = this.controls[i].displayClass + "ItemActive";
} else {
element.className = this.controls[i].displayClass + "ItemInactive";
}
var onClick = function (ctrl, evt) {
OpenLayers.Event.stop(evt ? evt : window.event);
this.activateControl(ctrl);
};
var control = this.controls[i];
element.onclick = onClick.bind(this, control);
element.onmousedown = OpenLayers.Event.stop.bindAsEventListener();
element.onmouseup = OpenLayers.Event.stop.bindAsEventListener();
this.div.appendChild(element);
}
}
},
activateControl: function (control) {
if (!this.active) { return false; }
if (control.type == OpenLayers.Control.TYPE_BUTTON) {
control.trigger();
return;
}
for (var i = 0; i < this.controls.length; i++) {
if (this.controls[i] == control) {
control.activate();
} else {
this.controls[i].deactivate();
}
}
this.redraw();
},
/**
* To build a toolbar, you add a set of controls to it. addControls
* lets you add a single control or a list of controls to the
* Control Panel.
* @param OpenLayers.Control
*/
addControls: function(controls) {
if (!(controls instanceof Array)) {
controls = [controls];
}
this.controls = this.controls.concat(controls);
if (this.map) { // map.addControl() has already been called on the panel
for (var i = 0; i < controls.length; i++) {
map.addControl(controls[i]);
controls[i].deactivate();
}
this.redraw();
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.Panel"
});

View File

@@ -59,7 +59,7 @@ OpenLayers.Control.Permalink.prototype =
OpenLayers.Control.prototype.draw.apply(this, arguments);
if (!this.element) {
this.div.className = 'olControlPermalink';
this.div.className = this.displayClass;
this.element = document.createElement("a");
this.element.style.fontSize="smaller";
this.element.innerHTML = "Permalink";

View File

@@ -32,7 +32,7 @@ OpenLayers.Control.Scale.prototype =
OpenLayers.Control.prototype.draw.apply(this, arguments);
if (!this.element) {
this.element = document.createElement("div");
this.div.className = "olControlScale";
this.div.className = this.displayClass;
this.element.style.fontSize="smaller";
this.div.appendChild(this.element);
}

View File

@@ -0,0 +1,106 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Draws features on a vector layer when active.
*
* @class
* @requires OpenLayers/Control.js
* @requires OpenLayers/Feature/Vector.js
*/
OpenLayers.Control.SelectFeature = OpenLayers.Class.create();
OpenLayers.Control.SelectFeature.prototype =
OpenLayers.Class.inherit(OpenLayers.Control, {
/**
* @type {OpenLayers.Layer.Vector}
*/
layer: null,
/**
* @type {OpenLayers.Handler.Select}
*/
handler: null,
/**
* @type {Object} The functions that are sent to the handler for callback
*/
callbacks: {},
/**
* @type {Object} Hash of styles
*/
selectStyle: OpenLayers.Feature.Vector.style['select'],
/**
* @type {Object} Hash of styles
* @private
*/
originalStyle: null,
/**
* @type {Boolean} Allow selection of multiple geometries
*/
multiple: false,
/**
* @param {OpenLayers.Layer.Vector} layer
* @param {OpenLayers.Handler} handler
* @param {Object} options
*/
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.callbacks = OpenLayers.Util.extend({down: this.downFeature},
this.callbacks);
this.layer = layer;
this.handler = new OpenLayers.Handler.Select(this, layer, this.callbacks);
},
/**
*
*/
downFeature: function(geometry) {
// Store feature style for restoration later
if(geometry.feature.originalStyle == null) {
geometry.feature.originalStyle = geometry.feature.style;
}
if (this.multiple) {
if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, geometry.feature) > -1) {
this.layer.renderer.drawGeometry(geometry, geometry.feature.originalStyle);
OpenLayers.Util.removeItem(this.layer.selectedFeatures, geometry.feature);
} else {
this.layer.selectedFeatures.push(geometry.feature);
this.layer.renderer.drawGeometry(geometry, this.selectStyle);
}
} else {
if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, geometry.feature) > -1) {
this.layer.renderer.drawGeometry(geometry, geometry.feature.originalStyle);
OpenLayers.Util.removeItem(this.layer.selectedFeatures, geometry.feature);
} else {
if (this.layer.selectedFeatures) {
for (var i = 0; i < this.layer.selectedFeatures.length; i++) {
this.layer.renderer.drawGeometry(this.layer.selectedFeatures[i].geometry, this.layer.selectedFeatures[i].originalStyle);
}
OpenLayers.Util.clearArray(this.layer.selectedFeatures);
}
this.layer.selectedFeatures.push(geometry.feature);
this.layer.renderer.drawGeometry(geometry, this.selectStyle);
}
}
},
/** Set the map property for the control.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.SelectFeature"
});

View File

@@ -0,0 +1,42 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/Handler/Box.js
*/
OpenLayers.Control.ZoomBox = OpenLayers.Class.create();
OpenLayers.Control.ZoomBox.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.Control.TYPE_* */
type: OpenLayers.Control.TYPE_TOOL,
/**
*
*/
draw: function() {
this.handler = new OpenLayers.Handler.Box( this,
{done: this.zoomBox}, {keyMask: this.keyMask} );
},
zoomBox: function (position) {
if (position instanceof OpenLayers.Bounds) {
var minXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.left, position.bottom));
var maxXY = this.map.getLonLatFromPixel(
new OpenLayers.Pixel(position.right, position.top));
var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
maxXY.lon, maxXY.lat);
this.map.zoomToExtent(bounds);
} else { // it's a pixel
this.map.setCenter(this.map.getLonLatFromPixel(position),
this.map.getZoom() + 1);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.ZoomBox"
});

View File

@@ -0,0 +1,24 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* Imlements a very simple button control.
* @requires OpenLayers/Control.js
*/
OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class.create();
OpenLayers.Control.ZoomToMaxExtent.prototype =
OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.Control.TYPE_* */
type: OpenLayers.Control.TYPE_BUTTON,
trigger: function() {
if (this.map) {
this.map.zoomToMaxExtent();
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Control.ZoomToMaxExtent"
});

View File

@@ -227,6 +227,21 @@ OpenLayers.Events.prototype = {
}
}
},
// TODO: get rid of this in 3.0
// Decide whether listeners should be called in the order they were
// registered or in reverse order.
registerPriority: function (type, obj, func) {
if (func != null) {
if (obj == null) {
obj = this.object;
}
var listeners = this.listeners[type];
if (listeners != null) {
listeners.unshift( {obj: obj, func: func} );
}
}
},
/**
* @param {String} type

View File

@@ -7,6 +7,7 @@
* @class
*
* @requires OpenLayers/Util.js
* @requires OpenLayers/Marker.js
*/
OpenLayers.Feature = OpenLayers.Class.create();
OpenLayers.Feature.prototype= {
@@ -151,5 +152,6 @@ OpenLayers.Feature.prototype= {
this.popup.destroy()
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Feature"
};

View File

@@ -0,0 +1,298 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
// TRASH THIS
OpenLayers.State = {
/** states */
UNKNOWN: 'Unknown',
INSERT: 'Insert',
UPDATE: 'Update',
DELETE: 'Delete'
}
/**
* @class
*
* @requires OpenLayers/Feature.js
* @requires OpenLayers/Util.js
*/
OpenLayers.Feature.Vector = OpenLayers.Class.create();
OpenLayers.Feature.Vector.prototype =
OpenLayers.Class.inherit( OpenLayers.Feature, {
/** @type String */
fid: null,
/** @type OpenLayers.Geometry */
geometry:null,
/** @type array */
attributes: {},
/** @type strinng */
state: null,
/** @type Object */
style: null,
/**
* Create a vector feature.
* @constructor
*
* @param {OpenLayers.Geometry} geometry
* @param {Object} data
*/
initialize: function(geometry, data, style) {
OpenLayers.Feature.prototype.initialize.apply(this, [null, null, data]);
this.lonlat = null;
this.setGeometry(geometry);
this.state = null;
if (data) {
OpenLayers.Util.extend(this.attributes, data);
}
this.style = style ? style : OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
},
/**
* @returns An exact clone of this OpenLayers.Feature
* @type OpenLayers.Feature
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Feature(null, this.geometry.clone(), this.data);
}
// catch any randomly tagged-on properties
OpenLayers.Util.applyDefaults(obj, this);
return obj;
},
/**
*
*/
destroy: function() {
this.geometry = null;
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
},
/**
* HACK - we need to rewrite this for non-point geometry
* @returns null - we need to rewrite this for non-point geometry
* @type Boolean
*/
onScreen:function() {
return null;
},
/**
*
* HACK - we need to decide if all vector features should be able to
* create markers
*
* @returns null
*
* @type OpenLayers.Marker
*/
createMarker: function() {
return null;
},
/**
* HACK - we need to decide if all vector features should be able to
* delete markers
*
* If user overrides the createMarker() function, s/he should be able
* to also specify an alternative function for destroying it
*/
destroyMarker: function() {
// pass
},
/**
* HACK - we need to decide if all vector features should be able to
* create popups
*
* @returns null
*/
createPopup: function() {
return null;
},
/**
* Set a feature id to the feature
*
* @param {String} feature id to set
*/
setFid: function(fid) {
this.fid = fid;
},
/**
* Set a geometry to the feature
*
* @param {OpenLayers.Geometry} geometry to set
* @param {Boolean} recurse Recursively set feature (for components)
*/
setGeometry: function(geometry, recurse) {
if(geometry) {
this.geometry = geometry;
this.geometry.feature = this;
if (recurse != false) {
this._setGeometryFeatureReference(this.geometry, this);
}
}
},
/**
* Sets recursively the reference to the feature in the geometry
*
* @param {OpenLayers.Geometry}
* @param {OpenLayers.Feature}
*/
_setGeometryFeatureReference: function(geometry, feature) {
geometry.feature = feature;
if (geometry.components) {
for (var i = 0; i < geometry.components.length; i++) {
this._setGeometryFeatureReference(geometry.components[i], feature);
}
}
},
/**
* Adds attributes an attributes object to the feature.
* (should not be in geometry but in feature class)
*
* @param {Attributes} attributes
*/
setAttributes: function(attributes) {
this.attributes=attributes;
},
/**
* @param {OpenLayers.LonLat} lonlat
* @param {float} toleranceLon Optional tolerance in Geometric Coords
* @param {float} toleranceLat Optional tolerance in Geographic Coords
*
* @returns Whether or not the feature is at the specified location
* @type Boolean
*/
atPoint: function(lonlat, toleranceLon, toleranceLat) {
var atPoint = false;
if(this.geometry) {
atPoint = this.geometry.atPoint(lonlat, toleranceLon,
toleranceLat);
}
return atPoint;
},
/**
*
* HACK - we need to decide if all vector features should be able to
* delete popups
*/
destroyPopup: function() {
// pass
},
/**
* Sets the new state
* @param {String} state
*/
toState: function(state) {
if (state == OpenLayers.State.UPDATE) {
switch (this.state) {
case OpenLayers.State.UNKNOWN:
case OpenLayers.State.DELETE:
this.state = state;
break;
case OpenLayers.State.UPDATE:
case OpenLayers.State.INSERT:
break;
}
} else if (state == OpenLayers.State.INSERT) {
switch (this.state) {
case OpenLayers.State.UNKNOWN:
break;
default:
this.state = state;
break;
}
} else if (state == OpenLayers.State.DELETE) {
switch (this.state) {
case OpenLayers.State.INSERT:
// the feature should be destroyed
break;
case OpenLayers.State.DELETE:
break;
case OpenLayers.State.UNKNOWN:
case OpenLayers.State.UPDATE:
this.state = state;
break;
}
} else if (state == OpenLayers.State.UNKNOWN) {
this.state = state;
}
},
destroy: function() {
},
CLASS_NAME: "OpenLayers.Feature.Vector"
});
// styles for feature rendering
OpenLayers.Feature.Vector.style = {
'default': {
fillColor: "#ee9900",
fillOpacity: 0.4,
hoverFillColor: "white",
hoverFillOpacity: 0.8,
strokeColor: "#ee9900",
strokeOpacity: 1,
strokeWidth: 1,
hoverStrokeColor: "red",
hoverStrokeOpacity: 1,
hoverStrokeWidth: 0.2,
pointRadius: 6,
hoverPointRadius: 1,
hoverPointUnit: "%",
pointerEvents: "visiblePainted"
},
'select': {
fillColor: "blue",
fillOpacity: 0.4,
hoverFillColor: "white",
hoverFillOpacity: 0.8,
strokeColor: "blue",
strokeOpacity: 1,
strokeWidth: 2,
hoverStrokeColor: "red",
hoverStrokeOpacity: 1,
hoverStrokeWidth: 0.2,
pointRadius: 6,
hoverPointRadius: 1,
hoverPointUnit: "%",
pointerEvents: "visiblePainted"
},
'temporary': {
fillColor: "yellow",
fillOpacity: 0.2,
hoverFillColor: "white",
hoverFillOpacity: 0.8,
strokeColor: "yellow",
strokeOpacity: 1,
strokeWidth: 4,
hoverStrokeColor: "red",
hoverStrokeOpacity: 1,
hoverStrokeWidth: 0.2,
pointRadius: 6,
hoverPointRadius: 1,
hoverPointUnit: "%",
pointerEvents: "visiblePainted"
}
};

33
lib/OpenLayers/Format.js Normal file
View File

@@ -0,0 +1,33 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Base class for format reading/writing.
* @requires OpenLayers/Util.js
*/
OpenLayers.Format = OpenLayers.Class.create();
OpenLayers.Format.prototype = {
initialize: function(options) {
OpenLayers.Util.extend(this, options);
},
/**
* Read data from a string, and return a list of features.
*
* @param {string} data data to read/parse.
*/
read: function(data) {
alert("Read not implemented.");
},
/**
* Accept Feature Collection, and return a string.
*
* @param {Array} List of features to serialize into a string.
*/
write: function(features) {
alert("Write not implemented.");
}
};

View File

@@ -0,0 +1,433 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Read/WRite GML.
* @requires OpenLayers/Format.js
* @requires OpenLayers/Feature/Vector.js
* @requires OpenLayers/Ajax.js
* @requires OpenLayers/Geometry.js
*/
OpenLayers.Format.GML = OpenLayers.Class.create();
OpenLayers.Format.GML.prototype =
OpenLayers.Class.inherit( OpenLayers.Format, {
featureNS: "http://mapserver.gis.umn.edu/mapserver",
featureName: "featureMember",
layerName: "features",
geometryName: "geometry",
collectionName: "FeatureCollection",
gmlns: "http://www.opengis.net/gml",
/**
* Extract attributes from GML. Most of the time,
* this is a significant time usage, due to the need
* to recursively descend the XML to search for attributes.
*
* @type Boolean */
extractAttributes: true,
/**
* Read data from a string, and return a list of features.
*
* @param {string|XMLNode} data data to read/parse.
*/
read: function(data) {
if (typeof data == "string") {
data = OpenLayers.parseXMLString(data);
}
var featureNodes = OpenLayers.Ajax.getElementsByTagNameNS(data, this.gmlns, "gml", this.featureName);
if (featureNodes.length == 0) { return []; }
// Determine dimension of the FeatureCollection. Ie, dim=2 means (x,y) coords
// dim=3 means (x,y,z) coords
// GML3 can have 2 or 3 dimensions. GML2 only 2.
var dim;
var coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(featureNodes[0], this.gmlns, "gml", "posList");
if (coordNodes.length == 0) {
coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(featureNodes[0], this.gmlns, "gml", "pos");
}
if (coordNodes.length > 0) {
dim = coordNodes[0].getAttribute("srsDimension");
}
this.dim = (dim == "3" || dim == 3) ? 3 : 2;
var features = [];
// Process all the featureMembers
for (var i = 0; i < featureNodes.length; i++) {
var feature = this.parseFeature(featureNodes[i]);
if (feature) {
features.push(feature);
}
}
return features;
},
/**
* This function is the core of the GML parsing code in OpenLayers.
* It creates the geometries that are then attached to the returned
* feature, and calls parseAttributes() to get attribute data out.
* @param DOMElement xmlNode
*/
parseFeature: function(xmlNode) {
var geom;
var p; // [points,bounds]
var feature = new OpenLayers.Feature.Vector();
if (xmlNode.firstChild.attributes && xmlNode.firstChild.attributes['fid']) {
feature.fid = xmlNode.firstChild.attributes['fid'].nodeValue;
}
// match MultiPolygon
if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon").length != 0) {
var multipolygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon")[0];
geom = new OpenLayers.Geometry.MultiPolygon();
var polygons = OpenLayers.Ajax.getElementsByTagNameNS(multipolygon,
this.gmlns, "gml", "Polygon");
for (var i = 0; i < polygons.length; i++) {
polygon = this.parsePolygonNode(polygons[i],geom);
geom.addComponents(polygon);
}
}
// match MultiLineString
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "MultiLineString").length != 0) {
var multilinestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "MultiLineString")[0];
geom = new OpenLayers.Geometry.MultiLineString();
var lineStrings = OpenLayers.Ajax.getElementsByTagNameNS(multilinestring, this.gmlns, "gml", "LineString");
for (var i = 0; i < lineStrings.length; i++) {
p = this.parseCoords(lineStrings[i]);
if(p.points){
var lineString = new OpenLayers.Geometry.LineString(p.points);
geom.addComponents(lineString);
// TBD Bounds only set for one of multiple geometries
}
}
}
// match MultiPoint
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "MultiPoint").length != 0) {
var multiPoint = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "MultiPoint")[0];
geom = new OpenLayers.Geometry.MultiPoint();
var points = OpenLayers.Ajax.getElementsByTagNameNS(multiPoint, this.gmlns, "gml", "Point");
for (var i = 0; i < points.length; i++) {
p = this.parseCoords(points[i]);
geom.addComponents(p.points[0]);
// TBD Bounds only set for one of multiple geometries
}
}
// match Polygon
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "Polygon").length != 0) {
var polygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "Polygon")[0];
geom = this.parsePolygonNode(polygon);
}
// match LineString
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "LineString").length != 0) {
var lineString = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "LineString")[0];
p = this.parseCoords(lineString);
if (p.points) {
geom = new OpenLayers.Geometry.LineString(p.points);
// TBD Bounds only set for one of multiple geometries
}
}
// match Point
else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "Point").length != 0) {
var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.gmlns, "gml", "Point")[0];
p = this.parseCoords(point);
if (p.points) {
geom = p.points[0];
// TBD Bounds only set for one of multiple geometries
}
}
feature.setGeometry(geom, false);
if (this.extractAttributes) {
feature.attributes = this.parseAttributes(xmlNode);
}
return feature;
},
/**
* recursive function parse the attributes of a GML node.
* Searches for any child nodes which aren't geometries,
* and gets their value.
* @param DOMElement xmlNode
*/
parseAttributes: function(xmlNode) {
var nodes = xmlNode.childNodes;
var attributes = {};
for(var i = 0; i < nodes.length; i++) {
var name = nodes[i].nodeName;
var value = OpenLayers.Util.getXmlNodeValue(nodes[i]);
// Ignore Geometry attributes
// match ".//gml:pos|.//gml:posList|.//gml:coordinates"
if((name.search(":pos")!=-1)
||(name.search(":posList")!=-1)
||(name.search(":coordinates")!=-1)){
continue;
}
// Check for a leaf node
if((nodes[i].childNodes.length == 1 && nodes[i].childNodes[0].nodeName == "#text")
|| (nodes[i].childNodes.length == 0 && nodes[i].nodeName!="#text")) {
attributes[name] = value;
}
OpenLayers.Util.extend(attributes, this.parseAttributes(nodes[i]))
}
return attributes;
},
/**
*
* @param {XMLNode} xmlNode
*
* @return {OpenLayers.Geometry.Polygon} polygon geometry
*/
parsePolygonNode: function(polygonNode) {
var linearRings = OpenLayers.Ajax.getElementsByTagNameNS(polygonNode,
this.gmlns, "gml", "LinearRing");
var rings = [];
var p;
var polyBounds;
for (var i = 0; i < linearRings.length; i++) {
p = this.parseCoords(linearRings[i]);
ring1 = new OpenLayers.Geometry.LinearRing(p.points);
rings.push(ring1);
}
var poly = new OpenLayers.Geometry.Polygon(rings);
return poly;
},
/**
* Extract Geographic coordinates from an XML node.
* @private
* @param {XMLNode} xmlNode
*
* @return an array of OpenLayers.Geometry.Point points.
* @type Array
*/
parseCoords: function(xmlNode) {
var x, y, left, bottom, right, top, bounds;
var p = []; // return value = [points,bounds]
if (xmlNode) {
p.points = [];
// match ".//gml:pos|.//gml:posList|.//gml:coordinates"
// Note: GML2 coordinates are of the form:x y,x y,x y
// GML2 can also be of the form <coord><x>1</x><y>2</y></coord>
// GML3 posList is of the form:x y x y. OR x y z x y z.
// GML3 Line or Polygon
var coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "posList");
// GML3 Point
if (coordNodes.length == 0) {
coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "pos");
}
// GML2
if (coordNodes.length == 0) {
coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "coordinates");
}
// TBD: Need to handle an array of coordNodes not just coordNodes[0]
var coordString = OpenLayers.Util.getXmlNodeValue(coordNodes[0]);
// Extract an array of Numbers from CoordString
var nums = (coordString) ? coordString.split(/[, \n\t]+/) : [];
// Remove elements caused by leading and trailing white space
while (nums[0] == "")
nums.shift();
while (nums[nums.length-1] == "")
nums.pop();
for(i = 0; i < nums.length; i = i + this.dim) {
x = parseFloat(nums[i]);
y = parseFloat(nums[i+1]);
p.points.push(new OpenLayers.Geometry.Point(x, y));
}
}
return p;
},
/**
* Accept Feature Collection, and return a string.
*
* @param {Array} List of features to serialize into a string.
*/
write: function(features) {
var featureCollection = document.createElementNS("http://www.opengis.net/wfs", "wfs:" + this.collectionName);
for (var i=0; i < features.length; i++) {
featureCollection.appendChild(this.createFeatureXML(features[i]));
}
return featureCollection;
},
/**
* Accept an OpenLayers.Feature.Vector, and build a geometry for it.
*
* @param OpenLayers.Feature.Vector feature
* @returns DOMElement
*/
createFeatureXML: function(feature) {
var geometryNode = this.buildGeometryNode(feature.geometry);
var geomContainer = document.createElementNS(this.featureNS, "feature:"+this.geometryName);
geomContainer.appendChild(geometryNode);
var featureNode = document.createElementNS(this.gmlns, "gml:" + this.featureName);
var featureContainer = document.createElementNS(this.featureNS, "feature:"+this.layerName);
featureContainer.appendChild(geomContainer);
for(var attr in feature.attributes) {
var attrText = document.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = document.createElementNS(this.featureNS, "feature:"+nodename);
attrContainer.appendChild(attrText);
featureContainer.appendChild(attrContainer);
}
featureNode.appendChild(featureContainer);
return featureNode;
},
/**
* builds a GML file with a given geometry
*
* @param {OpenLayers.Geometry} geometry
*/
buildGeometryNode: function(geometry) {
// TBD test if geoserver can be given a Multi-geometry for a simple-geometry data store
// ie if multipolygon can be sent for a polygon feature type
var gml = "";
// match MultiPolygon or Polygon
if (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon"
|| geometry.CLASS_NAME == "OpenLayers.Geometry.Polygon") {
gml = document.createElementNS(this.gmlns, 'gml:MultiPolygon');
// TBD retrieve the srs from layer
// srsName is non-standard, so not including it until it's right.
//gml.setAttribute("srsName", "http://www.opengis.net/gml/srs/epsg.xml#4326");
var polygonMember = document.createElementNS(this.gmlns, 'gml:polygonMember');
var polygon = document.createElementNS(this.gmlns, 'gml:Polygon');
var outerRing = document.createElementNS(this.gmlns, 'gml:outerBoundaryIs');
var linearRing = document.createElementNS(this.gmlns, 'gml:LinearRing');
// TBD manage polygons with holes
linearRing.appendChild(this.buildCoordinatesNode(geometry.components[0]));
outerRing.appendChild(linearRing);
polygon.appendChild(outerRing);
polygonMember.appendChild(polygon);
gml.appendChild(polygonMember);
}
// match MultiLineString or LineString
else if (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString"
|| geometry.CLASS_NAME == "OpenLayers.Geometry.LineString") {
gml = document.createElementNS(this.gmlns, 'gml:MultiLineString');
// TBD retrieve the srs from layer
// srsName is non-standard, so not including it until it's right.
//gml.setAttribute("srsName", "http://www.opengis.net/gml/srs/epsg.xml#4326");
var lineStringMember = document.createElementNS(this.gmlns, 'gml:lineStringMember');
var lineString = document.createElementNS(this.gmlns, 'gml:LineString');
lineString.appendChild(this.buildCoordinatesNode(geometry));
lineStringMember.appendChild(lineString);
gml.appendChild(lineStringMember);
}
// match MultiPoint or Point
else if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point" ||
geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") {
// TBD retrieve the srs from layer
// srsName is non-standard, so not including it until it's right.
//gml.setAttribute("srsName", "http://www.opengis.net/gml/srs/epsg.xml#4326");
gml = document.createElementNS(this.gmlns, 'gml:MultiPoint');
var parts = "";
if (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") {
parts = geometry.components;
} else {
parts = [geometry];
}
for (var i = 0; i < parts.length; i++) {
var pointMember = document.createElementNS(this.gmlns, 'gml:pointMember');
var point = document.createElementNS(this.gmlns, 'gml:Point');
point.appendChild(this.buildCoordinatesNode(parts[i]));
pointMember.appendChild(point);
gml.appendChild(pointMember);
}
}
return gml;
},
/**
* builds the coordinates XmlNode
* <gml:coordinates decimal="." cs="," ts=" ">...</gml:coordinates>
*
* @param {OpenLayers.Geometry} geometry
* @return {XmlNode} created xmlNode
*/
buildCoordinatesNode: function(geometry) {
var coordinatesNode = document.createElementNS(this.gmlns, "gml:coordinates");
coordinatesNode.setAttribute("decimal", ".");
coordinatesNode.setAttribute("cs", ",");
coordinatesNode.setAttribute("ts", " ");
var points = null;
if (geometry.components) {
points = geometry.components;
}
var path = "";
if (points) {
for (var i = 0; i < points.length; i++) {
path += points[i].x + "," + points[i].y + " ";
}
} else {
path += geometry.x + "," + geometry.y + " ";
}
var txtNode = document.createTextNode(path);
coordinatesNode.appendChild(txtNode);
return coordinatesNode;
}
});

View File

@@ -0,0 +1,107 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Write-only GeoRSS.
* @requires OpenLayers/Format.js
*/
OpenLayers.Format.GeoRSS = OpenLayers.Class.create();
OpenLayers.Format.GeoRSS.prototype =
OpenLayers.Class.inherit( OpenLayers.Format, {
rssns: "http://backend.userland.com/rss2",
featureNS: "http://mapserver.gis.umn.edu/mapserver",
georssns: "http://www.georss.org/georss",
/**
* Accept Feature Collection, and return a string.
*
* @param {Array} List of features to serialize into a string.
*/
write: function(features) {
var featureCollection = document.createElementNS(this.rssns, "rss");
for (var i=0; i < features.length; i++) {
featureCollection.appendChild(this.createFeatureXML(features[i]));
}
return featureCollection;
},
/**
* Accept an OpenLayers.Feature.Vector, and build a geometry for it.
*
* @param OpenLayers.Feature.Vector feature
* @returns DOMElement
*/
createFeatureXML: function(feature) {
var geometryNode = this.buildGeometryNode(feature.geometry);
var featureNode = document.createElementNS(this.rssns, "item");
var titleNode = document.createElementNS(this.rssns, "title");
titleNode.appendChild(document.createTextNode(feature.attributes.title ? feature.attributes.title : ""));
var descNode = document.createElementNS(this.rssns, "description");
descNode.appendChild(document.createTextNode(feature.attributes.description ? feature.attributes.description : ""));
featureNode.appendChild(titleNode);
featureNode.appendChild(descNode);
for(var attr in feature.attributes) {
var attrText = document.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = document.createElementNS(this.featureNS, "feature:"+nodename);
attrContainer.appendChild(attrText);
featureNode.appendChild(attrContainer);
}
featureNode.appendChild(geometryNode);
return featureNode;
},
/**
* builds a GeoRSS node with a given geometry
*
* @param {OpenLayers.Geometry} geometry
*/
buildGeometryNode: function(geometry) {
var gml = "";
// match MultiPolygon or Polygon
if (geometry.CLASS_NAME == "OpenLayers.Geometry.Polygon") {
gml = document.createElementNS(this.georssns, 'georss:polygon');
gml.appendChild(this.buildCoordinatesNode(geometry.components[0]));
}
// match MultiLineString or LineString
else if (geometry.CLASS_NAME == "OpenLayers.Geometry.LineString") {
gml = document.createElementNS(this.georssns, 'georss:line');
gml.appendChild(this.buildCoordinatesNode(geometry));
}
// match MultiPoint or Point
else if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
gml = document.createElementNS(this.georssns, 'georss:point');
gml.appendChild(this.buildCoordinatesNode(geometry));
} else {
alert("Couldn't parse " + geometry.CLASS_NAME);
}
return gml;
},
buildCoordinatesNode: function(geometry) {
var points = null;
if (geometry.components) {
points = geometry.components;
}
var path = "";
if (points) {
for (var i = 0; i < points.length; i++) {
path += points[i].lat + " " + points[i].lon + " ";
}
} else {
path += geometry.lat + " " + geometry.lon + " ";
}
return document.createTextNode(path);
}
});

View File

@@ -0,0 +1,169 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Read only KML.
* @requires OpenLayers/Format.js
* @requires OpenLayers/Feature/Vector.js
* @requires OpenLayers/Ajax.js
*/
OpenLayers.Format.KML = OpenLayers.Class.create();
OpenLayers.Format.KML.prototype =
OpenLayers.Class.inherit( OpenLayers.Format, {
featureNS: "http://mapserver.gis.umn.edu/mapserver",
collectionName: "FeatureCollection",
kmlns: "http://earth.google.com/kml/2.0",
/**
* Read data from a string, and return a list of features.
*
* @param {string|XMLNode} data data to read/parse.
*/
read: function(data) {
if (typeof data == "string") {
data = OpenLayers.parseXMLString(data);
}
var featureNodes = OpenLayers.Ajax.getElementsByTagNameNS(data, this.kmlns, "", "Placemark");
var features = [];
// Process all the featureMembers
for (var i = 0; i < featureNodes.length; i++) {
var feature = this.parseFeature(featureNodes[i]);
if (feature) {
features.push(feature);
}
}
return features;
},
/**
* This function is the core of the KML parsing code in OpenLayers.
* It creates the geometries that are then attached to the returned
* feature, and calls parseAttributes() to get attribute data out.
* @param DOMElement xmlNode
*/
parseFeature: function(xmlNode) {
var geom;
var p; // [points,bounds]
var feature = new OpenLayers.Feature.Vector();
// match Point
if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.kmlns, "", "Point").length != 0) {
var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.kmlns, "", "Point")[0];
p = this.parseCoords(point);
if (p.points) {
geom = p.points[0];
// TBD Bounds only set for one of multiple geometries
geom.extendBounds(p.bounds);
}
// match LineString
} else if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.kmlns, "", "LineString").length != 0) {
var linestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode,
this.kmlns, "", "LineString")[0];
p = this.parseCoords(linestring);
if (p.points) {
geom = new OpenLayers.Geometry.LineString(p.points);
// TBD Bounds only set for one of multiple geometries
geom.extendBounds(p.bounds);
}
}
feature.setGeometry(geom);
feature.attributes = this.parseAttributes(xmlNode);
return feature;
},
/**
* recursive function parse the attributes of a KML node.
* Searches for any child nodes which aren't geometries,
* and gets their value.
* @param DOMElement xmlNode
*/
parseAttributes: function(xmlNode) {
var nodes = xmlNode.childNodes;
var attributes = {};
for(var i = 0; i < nodes.length; i++) {
var name = nodes[i].nodeName;
var value = OpenLayers.Util.getXmlNodeValue(nodes[i]);
// Ignore Geometry attributes
// match ".//gml:pos|.//gml:posList|.//gml:coordinates"
if((name.search(":pos")!=-1)
||(name.search(":posList")!=-1)
||(name.search(":coordinates")!=-1)){
continue;
}
// Check for a leaf node
if((nodes[i].childNodes.length == 1 && nodes[i].childNodes[0].nodeName == "#text")
|| (nodes[i].childNodes.length == 0 && nodes[i].nodeName!="#text")) {
attributes[name] = value;
}
OpenLayers.Util.extend(attributes, this.parseAttributes(nodes[i]))
}
return attributes;
},
/**
* Extract Geographic coordinates from an XML node.
* @private
* @param {XMLNode} xmlNode
*
* @return an array of OpenLayers.Geometry.Point points.
* @type Array
*/
parseCoords: function(xmlNode) {
var p = [];
p.points = [];
// TBD: Need to handle an array of coordNodes not just coordNodes[0]
var coordNodes = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.kmlns, "", "coordinates")[0];
var coordString = OpenLayers.Util.getXmlNodeValue(coordNodes);
var firstCoord = coordString.split(" ");
while (firstCoord[0] == "")
firstCoord.shift();
var dim = firstCoord[0].split(",").length;
// Extract an array of Numbers from CoordString
var nums = (coordString) ? coordString.split(/[, \n\t]+/) : [];
// Remove elements caused by leading and trailing white space
while (nums[0] == "")
nums.shift();
while (nums[nums.length-1] == "")
nums.pop();
for(i = 0; i < nums.length; i = i + dim) {
x = parseFloat(nums[i]);
y = parseFloat(nums[i+1]);
p.points.push(new OpenLayers.Geometry.Point(x, y));
if (!p.bounds) {
p.bounds = new OpenLayers.Bounds(x, y, x, y);
} else {
p.bounds.extend(x, y);
}
}
return p;
},
CLASS_NAME: "OpenLayers.Format.KML"
});

View File

@@ -0,0 +1,156 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Read/WRite WFS.
* @requires OpenLayers/Format/GML.js
*/
OpenLayers.Format.WFS = OpenLayers.Class.create();
OpenLayers.Format.WFS.prototype =
OpenLayers.Class.inherit( OpenLayers.Format.GML, {
layer: null,
wfsns: "http://www.opengis.net/wfs",
/*
* Create a WFS-T formatter. This requires a layer: that layer should
* have two properties: geometry_column and typename. The parser
* for this format is subclassed entirely from GML: There is a writer
* only, which uses most of the code from the GML layer, and wraps
* it in transactional elements.
* @param {Object} options
* @param OpenLayers.Layer layer
*/
initialize: function(options, layer) {
OpenLayers.Format.GML.prototype.initialize.apply(this, arguments);
this.layer = layer;
if (this.layer.featureNS) {
this.featureNS = this.layer.featureNS;
}
if (this.layer.options.geometry_column) {
this.geometryName = this.layer.options.geometry_column;
}
if (this.layer.options.typename) {
this.featureName = this.layer.options.typename;
}
},
/**
* write
* Takes a feature list, and generates a WFS-T Transaction
*
* @param Array
*/
write: function(features) {
var transaction = document.createElementNS('http://www.opengis.net/wfs', 'wfs:Transaction');
for (var i=0; i < features.length; i++) {
switch (features[i].state) {
case OpenLayers.State.INSERT:
transaction.appendChild(this.insert(features[i]));
break;
case OpenLayers.State.UPDATE:
transaction.appendChild(this.update(features[i]));
break;
case OpenLayers.State.DELETE:
transaction.appendChild(this.remove(features[i]));
break;
}
}
return transaction;
},
createFeatureXML: function(feature) {
var geometryNode = this.buildGeometryNode(feature.geometry);
var geomContainer = document.createElementNS(this.featureNS, "feature:" + this.geometryName);
geomContainer.appendChild(geometryNode);
var featureContainer = document.createElementNS(this.featureNS, "feature:" + this.featureName);
featureContainer.appendChild(geomContainer);
for(var attr in feature.attributes) {
var attrText = document.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = document.createElementNS(this.featureNS, "feature:" + nodename);
attrContainer.appendChild(attrText);
featureContainer.appendChild(attrContainer);
}
return featureContainer;
},
/**
* insert
* Takes a feature, and generates a WFS-T Transaction "Insert"
*
* @param OpenLayers.Feature.Vector
*/
insert: function(feature) {
var insertNode = document.createElementNS(this.wfsns, 'wfs:Insert');
insertNode.appendChild(this.createFeatureXML(feature));
return insertNode;
},
/**
* update
* Takes a feature, and generates a WFS-T Transaction "Update"
*
* @param OpenLayers.Feature.Vector
*/
update: function(feature) {
if (!feature.fid) { alert("Can't update a feature for which there is no FID."); }
var updateNode = document.createElementNS(this.wfsns, 'wfs:Update');
updateNode.setAttribute("typeName", this.layerName);
var propertyNode = document.createElementNS(this.wfsns, 'wfs:Property');
var nameNode = document.createElementNS('http://www.opengis.net/wfs', 'wfs:Name');
var txtNode = document.createTextNode(this.geometryName);
nameNode.appendChild(txtNode);
propertyNode.appendChild(nameNode);
var valueNode = document.createElementNS('http://www.opengis.net/wfs', 'wfs:Value');
valueNode.appendChild(this.buildGeometryNode(feature.geometry));
propertyNode.appendChild(valueNode);
updateNode.appendChild(propertyNode);
var filterNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:Filter');
var filterIdNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:FeatureId');
filterIdNode.setAttribute("fid", feature.fid);
filterNode.appendChild(filterIdNode);
updateNode.appendChild(filterNode);
return updateNode;
},
/**
* delete
* Takes a feature, and generates a WFS-T Transaction "Delete"
*
* @param OpenLayers.Feature.Vector
*/
remove: function(feature) {
if (!feature.attributes.fid) {
alert("Can't update a feature for which there is no FID.");
return false;
}
var deleteNode = document.createElementNS(this.featureNS, 'wfs:Delete');
deleteNode.setAttribute("typeName", this.layerName);
var filterNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:Filter');
var filterIdNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:FeatureId');
filterIdNode.setAttribute("fid", feature.attributes.fid);
filterNode.appendChild(filterIdNode);
deleteNode.appendChild(filterNode);
return deleteNode;
},
destroy: function() {
this.layer = null;
}
});

165
lib/OpenLayers/Geometry.js Normal file
View File

@@ -0,0 +1,165 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*/
OpenLayers.Geometry = OpenLayers.Class.create();
OpenLayers.Geometry.prototype = {
/** @type String */
id: null,
/** This is set when a Geometry is added as Component of another Geometry
*
* @type OpenLayers.Geometry */
parent: null,
/** @type OpenLayers.Bounds */
bounds: null,
/**
* Cross reference back to the feature that owns this geometry so
* that that the feature can be identified after the geometry has been
* selected by a mouse click.
*
* @type OpenLayers.Feature */
feature: null,
/** @type OpenLayers.Events */
events:null,
/**
* @constructor
*/
initialize: function() {
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME+ "_");
},
/**
*
*/
destroy: function() {
this.id = null;
this.bounds = null;
this.feature = null;
if (this.events) {
this.events.destroy();
}
this.events = null;
},
/**
* Set the bounds for this Geometry.
*
* @param {OpenLayers.Bounds} object
*/
setBounds: function(bounds) {
if (bounds) {
this.bounds = bounds.clone();
}
},
/**
* Nullify this components bounds and that of its parent as well.
*/
clearBounds: function() {
this.bounds = null;
if (this.parent) {
this.parent.clearBounds();
}
},
/**
* Extend the existing bounds to include the new bounds.
* If geometry's bounds is not yet set, then set a new Bounds.
*
* @param {OpenLayers.Bounds} newBounds
*/
extendBounds: function(newBounds){
var bounds = this.getBounds();
if (!bounds) {
this.setBounds(newBounds);
} else {
this.bounds.extend(newBounds);
}
},
/**
* Get the bounds for this Geometry. If bounds is not set, it
* is calculated again, this makes queries faster.
*
* @type OpenLayers.Bounds
*/
getBounds: function() {
if (this.bounds == null) {
this.calculateBounds();
}
return this.bounds;
},
/** Recalculate the bounds for the geometry.
*
*/
calculateBounds: function() {
//
// This should be overridden by subclasses.
//
},
/**
* Note: This is only an approximation based on the bounds of the
* geometry.
*
* @param {OpenLayers.LonLat} lonlat
* @param {float} toleranceLon Optional tolerance in Geometric Coords
* @param {float} toleranceLat Optional tolerance in Geographic Coords
*
* @returns Whether or not the geometry is at the specified location
* @type Boolean
*/
atPoint: function(lonlat, toleranceLon, toleranceLat) {
var atPoint = false;
var bounds = this.getBounds();
if ((bounds != null) && (lonlat != null)) {
var dX = (toleranceLon != null) ? toleranceLon : 0;
var dY = (toleranceLat != null) ? toleranceLat : 0;
var toleranceBounds =
new OpenLayers.Bounds(this.bounds.left - dX,
this.bounds.bottom - dY,
this.bounds.right + dX,
this.bounds.top + dY);
atPoint = toleranceBounds.containsLonLat(lonlat);
}
return atPoint;
},
/**
* @returns The length of the geometry
* @type float
*/
getLength: function() {
//to be overridden by geometries that actually have a length
//
return 0.0;
},
/**
* @returns The area of the geometry
* @type float
*/
getArea: function() {
//to be overridden by geometries that actually have an area
//
return 0.0;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry"
};

View File

@@ -0,0 +1,201 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A Collection is exactly what it sounds like: A collection of different
* Geometries. These are stored in the local parameter "components" (which
* can be passed as a parameter to the constructor).
*
* As new geometries are added to the collection, they are NOT cloned.
* When removing geometries, they need to be specified by reference (ie you
* have to pass in the *exact* geometry to be removed).
*
* The getArea() and getLength() functions here merely iterate through
* the components, summing their respective areas and lengths.
*
* @requires OpenLayers/Geometry.js
*/
OpenLayers.Geometry.Collection = OpenLayers.Class.create();
OpenLayers.Geometry.Collection.prototype =
OpenLayers.Class.inherit( OpenLayers.Geometry, {
/** @type Array(OpenLayers.Geometry) */
components: null,
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry)} components
*/
initialize: function (components) {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
this.components = new Array();
if (components != null) {
this.addComponents(components);
}
},
/**
*
*/
destroy: function () {
this.components.length = 0;
this.components = null;
},
/**
* @returns An exact clone of this collection
* @type OpenLayers.Geometry.Collection
*/
clone: function (obj) {
if (obj == null) {
obj = eval("new " + this.CLASS_NAME + "()");
}
for (var i = 0; i < this.components.length; i++) {
obj.addComponent(this.components[i].clone());
}
// catch any randomly tagged-on properties
OpenLayers.Util.applyDefaults(obj, this);
return obj;
},
/**
* @returns the components of the geometry
* @type Array(OpenLayers.Geometry)
*/
getComponents: function(){
return this.components;
},
/**
* @returns the components of the geometry
* @type Array(OpenLayers.Geometry)
*/
getComponentsString: function(){
var strings = [];
for(var i = 0; i < this.components.length; i++) {
strings.push(this.components[i].toShortString());
}
return strings.join(",");
},
/** Recalculate the bounds by iterating through the components and
* calling calling extendBounds() on each item
*
*/
calculateBounds: function() {
this.bounds = null;
if ( !this.components || (this.components.length > 0)) {
this.setBounds(this.components[0].getBounds());
for (var i = 1; i < this.components.length; i++) {
this.extendBounds(this.components[i].getBounds());
}
}
},
/**
* @param {Array(OpenLayers.Geometry)} components
*
*/
addComponents: function(components){
if(!(components instanceof Array)) {
components = [components];
}
for(var i=0; i < components.length; i++) {
this.addComponent(components[i]);
}
},
/** Add a new component (geometry) to the collection.
*
* The bounds cache is reset.
*
* @param {OpenLayers.Geometry} component
* @param {int} index Index into the array to insert the component
*/
addComponent: function(component, index) {
if (component) {
if (index) {
var components1 = this.components.slice(0, index);
var components2 = this.components.slice(index,
this.components.length);
components1.push(component);
this.components = components1.concat(components2);
} else {
this.components.push(component);
}
component.parent = this;
this.clearBounds();
}
},
/**
* @param {Array(OpenLayers.Geometry)} components
*/
removeComponents: function(components) {
if(!(components instanceof Array)) {
components = [components];
}
for (var i = 0; i < components.length; i++) {
this.removeComponent(components[i]);
}
},
/**
* @param {OpenLayers.Geometry} component
*/
removeComponent: function(component) {
OpenLayers.Util.removeItem(this.components, component);
// clearBounds() so that it gets recalculated on the next call
// to this.getBounds();
this.clearBounds();
},
/**
* @returns The length of the geometry
* @type float
*/
getLength: function() {
var length = 0.0;
for (var i = 0; i < this.components.length; i++) {
length += this.components[i].getLength();
}
return length;
},
/** Note how this function is overridden in Polygon
*
* @returns the area of the collection by summing its parts
* @type float
*/
getArea: function() {
var area = 0.0;
for (var i = 0; i < this.components.length; i++) {
area += this.components[i].getArea();
}
return area;
},
/**
* Moves a collection in place
* @param {Float} x
* @param {Float} y
*/
move: function(x, y) {
for(var i = 0; i < this.components.length; i++) {
this.components[i].move(x, y);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Collection"
});

View File

@@ -0,0 +1,58 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A Curve is a MultiPoint, whose points are assumed to be connected. To
* this end, we provide a "getLength()" function, which iterates through
* the points, summing the distances between them.
*
* @requires OpenLayers/Geometry/MultiPoint.js
*/
OpenLayers.Geometry.Curve = OpenLayers.Class.create();
OpenLayers.Geometry.Curve.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.MultiPoint, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.Point)} points
*/
initialize: function(points) {
OpenLayers.Geometry.MultiPoint.prototype.initialize.apply(this,
arguments);
},
/**
* @returns An exact clone of this OpenLayers.Feature
* @type OpenLayers.Feature
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Geometry.Curve();
}
obj = OpenLayers.Geometry.Collection.prototype.clone.apply(this,
[obj]);
return obj;
},
/**
* @returns The length of the curve
* @type float
*/
getLength: function() {
var length = 0.0;
if ( this.components && (this.components.length > 1)) {
for(var i=1; i < this.components.length; i++) {
length += this.components[i-1].distanceTo(this.components[i]);
}
}
return length;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Curve"
});

View File

@@ -0,0 +1,65 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A LineString is a Curve which, once two points have been added to it, can
* never be less than two points long.
*
* @requires OpenLayers/Geometry/Curve.js
*/
OpenLayers.Geometry.LineString = OpenLayers.Class.create();
OpenLayers.Geometry.LineString.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.Curve, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.Point)} points
*/
initialize: function(points) {
OpenLayers.Geometry.Curve.prototype.initialize.apply(this,
arguments);
},
/**
* @returns The coordinates components as a string
* @type String
*/
toString: function() {
return this.components.toString();
},
/**
* @returns An exact clone of this OpenLayers.Feature
* @type OpenLayers.Feature
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Geometry.LineString();
}
for (var i = 0; i < this.components.length; i++) {
obj.addComponent(this.components[i].clone());
}
return obj;
},
/** Only allows removal of a point if there are three or more points in
* the linestring. (otherwise the result would be just a single point)
*
* @param {OpenLayers.Geometry.Point} point
*/
removeComponent: function(point) {
if ( this.components && (this.components.length > 2)) {
OpenLayers.Geometry.Curve.prototype.removeComponent.apply(this,
arguments);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.LineString"
});

View File

@@ -0,0 +1,113 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A Linear Ring is a special LineString which is closed. It closes itself
* automatically on every addPoint/removePoint by adding a copy of the first
* point as the last point.
*
* Also, as it is the first in the line family to close itself, a getArea()
* function is defined to calculate the enclosed area of the linearRing
*
* @requires OpenLayers/Geometry/LineString.js
*/
OpenLayers.Geometry.LinearRing = OpenLayers.Class.create();
OpenLayers.Geometry.LinearRing.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.LineString, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.Point)} points
*/
initialize: function(points) {
OpenLayers.Geometry.LineString.prototype.initialize.apply(this,
arguments);
},
/**
* @returns An exact clone of this OpenLayers.Geometry.LinearRing
* @type OpenLayers.Geometry.LinearRing
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Geometry.LinearRing();
}
for (var i = 0; i < this.components.length; i++) {
obj.addComponent(this.components[i].clone());
}
return obj;
},
/**
* Adds a point to geometry components
*
* @param {OpenLayers.Geometry.Point} point
* @param {int} index Index into the array to insert the component
*/
addComponent: function(point, index) {
//remove last point
var lastPoint = this.components[this.components.length-1];
OpenLayers.Geometry.Curve.prototype.removeComponent.apply(this,
[lastPoint]);
//add our point
OpenLayers.Geometry.LineString.prototype.addComponent.apply(this,
arguments);
//append copy of first point
var firstPoint = this.components[0];
OpenLayers.Geometry.Curve.prototype.addComponent.apply(this,
[firstPoint.clone()]);
},
/**
* Removes a point from geometry components
*
* @param {OpenLayers.Geometry.Point} point
*/
removeComponent: function(point) {
if (this.components.length > 4) {
//remove last point
var lastPoint = this.components[this.components.length-1];
OpenLayers.Geometry.Curve.prototype.removeComponent.apply(this,
[lastPoint]);
//remove our point
OpenLayers.Geometry.LineString.prototype.removeComponent.apply(this,
arguments);
//append copy of first point
var firstPoint = this.components[0];
OpenLayers.Geometry.Curve.prototype.addComponent.apply(this,
[firstPoint.clone()]);
}
},
/** Note: The area is positive if the ring is oriented CW, otherwise
* it will be negative.
*
* @returns The signed area for a ring.
* @type float
*/
getArea: function() {
var area = 0.0;
if ( this.components && (this.components.length > 2)) {
var sum = 0.0;
for (var i = 0; i < this.components.length - 1; i++) {
var b = this.components[i];
var c = this.components[i+1];
sum += (b.x + c.x) * (c.y - b.y);
}
area = - sum / 2.0;
}
return area;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.LinearRing"
});

View File

@@ -0,0 +1,42 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A MultiLineString is a collection of LineStrings
*
* @requires OpenLayers/Geometry/Collection.js
*/
OpenLayers.Geometry.MultiLineString = OpenLayers.Class.create();
OpenLayers.Geometry.MultiLineString.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.Collection, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.LineString)} components
*/
initialize: function(components) {
OpenLayers.Geometry.Collection.prototype.initialize.apply(this,
arguments);
},
/**
* adds a component to the MultiPoint, checking type
*
* @param {OpenLayers.Geometry.LineString} component lineString to add
* @param {int} index Index into the array to insert the component
*/
addComponent: function(component, index) {
if (!(component instanceof OpenLayers.Geometry.LineString)) {
throw "component should be an OpenLayers.Geometry.LineString";
}
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.MultiLineString"
});

View File

@@ -0,0 +1,60 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* MultiPoint is a collection of Points.
*
* @requires OpenLayers/Geometry/Collection.js
*/
OpenLayers.Geometry.MultiPoint = OpenLayers.Class.create();
OpenLayers.Geometry.MultiPoint.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.Collection, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.Point)} components
*/
initialize: function(components) {
OpenLayers.Geometry.Collection.prototype.initialize.apply(this,
arguments);
},
/**
* adds component to the MultiPoint, checking type
*
* @param {OpenLayers.Geometry.Point} component point to add
* @param {int} index Index into the array to insert the component
*/
addComponent: function(component, index) {
if (!(component instanceof OpenLayers.Geometry.Point)) {
throw "component should be an OpenLayers.Geometry.Point";
}
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
arguments);
},
/**
* Wrapper for addComponent()
*
* @param {OpenLayers.Geometry.Point} point
* @param {int} index
*/
addPoint: function(point, index) {
this.addComponent(point, index);
},
/**
* Wrapper for removeComponent()
*
* @param {OpenLayers.Geometry.Point} point
*/
removePoint: function(point){
this.removeComponent(point);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.MultiPoint"
});

View File

@@ -0,0 +1,45 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* MultiPolygon is a collection of Polygons.
*
* @requires OpenLayers/Geometry/Collection.js
*/
OpenLayers.Geometry.MultiPolygon = OpenLayers.Class.create();
OpenLayers.Geometry.MultiPolygon.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.Collection, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.Polygon)} components
*/
initialize: function(components) {
OpenLayers.Geometry.Collection.prototype.initialize.apply(this,
arguments);
},
/**
* adds component to the MultiPolygon, checking type
*
* @param {OpenLayers.Geometry.Polygon} component Polygon to add
* @param {int} index Index into the array to insert the component
*/
addComponent: function(component, index) {
if (!(component instanceof OpenLayers.Geometry.Polygon)) {
var throwStr = "component should be an " +
"OpenLayers.Geometry.Polygon but is an " +
component.CLASS_NAME;
throw throwStr;
}
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.MultiPolygon"
});

View File

@@ -0,0 +1,135 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* The Point class is a subclass of Geometry and also a subclass of the
* non-vector OpenLayers.LonLat class. The basic functionality that this adds
* is the ability to switch between lon/lat and x/y at will, as well some
* convenience functions to create a Bounds from a point and measure the
* distance between two points.
*
* getX() and setX() should be used to access the x or lon variables.
*
* @requires OpenLayers/BaseTypes.js
* @requires OpenLayers/Geometry.js
*/
OpenLayers.Geometry.Point = OpenLayers.Class.create();
OpenLayers.Geometry.Point.prototype =
OpenLayers.Class.inherit(OpenLayers.LonLat, OpenLayers.Geometry, {
/** @type float */
x: null,
/** @type float */
y: null,
/**
* @constructor
*
* @param {float} x
* @param {float} y
*/
initialize: function(x, y) {
OpenLayers.LonLat.prototype.initialize.apply(this, arguments);
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
this.x = this.lon;
this.y = this.lat;
},
/**
* @returns An exact clone of this OpenLayers.Geometry.Point
* @type OpenLayers.Geometry.Point
*/
clone: function(obj) {
if (obj == null) {
obj = new OpenLayers.Geometry.Point(this.x, this.y);
}
// catch any randomly tagged-on properties
OpenLayers.Util.applyDefaults(obj, this);
return obj;
},
/**
* Sets the x coordinate
*
* @param {float} x
*/
setX: function(x) {
this.lon = x;
this.x = x;
},
/**
* Sets the y coordinate
*
* @param {float} y
*/
setY: function(y) {
this.lat = y;
this.y = y;
},
/**
* @type float
*/
getX: function() {
return this.lon;
},
/**
* @type float
*/
getY: function() {
return this.lat;
},
/** Create a new Bounds based on the lon/lat
*
*/
calculateBounds: function () {
this.bounds = new OpenLayers.Bounds(this.lon, this.lat,
this.lon, this.lat);
},
/**
* @param {OpenLayers.Geometry.Point} point
*/
distanceTo: function(point) {
var distance = 0.0;
if ( (this.x != null) && (this.y != null) &&
(point != null) && (point.x != null) && (point.y != null) ) {
var dx2 = Math.pow(this.x - point.x, 2);
var dy2 = Math.pow(this.y - point.y, 2);
distance = Math.sqrt( dx2 + dy2 );
}
return distance;
},
/**
* @returns the coordinates as a string
* @type String
*/
toString: function() {
return this.toShortString();
},
/**
* Moves a point in place
* @param {Float} x
* @param {Float} y
*/
move: function(x, y) {
this.setX(this.x + x);
this.setY(this.y + y);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Point"
});

View File

@@ -0,0 +1,66 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* Polygon is a collection of Geometry.LinearRings.
*
* The first ring (this.component[0])is the outer bounds of the polygon and
* all subsequent rings (this.component[1-n]) are internal holes.
*
* @requires OpenLayers/Geometry/Collection.js
*/
OpenLayers.Geometry.Polygon = OpenLayers.Class.create();
OpenLayers.Geometry.Polygon.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry.Collection, {
/**
* @constructor
*
* @param {Array(OpenLayers.Geometry.LinearRing)}
*/
initialize: function(components) {
OpenLayers.Geometry.Collection.prototype.initialize.apply(this,
arguments);
},
/**
* adds a component to the Polygon, checking type
*
* @param {OpenLayers.Geometry.LinearRing} point to add
* @param {int} index Index into the array to insert the component
*/
addComponent: function(component, index) {
if (!(component instanceof OpenLayers.Geometry.LinearRing)) {
var throwStr = "component should be an " +
"OpenLayers.Geometry.LinearRing but is a " +
component.CLASS_NAME;
throw throwStr;
}
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
arguments);
},
/** Calculated by subtracting the areas of the internal holes from the
* area of the outer hole.
*
* @returns The area of the geometry
* @type float
*/
getArea: function() {
var area = 0.0;
if ( this.components && (this.components.length > 0)) {
area += Math.abs(this.components[0].getArea());
for (var i = 1; i < this.components.length; i++) {
area -= Math.abs(this.components[i].getArea());
}
}
return area;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Polygon"
});

View File

@@ -0,0 +1,76 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* A Rectangle is a simple geometry. It is specified by a a point (x and y)
* and dimensions (width and height), all of which are directly accessible as
* properties.
*
* @requires OpenLayers/Geometry.js
*/
OpenLayers.Geometry.Rectangle = OpenLayers.Class.create();
OpenLayers.Geometry.Rectangle.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry, {
/** @type float */
x: null,
/** @type float */
y: null,
/** @type float */
width: null,
/** @type float */
height: null,
/**
* @constructor
*
* @param {array} points
*/
initialize: function(x, y, width, height) {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
},
/**
*
*/
calculateBounds: function() {
this.bounds = new OpenLayers.Bounds(this.x, this.y,
this.x + this.width,
this.y + this.height);
},
/**
* @returns The length of the geometry
* @type float
*/
getLength: function() {
var length = (2 * this.width) + (2 * this.height);
return length;
},
/**
* @returns The area of the geometry
* @type float
*/
getArea: function() {
var area = this.width * this.height;
return area;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Rectangle"
});

View File

@@ -0,0 +1,25 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Geometry.js
*/
OpenLayers.Geometry.Surface = OpenLayers.Class.create();
OpenLayers.Geometry.Surface.prototype =
OpenLayers.Class.inherit(OpenLayers.Geometry, {
/**
* @constructor
*
*/
initialize: function() {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Surface"
});

165
lib/OpenLayers/Handler.js Normal file
View File

@@ -0,0 +1,165 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Base class to construct a higher-level handler for event sequences.
* Handlers are created by controls, which ultimately have the responsibility
* of making changes to the map.
*
* @class
*/
OpenLayers.Handler = OpenLayers.Class.create();
OpenLayers.Handler.MOD_NONE = 0;
OpenLayers.Handler.MOD_SHIFT = 1;
OpenLayers.Handler.MOD_CTRL = 2;
OpenLayers.Handler.MOD_ALT = 4;
OpenLayers.Handler.prototype = {
/**
* @type String
* @private
*/
id: null,
/**
* The control that initialized this handler.
* @type OpenLayers.Control
* @private
*/
control: null,
/**
* @type OpenLayers.Map
* @private
*/
map: null,
/**
* @type integer
*/
// keyMask: OpenLayers.Handler.MOD_NONE,
keyMask: null,
/**
* @type Boolean
* @private
*/
active: false,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks A hash of callback functions
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Util.extend(this, options);
this.control = control;
this.callbacks = callbacks;
if (control.map) {
this.setMap(control.map);
}
OpenLayers.Util.extend(this, options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
},
setMap: function (map) {
this.map = map;
},
checkModifiers: function (evt) {
if(this.keyMask == null) {
return true;
}
/* calculate the keyboard modifier mask for this event */
var keyModifiers =
(evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |
(evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |
(evt.altKey ? OpenLayers.Handler.MOD_ALT : 0);
/* if it differs from the handler object's key mask,
bail out of the event handler */
return (keyModifiers == this.keyMask);
},
/**
* Turn on the handler. Returns false if the handler was already active.
*
* @type {Boolean}
*/
activate: function() {
if(this.active) {
return false;
}
// register for event handlers defined on this class.
var events = OpenLayers.Events.prototype.BROWSER_EVENTS;
for (var i = 0; i < events.length; i++) {
if (this[events[i]]) {
this.register(events[i], this[events[i]]);
}
}
this.active = true;
return true;
},
/**
* Turn off the handler. Returns false if the handler was already inactive.
*
* @type {Boolean}
*/
deactivate: function() {
if(!this.active) {
return false;
}
// unregister event handlers defined on this class.
var events = OpenLayers.Events.prototype.BROWSER_EVENTS;
for (var i = 0; i < events.length; i++) {
if (this[events[i]]) {
this.unregister(events[i], this[events[i]]);
}
}
this.active = false;
return true;
},
/**
* trigger the control's named callback with the given arguments
*/
callback: function (name, args) {
if (this.callbacks[name]) {
this.callbacks[name].apply(this.control, args);
}
},
/**
* register an event on the map
*/
register: function (name, method) {
// TODO: deal with registerPriority in 3.0
this.map.events.registerPriority(name, this, method);
},
/**
* unregister an event from the map
*/
unregister: function (name, method) {
this.map.events.unregister(name, this, method);
},
/**
*
*/
destroy: function () {
// eliminate circular references
this.control = this.map = null;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler"
};

View File

@@ -0,0 +1,126 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler for dragging a rectangle across the map. Box is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
*/
OpenLayers.Handler.Box = OpenLayers.Class.create();
OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/**
* @type OpenLayers.Handler.Drag
*/
dragHandler: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
var callbacks = {
"down": this.startBox,
"move": this.moveBox,
"out": this.removeBox,
"up": this.endBox
};
this.dragHandler = new OpenLayers.Handler.Drag(
this, callbacks, {keyMask: this.keyMask});
},
setMap: function (map) {
OpenLayers.Handler.prototype.setMap.apply(this, arguments);
if (this.dragHandler) {
this.dragHandler.setMap(map);
}
},
/**
* @param {Event} evt
*/
startBox: function (xy) {
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
this.dragHandler.start,
null,
null,
"absolute",
"2px solid red");
this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox);
// TBD: use CSS classes instead
this.map.div.style.cursor = "crosshair";
},
/**
*/
moveBox: function (xy) {
var deltaX = Math.abs(this.dragHandler.start.x - xy.x);
var deltaY = Math.abs(this.dragHandler.start.y - xy.y);
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
if (xy.x < this.dragHandler.start.x) {
this.zoomBox.style.left = xy.x+"px";
}
if (xy.y < this.dragHandler.start.y) {
this.zoomBox.style.top = xy.y+"px";
}
},
/**
*/
endBox: function(end) {
var result;
if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||
Math.abs(this.dragHandler.start.y - end.y) > 5) {
var start = this.dragHandler.start;
var top = Math.min(start.y, end.y);
var bottom = Math.max(start.y, end.y);
var left = Math.min(start.x, end.x);
var right = Math.max(start.x, end.x);
result = new OpenLayers.Bounds(left, bottom, right, top);
} else {
result = this.dragHandler.start.clone(); // i.e. OL.Pixel
}
this.removeBox();
// TBD: use CSS classes instead
this.map.div.style.cursor = "default";
this.callback("done", [result]);
},
/**
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeBox: function() {
this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null;
},
activate: function () {
OpenLayers.Handler.prototype.activate.apply(this, arguments);
this.dragHandler.activate();
},
deactivate: function () {
OpenLayers.Handler.prototype.deactivate.apply(this, arguments);
this.dragHandler.deactivate();
},
CLASS_NAME: "OpenLayers.Handler.Box"
});

View File

@@ -0,0 +1,110 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler for dragging a rectangle across the map. Drag is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Events.js
*/
OpenLayers.Handler.Drag = OpenLayers.Class.create();
OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/**
* When a mousedown event is received, we want to record it, but not set
* 'dragging' until the mouse moves after starting.
*
* @type boolean
**/
started: false,
/** @type boolean **/
dragging: null,
/** @type OpenLayers.Pixel **/
start: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
},
mousedown: function (evt) {
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
this.started = true;
this.dragging = null;
this.start = evt.xy.clone();
// TBD replace with CSS classes
this.map.div.style.cursor = "move";
this.callback("down", [evt.xy]);
OpenLayers.Event.stop(evt);
return false;
}
},
mousemove: function (evt) {
if (this.started) {
this.dragging = true;
this.callback("move", [evt.xy]);
}
},
mouseup: function (evt) {
if (this.started) {
this.started = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
this.callback("up", [evt.xy]);
}
},
mouseout: function (evt) {
if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.started = false;
this.dragging = null;
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
this.callback("out", []);
}
},
/**
* @param {Event} evt
*
* @type Boolean
*/
click: function (evt) {
// throw away the first left click event that happens after a mouse up
if (OpenLayers.Event.isLeftClick(evt) && this.dragging != null) {
this.dragging = null;
return false;
}
this.started = false;
},
activate: function (evt) {
OpenLayers.Handler.prototype.activate.apply(this, arguments);
document.onselectstart = function() { return false; };
this.dragging = null;
},
deactivate: function (evt) {
OpenLayers.Handler.prototype.deactivate.apply(this, arguments);
document.onselectstart = null;
this.dragging = null;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Drag"
});

View File

@@ -0,0 +1,59 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler for dragging a rectangle across the map. Keyboard is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Events.js
*/
OpenLayers.Handler.Keyboard = OpenLayers.Class.create();
OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/* http://www.quirksmode.org/js/keys.html explains key x-browser
key handling quirks in pretty nice detail */
/* supported named callbacks are: keyup, keydown, keypress */
/** constant */
KEY_EVENTS: ["keydown", "keypress", "keyup"],
/** @type Function
* @private
*/
eventListener: null,
initialize: function () {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
// cache the bound event listener method so it can be unobserved later
this.eventListener = this.handleKeyEvent.bindAsEventListener(this);
},
activate: function() {
OpenLayers.Handler.prototype.activate.apply(this, arguments);
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
OpenLayers.Event.observe(
window, this.KEY_EVENTS[i], this.eventListener);
}
},
deactivate: function() {
OpenLayers.Handler.prototype.activate.apply(this, arguments);
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
OpenLayers.Event.stopObserving(
document, this.KEY_EVENTS[i], this.eventListener);
}
},
handleKeyEvent: function (evt) {
if (this.checkModifiers(evt)) {
this.callback(evt.type, [evt.charCode || evt.keyCode]);
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Keyboard"
});

View File

@@ -0,0 +1,105 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler for wheel up/down events.
*
* @class
* @requires OpenLayers/Handler.js
*/
OpenLayers.Handler.MouseWheel = OpenLayers.Class.create();
OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/** @type function **/
wheelListener: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
this.wheelListener = this.onWheelEvent.bindAsEventListener(this);
},
/**
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
*/
/** Catch the wheel event and handle it xbrowserly
*
* @param {Event} e
*/
onWheelEvent: function(e){
// first check keyboard modifiers
if (!this.checkModifiers(e)) return;
// first determine whether or not the wheeling was inside the map
var inMap = false;
var elem = OpenLayers.Event.element(e);
while(elem != null) {
if (this.map && elem == this.map.div) {
inMap = true;
break;
}
elem = elem.parentNode;
}
if (inMap) {
var delta = 0;
if (!e) {
e = window.event;
}
if (e.wheelDelta) {
delta = e.wheelDelta/120;
if (window.opera) {
delta = -delta;
}
} else if (e.detail) {
delta = -e.detail / 3;
}
if (delta) {
// add the mouse position to the event because mozilla has a bug
// with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
// getLonLatFromViewPortPx(e) returns wrong values
// TODO FIXME FIXME this might not be the right way to port the 2.3 behavior
e.xy = this.map.events.getMousePosition(e);
if (delta < 0) {
this.callback("down", [e, delta]);
} else {
this.callback("up", [e, delta]);
}
}
//only wheel the map, not the window
OpenLayers.Event.stop(e);
}
},
activate: function (evt) {
OpenLayers.Handler.prototype.activate.apply(this, arguments);
//register mousewheel events specifically on the window and document
var wheelListener = this.wheelListener;
OpenLayers.Event.observe(window, "DOMMouseScroll", wheelListener);
OpenLayers.Event.observe(window, "mousewheel", wheelListener);
OpenLayers.Event.observe(document, "mousewheel", wheelListener);
},
deactivate: function (evt) {
OpenLayers.Handler.prototype.deactivate.apply(this, arguments);
// unregister mousewheel events specifically on the window and document
var wheelListener = this.wheelListener;
OpenLayers.Event.stopObserving(window, "DOMMouseScroll", wheelListener);
OpenLayers.Event.stopObserving(window, "mousewheel", wheelListener);
OpenLayers.Event.stopObserving(document, "mousewheel", wheelListener);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.MouseWheel"
});

View File

@@ -0,0 +1,216 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler to draw a path on the map. Path is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler/Point.js
* @requires OpenLayers/Geometry/Point.js
* @requires OpenLayers/Geometry/LineString.js
*/
OpenLayers.Handler.Path = OpenLayers.Class.create();
OpenLayers.Handler.Path.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler.Point, {
/**
* @type OpenLayers.Geometry.LineString
* @private
*/
line: null,
/**
* In freehand mode, the handler starts the path on mouse down, adds a point
* for every mouse move, and finishes the path on mouse up. Outside of
* freehand mode, a point is added to the path on every mouse click and
* double-click finishes the path.
*
* @type Boolean
*/
freehand: false,
/**
* If set, freehandToggle is checked on mouse events and will set the
* freehand mode to the opposite of this.freehand. To disallow toggling
* between freehand and non-freehand mode, set freehandToggle to null.
* Acceptable toggle values are 'shiftKey', 'ctrlKey', and 'altKey'.
*
* @type String
*/
freehandToggle: 'shiftKey',
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Array} callbacks An object with a 'done' property whos value is
* a function to be called when the path drawing is
* finished. The callback should expect to recieve a
* single argument, the line string geometry.
* If the callbacks object contains a 'point'
* property, this function will be sent each point
* as they are added. If the callbacks object contains
* a 'cancel' property, this function will be called when
* the handler is deactivated while drawing. The cancel
* should expect to receive a geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.Point.prototype.initialize.apply(this, arguments);
},
/**
* Add temporary geometries
*/
createGeometry: function() {
this.line = new OpenLayers.Geometry.LineString();
this.point = new OpenLayers.Geometry.Point();
},
/**
* Destroy temporary geometries
*/
destroyGeometry: function() {
this.line.destroy();
this.point.destroy();
},
/**
* Add point to geometry
*/
addPoint: function() {
this.line.addComponent(this.point.clone());
},
/**
* Determine whether to behanve in freehand mode or not.
*
* @type Boolean
*/
freehandMode: function(evt) {
return (this.freehandToggle && evt[this.freehandToggle]) ?
!this.freehand : this.freehand;
},
/**
* Modify the existing geometry given the new point
*
*/
modifyGeometry: function() {
var index = this.line.components.length - 1;
this.line.components[index].setX(this.point.x);
this.line.components[index].setY(this.point.y);
},
/**
* Render geometries on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.line, this.style);
this.layer.renderer.drawGeometry(this.point, this.style);
},
/**
* Return a clone of the relevant geometry.
*
* @type OpenLayers.Geometry.LineString
*/
geometryClone: function() {
return this.line.clone();
},
/**
* Handle mouse down. Add a new point to the geometry and render it.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mousedown: function(evt) {
// ignore double-clicks
if (this.lastDown && this.lastDown.equals(evt.xy)) {
return false;
}
if(this.lastDown == null) {
this.createGeometry();
}
this.mouseDown = true;
this.lastDown = evt.xy;
var lonlat = this.control.map.getLonLatFromPixel(evt.xy);
this.point.setX(lonlat.lon);
this.point.setY(lonlat.lat);
if((this.lastUp == null) || !this.lastUp.equals(evt.xy)) {
this.addPoint();
}
this.drawGeometry();
this.drawing = true;
return false;
},
/**
* Handle mouse move. Adjust the geometry and redraw.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mousemove: function (evt) {
if(this.drawing) {
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.setX(lonlat.lon);
this.point.setY(lonlat.lat);
if(this.mouseDown && this.freehandMode(evt)) {
this.addPoint();
} else {
this.modifyGeometry();
}
this.drawGeometry();
}
return true;
},
/**
* Handle mouse up. Send the latest point in the geometry to the control.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mouseup: function (evt) {
this.mouseDown = false;
if(this.drawing) {
if(this.freehandMode(evt)) {
this.finalize();
} else {
if(this.lastUp == null) {
this.addPoint();
}
this.lastUp = evt.xy;
this.callback("point", [this.point]);
}
return false;
}
return true;
},
/**
* Handle double-clicks. Finish the geometry and send it back
* to the control.
*
* @param {Event} evt
*/
dblclick: function(evt) {
if(!this.freehandMode(evt)) {
var index = this.line.components.length - 1;
this.line.removeComponent(this.line.components[index]);
this.finalize(this.line);
}
return false;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Path"
});

View File

@@ -0,0 +1,232 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler to draw a point on the map. Point is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Geometry/Point.js
*/
OpenLayers.Handler.Point = OpenLayers.Class.create();
OpenLayers.Handler.Point.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler, {
/**
* @type OpenLayers.Geometry.Point
* @private
*/
point: null,
/**
* @type OpenLayers.Layer.Vector
* @private
*/
layer: null,
/**
* @type Boolean
* @private
*/
drawing: false,
/**
* @type Boolean
* @private
*/
mouseDown: false,
/**
* @type OpenLayers.Pixel
* @private
*/
lastDown: null,
/**
* @type OpenLayers.Pixel
* @private
*/
lastUp: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Array} callbacks An object with a 'done' property whos value is
* a function to be called when the point drawing
* is finished. The callback should expect to
* recieve a single argument, the point geometry.
* If the callbacks object contains a 'cancel' property,
* this function will be called when the handler is deactivated
* while drawing. The cancel should expect to receive a geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
// TBD: deal with style
this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {});
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
},
/**
* turn on the handler
*/
activate: function() {
if(!OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
return false;
}
// create temporary vector layer for rendering geometry sketch
// TBD: this could be moved to initialize/destroy - setting visibility here
var options = {displayInLayerSwitcher: false};
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
this.map.addLayer(this.layer);
return true;
},
/**
* Add temporary geometries
*/
createGeometry: function() {
this.point = new OpenLayers.Geometry.Point();
},
/**
* turn off the handler
*/
deactivate: function() {
if(!OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
return false;
}
// call the cancel callback if mid-drawing
if(this.drawing) {
this.cancel();
}
this.map.removeLayer(this.layer, false);
this.layer.destroy();
return true;
},
/**
* Destroy the temporary geometries
*/
destroyGeometry: function() {
this.point.destroy();
},
/**
* Finish the geometry and call the "done" callback.
*/
finalize: function() {
this.layer.renderer.clear();
this.callback("done", [this.geometryClone()]);
this.destroyGeometry();
this.drawing = false;
this.mouseDown = false;
this.lastDown = null;
this.lastUp = null;
},
/**
* Finish the geometry and call the "cancel" callback.
*/
cancel: function() {
this.layer.renderer.clear();
this.callback("cancel", [this.geometryClone()]);
this.destroyGeometry();
this.drawing = false;
this.mouseDown = false;
this.lastDown = null;
this.lastUp = null;
},
/**
* Handle double clicks.
*/
dblclick: function(evt) {
OpenLayers.Event.stop(evt);
return false;
},
/**
* Render geometries on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.point, this.style);
},
/**
* Return a clone of the relevant geometry.
*
* @type OpenLayers.Geometry.Point
*/
geometryClone: function() {
return this.point.clone();
},
/**
* Handle mouse down. Add a new point to the geometry and render it.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mousedown: function(evt) {
// check keyboard modifiers
if(!this.checkModifiers(evt)) {
return true;
}
// ignore double-clicks
if(this.lastDown && this.lastDown.equals(evt.xy)) {
return true;
}
if(this.lastDown == null) {
this.createGeometry();
}
this.lastDown = evt.xy;
this.drawing = true;
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.setX(lonlat.lon);
this.point.setY(lonlat.lat);
this.drawGeometry();
return false;
},
/**
* Handle mouse move. Adjust the geometry and redraw.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mousemove: function (evt) {
if(this.drawing) {
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.setX(lonlat.lon);
this.point.setY(lonlat.lat);
this.drawGeometry();
}
return true;
},
/**
* Handle mouse up. Send the latest point in the geometry to the control.
* Return determines whether to propagate the event on the map.
*
* @param {Event} evt
* @type Boolean
*/
mouseup: function (evt) {
if(this.drawing) {
this.finalize(this.point);
return false;
} else {
return true;
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Point"
});

View File

@@ -0,0 +1,91 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler to draw a path on the map. Polygon is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler/Path.js
* @requires OpenLayers/Geometry/Polygon.js
*/
OpenLayers.Handler.Polygon = OpenLayers.Class.create();
OpenLayers.Handler.Polygon.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler.Path, {
/**
* @type OpenLayers.Geometry.Polygon
* @private
*/
polygon: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Array} callbacks An object with a 'done' property whos value is
* a function to be called when the path drawing is
* finished. The callback should expect to recieve a
* single argument, the polygon geometry.
* If the callbacks object contains a 'point'
* property, this function will be sent each point
* as they are added. If the callbacks object contains
* a 'cancel' property, this function will be called when
* the handler is deactivated while drawing. The cancel
* should expect to receive a geometry.
* @param {Object} options
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.Path.prototype.initialize.apply(this, arguments);
},
/**
* Add temporary geometries
*/
createGeometry: function() {
this.polygon = new OpenLayers.Geometry.Polygon();
this.line = new OpenLayers.Geometry.LinearRing();
this.polygon.addComponent(this.line);
this.point = new OpenLayers.Geometry.Point();
},
/**
* Destroy temporary geometries
*/
destroyGeometry: function() {
this.polygon.destroy();
this.point.destroy();
},
/**
* Modify the existing geometry given the new point
*
*/
modifyGeometry: function() {
var index = this.line.components.length - 2;
this.line.components[index].setX(this.point.x);
this.line.components[index].setY(this.point.y);
},
/**
* Render geometries on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.polygon, this.style);
this.layer.renderer.drawGeometry(this.point, this.style);
},
/**
* Return a clone of the relevant geometry.
*
* @type OpenLayers.Geometry.Polygon
*/
geometryClone: function() {
return this.polygon.clone();
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Polygon"
});

View File

@@ -0,0 +1,122 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Handler to draw a path on the map. Polygon is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
*/
OpenLayers.Handler.Select = OpenLayers.Class.create();
OpenLayers.Handler.Select.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler, {
/**
* @type {Int}
*/
layerIndex: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Array} layers List of OpenLayers.Layer.Vector
* @param {Array} callbacks An object with a 'over' property whos value is
* a function to be called when the mouse is over
* a feature. The callback should expect to recieve
* a single argument, the geometry.
* @param {Object} options
*/
initialize: function(control, layer, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);
this.layer = layer;
},
/**
* Handle mouse down. Call the "up" callback if down on a feature.
*
* @param {Event} evt
*/
mousedown: function(evt) {
return this.select('down', evt);
},
/**
* Handle mouse moves. Call the "over" callback if over a feature.
*
* @param {Event} evt
*/
mousemove: function(evt) {
this.select('move', evt);
return true;
},
/**
* Handle mouse moves. Call the "down" callback if up on a feature.
*
* @param {Event} evt
*/
mouseup: function(evt) {
return this.select('up', evt);
},
/**
* Capture double-clicks.
*
*/
dblclick: function(evt) {
return false;
},
/**
* Trigger the appropriate callback if a feature is under the mouse.
*
* @param {String} type Callback key
*/
select: function(type, evt) {
var geometry = this.layer.renderer.getGeometryFromEvent(evt);
if(geometry) {
if (geometry.parent) {
geometry = geometry.parent;
}
this.callback(type, [geometry]);
return false; // stop event propagation
}
return true;
},
/**
* Turn on the handler. Returns false if the handler was already active.
*
* @type {Boolean}
*/
activate: function() {
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
this.layerIndex = this.layer.div.style.zIndex;
this.layer.div.style.zIndex = this.map.Z_INDEX_BASE['Popup'] - 1;
return true;
} else {
return false;
}
},
/**
* Turn onf the handler. Returns false if the handler was already active.
*
* @type {Boolean}
*/
deactivate: function() {
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
this.layer.div.style.zIndex = this.layerIndex;
return true;
} else {
return false;
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Handler.Select"
});

View File

@@ -13,17 +13,20 @@ OpenLayers.Layer.Boxes = OpenLayers.Class.create();
OpenLayers.Layer.Boxes.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
/**
* @constructor
*/
initialize: function () {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
},
/** Calculate the pixel location for the marker, create it, and
* add it to the layer's div
*
* @private
*
* @param {OpenLayers.Marker.Box} marker
*/
* add it to the layer's div
*
* @private
*
* @param {OpenLayers.Marker.Box} marker
*/
drawMarker: function(marker) {
var bounds = marker.bounds;
var topleft = this.map.getLayerPxFromLonLat(

113
lib/OpenLayers/Layer/GML.js Normal file
View File

@@ -0,0 +1,113 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* Create a vector layer by parsing a GML file. The GML file is
* passed in as a parameter.
* @class
*
* @requires OpenLayers/Layer/Vector.js
* @requires OpenLayers/Ajax.js
*/
OpenLayers.Layer.GML = OpenLayers.Class.create();
OpenLayers.Layer.GML.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Vector, {
/**
* Flag for whether the GML data has been loaded yet.
* @type Boolean
*/
loaded: false,
format: null,
/**
* @constructor
*
* @param {String} name
* @param {String} url URL of a GML file.
* @param {Object} options Hashtable of extra options to tag onto the layer.
* Options renderer {Object}: Typically SvgRenderer or VmlRenderer.
*/
initialize: function(name, url, options) {
var newArguments = new Array()
newArguments.push(name, options);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
this.url = url;
},
/**
* 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.
*
* @param {Boolean} visible Whether or not to display the layer
* (if in range)
* @param {Boolean} noEvent
*/
setVisibility: function(visibility, noEvent) {
OpenLayers.Layer.Vector.prototype.setVisibility.apply(this, arguments);
if(this.visibility && !this.loaded){
// Load the GML
this.loadGML();
}
},
/**
* 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.
* @param {Object} bounds
* @param {Object} zoomChanged
* @param {Object} minor
*/
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();
}
},
loadGML: function() {
if (!this.loaded) {
var results = OpenLayers.loadURL(this.url, null, this, this.requestSuccess, this.requestFailure);
this.loaded = true;
}
},
/**
* Process GML after it has been loaded.
* Called by initialise() and loadUrl() after the GML has been loaded.
* @private
* @param {String} request
*/
requestSuccess:function(request) {
var doc = request.responseXML;
if (!doc || request.fileType!="XML") {
doc = request.responseText;
}
var gml = this.format ? new this.format() : new OpenLayers.Format.GML();
this.addFeatures(gml.read(doc));
},
/**
* Process a failed loading of GML.
* Called by initialise() and loadUrl() if there was a problem loading GML.
* @private
* @param {String} request
*/
requestFailure: function(request) {
alert("Error in loading GML file "+this.url);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.GML"
});

View File

@@ -7,6 +7,7 @@
* @class
*
* @requires OpenLayers/Layer/Markers.js
* @requires OpenLayers/Ajax.js
*/
OpenLayers.Layer.GeoRSS = OpenLayers.Class.create();
OpenLayers.Layer.GeoRSS.prototype =

View File

@@ -4,6 +4,7 @@
// @requires OpenLayers/Layer/Grid.js
/**
* @class
* @requires OpenLayers/Layer/Grid.js
*/
OpenLayers.Layer.MapServer = OpenLayers.Class.create();
OpenLayers.Layer.MapServer.prototype =

View File

@@ -0,0 +1,321 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Layer.js
* @requires OpenLayers/Renderer.js
*/
OpenLayers.Layer.Vector = OpenLayers.Class.create();
OpenLayers.Layer.Vector.prototype =
OpenLayers.Class.inherit(OpenLayers.Layer, {
/** @type Boolean */
isBaseLayer: false,
/** @type Boolean */
isFixed: false,
/** @type Boolean */
isVector: true,
/** @type {Array(OpenLayer.Feature.Vector)} */
features: null,
/** @type {Array(OpenLayers.Feature.Vector)} */
selectedFeatures: [],
/** @type {Boolean} */
editing: false,
/** @type {Boolean} */
editable: false,
/** @type {Boolean} */
reportError: true,
/**
* List of supported Renderer classes. Add to this list to
* add support for additional renderers. This list is ordered:
* the first renderer which returns true for the 'supported()'
* method will be used, if not defined in the 'renderer' option.
*
* @type {Array(String)}
*/
renderers: ['SVG', 'VML'],
/** @type OpenLayers.Renderer */
renderer: null,
/**
* geometryType allows you to limit the types of geometries this
* layer supports. This should be set to something like
* "OpenLayers.Geometry.Point" to limit types.
*
* @type string
*/
geometryType: null,
/** Whether the Vector Layer features have been drawn yet.
*
* @type boolean
*/
drawn: false,
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hashtable of extra options to tag onto the layer.
* Options renderer {Object}: Typically SVGRenderer or VMLRenderer.
*/
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
// allow user-set renderer, otherwise assign one
if (!this.renderer || !this.renderer.supported()) {
this.assignRenderer();
}
// if no valid renderer found, display error
if (!this.renderer || !this.renderer.supported()) {
this.renderer = null;
this.displayError();
}
this.features = new Array();
this.selectedFeatures = new Array();
},
/**
*
*/
destroy: function() {
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
// HACK HACK -- I believe we should be iterating and
// calling feature[i].destroy() here.
this.features = null;
this.selectedFeatures = null;
this.editing = null;
this.editable = null;
if (this.renderer) {
this.renderer.destroy();
}
this.renderer = null;
this.geometryType = null;
this.drawn = null;
},
/** Iterates through the available renderer implementations and selects
* and assigns the first one whose "supported()" function returns true.
*
* @private
*
*/
assignRenderer: function() {
for (var i = 0; i < this.renderers.length; i++) {
var rendererClass = OpenLayers.Renderer[this.renderers[i]];
if (rendererClass && rendererClass.prototype.supported()) {
this.renderer = new rendererClass(this.div);
break;
}
}
},
/**
* Let the user know their browser isn't supported.
*
* @private
*
*/
displayError: function() {
if (this.reportError) {
var message = "Your browser does not support vector rendering. " +
"Currently supported renderers are:\n";
message += this.renderers.join("\n");
alert(message);
}
},
/** The layer has been added to the map.
*
* If there is no renderer set, the layer can't be used. Remove it.
* Otherwise, give the renderer a reference to the map and set its size.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
if (!this.renderer) {
this.map.removeLayer(this);
} else {
this.renderer.map = this.map;
this.renderer.setSize(this.map.getSize());
}
},
/** Notify the renderer of the change in size.
*
*/
onMapResize: function() {
OpenLayers.Layer.prototype.onMapResize.apply(this, arguments);
this.renderer.setSize(this.map.getSize());
},
/** Reset the vector layer's div so that it once again is lined up with
* the map. Notify the renderer of the change of extent, and in the
* case of a change of zoom level (resolution), have the
* renderer reproject.
*
* If the layer has not yet been drawn, cycle through the layer's
* features and draw each one.
*
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
* @param {Boolean} dragging
*/
moveTo: function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
if (!dragging) {
this.div.style.left = - parseInt(this.map.layerContainerDiv.style.left) + "px";
this.div.style.top = - parseInt(this.map.layerContainerDiv.style.top) + "px";
var extent = this.map.getExtent();
this.renderer.setExtent(extent);
}
if (zoomChanged) {
this.renderer.reproject();
}
if (!this.drawn) {
this.drawn = true;
for(var i = 0; i < this.features.length; i++) {
var feature = this.features[i];
this.renderer.drawGeometry(feature.geometry, feature.style);
}
}
},
/**
* @param {Array(OpenLayers.Feature.Vector} features
*/
addFeatures: function(features) {
if (!(features instanceof Array)) {
features = [features];
}
for (var i = 0; i < features.length; i++) {
var feature = features[i];
if (this.geometryType &&
!(feature.geometry instanceof this.geometryType)) {
var throwStr = "addFeatures : component should be an " +
this.geometryType.prototype.CLASS_NAME;
throw throwStr;
}
this.features.push(feature);
//give feature reference to its layer
feature.layer = this;
if (this.drawn) {
this.renderer.drawGeometry(feature.geometry, feature.style);
}
this.onFeatureInsert(feature);
}
},
/**
* @param {Array(OpenLayers.Feature.Vector} features
*/
removeFeatures: function(features) {
if (!(features instanceof Array)) {
features = [features];
}
for (var i = 0; i < features.length; i++) {
var feature = features[i];
this.features = OpenLayers.Util.removeItem(this.features, feature);
this.renderer.eraseGeometry(feature.geometry);
}
},
/**
* @param {String} fid
* @param {Object} style
*/
redrawFeature: function(fid, style) {
for (var i = 0; i < this.features.length; i++) {
var feature = this.features[i];
if (feature.fid == fid) {
this.renderer.drawGeometry(feature.geometry, style);
}
}
},
/**
* Start editing the layer
*
* @returns Whether or not the layer is editable
* @type Boolean
*/
unlock: function() {
if(this.editable) {
this.editing = true;
}
return this.editable;
},
/**
* Stop editing the layer
*
* @return Whether or not the layer *was* editing
* HACK HACK This return value seems wierd to me.
* @type Boolean
*/
lock: function() {
if(this.editing) {
this.editing = false;
}
return this.editing;
},
/**
* Unselect the selected features
* i.e. clears the featureSelection array
* change the style back
clearSelection: function() {
var vectorLayer = this.map.vectorLayer;
for (var i = 0; i < this.map.featureSelection.length; i++) {
var featureSelection = this.map.featureSelection[i];
vectorLayer.renderer.drawGeometry(featureSelection.geometry,
vectorLayer.style);
}
this.map.featureSelection = [];
},
*/
/**
* method called when a feature is inserted.
* Does nothing by default. Override this if you
* need to do something on feature updates.
*
* @param {OpenLayers.Feature.Vector} feature
*/
onFeatureInsert: function(feature) {
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Vector"
});

View File

@@ -6,13 +6,12 @@
/**
* @class
*
* @requires OpenLayers/Layer/Grid.js
* @requires OpenLayers/Layer/Vector.js
* @requires OpenLayers/Layer/Markers.js
*/
OpenLayers.Layer.WFS = OpenLayers.Class.create();
OpenLayers.Layer.WFS.prototype =
OpenLayers.Class.inherit( OpenLayers.Layer.Grid,
OpenLayers.Layer.Markers, {
OpenLayers.Class.inherit( OpenLayers.Layer.Vector, OpenLayers.Layer.Markers, {
/** WFS layer is never a base layer.
*
@@ -20,29 +19,33 @@ OpenLayers.Layer.WFS.prototype =
*/
isBaseLayer: false,
buffer: 1,
/** Allow the user to specify special classes for features and tiles.
*
* This allows for easy-definition of behaviour. The defaults are
* set here, but to override it, the property should be set via
* the "options" parameter.
*/
/** @type Object */
featureClass: OpenLayers.Feature.WFS,
/** @type Object */
tileClass: OpenLayers.Tile.WFS,
/** the ratio of image/tile size to map size (this is the untiled buffer)
* @type int */
ratio: 2,
/** Hashtable of default key/value parameters
* @final @type Object */
DEFAULT_PARAMS: { service: "WFS",
version: "1.0.0",
request: "GetFeature",
typename: "docpoint"
request: "GetFeature"
},
/**
* If featureClass is defined, an old-style markers based
* WFS layer is created instead of a new-style vector layer.
* If sent, this should be a subclass of OpenLayers.Feature
*
* @type OpenLayers.Feature
*/
featureClass: null,
/**
* Should be calculated automatically.
*
* @type Boolean
*/
vectorMode: true,
/**
* @constructor
*
@@ -52,21 +55,40 @@ OpenLayers.Layer.WFS.prototype =
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, params, options) {
var newArguments = new Array();
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (options == undefined) { options = {}; }
var newArguments = new Array();
//uppercase params
if (options.featureClass || !OpenLayers.Layer.Vector || !OpenLayers.Feature.Vector) {
this.vectorMode = false;
}
// Turn off error reporting, browsers like Safari may work
// depending on the setup, and we don't want an unneccesary alert.
OpenLayers.Util.extend(options, {'reportError': false});
var newArguments=new Array()
newArguments.push(name, options);
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
if (!this.renderer || !this.vectorMode) {
this.vectorMode = false;
if (!options.featureClass) {
options.featureClass = OpenLayers.Feature.WFS;
}
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
}
if (this.params && this.params.typename && !this.options.typename) {
this.options.typename = this.params.typename;
}
if (!this.options.geometry_column) {
this.options.geometry_column = "the_geom";
}
this.params = params;
OpenLayers.Util.applyDefaults(
this.params,
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
this.url = url;
},
@@ -74,16 +96,22 @@ OpenLayers.Layer.WFS.prototype =
*
*/
destroy: function() {
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.destroy.apply(this, arguments);
} else {
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
}
},
/**
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments);
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments);
} else {
OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments);
}
},
/**
@@ -92,8 +120,86 @@ OpenLayers.Layer.WFS.prototype =
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);
} else {
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
}
// don't load wfs features while dragging, wait for drag end
if (dragging) {
// TBD try to hide the vector layer while dragging
// this.setVisibility(false);
// this will probably help for panning performances
return false;
}
if ( zoomChanged ) {
if (this.vectorMode) {
this.renderer.clear();
}
}
// don't load data if current zoom level doesn't match
if (this.options.minZoomLevel && this.map.getZoom() < this.options.minZoomLevel) {
return null;
};
if (bounds == null) {
bounds = this.map.getExtent();
}
var firstRendering = (this.tile == null);
//does the new bounds to which we need to move fall outside of the
// current tile's bounds?
var outOfBounds = (!firstRendering &&
!this.tile.bounds.containsBounds(bounds));
if ( zoomChanged || firstRendering || (!dragging && outOfBounds) ) {
//determine new tile bounds
var center = bounds.getCenterLonLat();
var tileWidth = bounds.getWidth() * this.ratio;
var tileHeight = bounds.getHeight() * this.ratio;
var tileBounds =
new OpenLayers.Bounds(center.lon - (tileWidth / 2),
center.lat - (tileHeight / 2),
center.lon + (tileWidth / 2),
center.lat + (tileHeight / 2));
//determine new tile size
var tileSize = this.map.getSize();
tileSize.w = tileSize.w * this.ratio;
tileSize.h = tileSize.h * this.ratio;
//determine new position (upper left corner of new bounds)
var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
var pos = this.map.getLayerPxFromLonLat(ul);
//formulate request url string
var url = this.getFullRequestString();
var params = { BBOX:tileBounds.toBBOX() };
url += "&" + OpenLayers.Util.getParameterString(params);
if (!this.tile) {
this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds,
url, tileSize);
this.tile.draw();
} else {
if (this.vectorMode) {
this.renderer.clear();
} else {
this.clearMarkers();
}
this.tile.destroy();
this.tile = null;
this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds,
url, tileSize);
this.tile.draw();
}
}
},
/**
@@ -112,60 +218,17 @@ OpenLayers.Layer.WFS.prototype =
}
//get all additions from superclasses
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
if (this.vectorMode) {
obj = OpenLayers.Layer.Vector.prototype.clone.apply(this, [obj]);
} else {
obj = OpenLayers.Layer.Markers.prototype.clone.apply(this, [obj]);
}
// copy/set any non-init, non-simple values here
return obj;
},
/**
* addTile creates a tile, initializes it (via 'draw' in this case), and
* adds it to the layer div.
*
* @param {OpenLayers.Bounds} bounds
*
* @returns The added OpenLayers.Tile.WFS
* @type OpenLayers.Tile.WFS
*/
addTile:function(bounds, position) {
var urls = new Array();
//add standard URL
urls.push( this.getFullRequestString() );
if (this.urls != null) {
// if there are more urls, add them.
for(var i=0; i < this.urls.length; i++) {
urls.push( this.getFullRequestString(null, this.urls[i]) );
}
}
return new this.tileClass(this, position, bounds,
urls, this.tileSize);
},
/**
* Catch changeParams and uppercase the new params to be merged in
* before calling changeParams on the super class.
*
* Once params have been changed, we will need to re-init our tiles
*
* @param {Object} newParams Hashtable of new params to use
*/
mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
if (this.grid != null) {
this._initTiles();
}
},
/** combine the layer's url with its params and these newParams.
*
* Add the SRS parameter from 'projection' -- this is probably
@@ -184,41 +247,90 @@ OpenLayers.Layer.WFS.prototype =
this, arguments);
},
commit: function() {
if (!this.writer) {
this.writer = new OpenLayers.Format.WFS({},this);
}
var data = this.writer.write(this.features);
var url = this.url;
if (OpenLayers.ProxyHost && this.url.startsWith("http")) {
url = OpenLayers.ProxyHost + escape(this.url);
}
var success = this.commitSuccess.bind(this);
var failure = this.commitFailure.bind(this)
//
OpenLayers.Ajax.serializeXMLToString(data);
// from prototype.js
new OpenLayers.Ajax.Request(url,
{ method: 'post',
postBody: data,
onComplete: success,
onFailure: failure
}
);
},
/**
* @param {String} featureID
* Called when the Ajax request returns a response
*
* @returns The Feature, found within one of the layer's tiles' features
* array, with a matching id.
* If none found or if null passed-in, returns null
* @type OpenLayers.Feature
* @param {XmlNode} response from server
*/
getFeature: function(featureID) {
var foundFeature = null;
if (featureID != null) {
commitSuccess: function(request) {
var response = request.responseText;
if (response.indexOf('SUCCESS') != -1) {
this.report('WFS Transaction: SUCCESS', response);
if (this.grid) {
for(var iRow = 0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow];
for(var iCol = 0; iCol < row.length; iCol++) {
var tile = row[iCol];
for(var i=0; i < tile.features.length; i++) {
var feature = tile.features[i];
if (feature.id == featureID) {
foundFeature = feature;
}
}
}
}
for(var i = 0; i < this.features.length; i++) {
i.state = null;
}
// TBD redraw the layer or reset the state of features
// foreach features: set state to null
} else if (response.indexOf('FAILED') != -1 ||
response.indexOf('Exception') != -1) {
this.report('WFS Transaction: FAILED', response);
}
return foundFeature;
},
/**
* Called when the Ajax request fails
*
* @param {XmlNode} response from server
*/
commitFailure: function(request) {},
/**
* Called with a 'success' message if the commit succeeded, otherwise
* a failure message, and the full text as a second parameter.
*
* @param {String} string reporting string
* @param {String} response full XML response
*/
commitReport: function(string, response) {
alert(string);
},
/**
* Refreshes all the features of the layer
*/
refresh: function() {
if (this.tile) {
if (this.vectorMode) {
this.renderer.clear();
OpenLayers.Util.clearArray(this.features);
} else {
this.clearMarkers();
OpenLayers.Util.clearArray(this.markers);
}
this.tile.draw();
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WFS"

View File

@@ -185,7 +185,7 @@ OpenLayers.Map.prototype = {
if (this.controls == null) {
if (OpenLayers.Control != null) { // running full or lite?
this.controls = [ new OpenLayers.Control.MouseDefaults(),
this.controls = [ new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.ArgParser()
];
@@ -1226,5 +1226,6 @@ OpenLayers.Map.prototype = {
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Map"
};

View File

@@ -5,6 +5,8 @@
/**
* @class
* @requires OpenLayers/Events.js
* @requires OpenLayers/Icon.js
*/
OpenLayers.Marker = OpenLayers.Class.create();
OpenLayers.Marker.prototype = {

View File

@@ -349,5 +349,6 @@ OpenLayers.Popup.prototype = {
this.mousedown = false;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Popup"
};

151
lib/OpenLayers/Renderer.js Normal file
View File

@@ -0,0 +1,151 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class Renderer is the base class for all renderers.
*
* This is based on a merger code written by Paul Spencer and Bertil Chapuis.
* It is largely composed of virtual functions that are to be implemented
* in technology-specific subclasses, but there is some generic code too.
*
* The functions that *are* implemented here merely deal with the maintenance
* of the size and extent variables, as well as the cached 'resolution'
* value.
*
* A note to the user that all subclasses should use getResolution() instead
* of directly accessing this.resolution in order to correctly use the
* cacheing system.
*
*/
OpenLayers.Renderer = OpenLayers.Class.create();
OpenLayers.Renderer.prototype =
{
/** @type DOMElement */
container: null,
/** @type OpenLayers.Bounds */
extent: null,
/** @type OpenLayers.Size */
size: null,
/** cache of current map resolution
* @type float */
resolution: null,
/** Reference to the map -- this is set in Vector's setMap()
* @type OpenLayers.Map */
map: null,
/**
* @constructor
*
* @param {String} containerID
*/
initialize: function(containerID) {
this.container = $(containerID);
},
/**
*
*/
destroy: function() {
this.container = null;
this.extent = null;
this.size = null;
this.resolution = null;
this.map = null;
},
/**
* This should be overridden by specific subclasses
*
* @returns Whether or not the browser supports the VML renderer
* @type Boolean
*/
supported: function() {
return false;
},
/**
* Set the visible part of the layer.
*
* Resolution has probably changed, so we nullify the resolution
* cache (this.resolution) -- this way it will be re-computed when
* next it is needed.
*
* @param {OpenLayers.Bounds} extent
*/
setExtent: function(extent) {
this.extent = extent.clone();
this.resolution = null;
},
/**
* Sets the size of the drawing surface.
*
* Resolution has probably changed, so we nullify the resolution
* cache (this.resolution) -- this way it will be re-computed when
* next it is needed.
*
* @param {OpenLayers.Size} size
*/
setSize: function(size) {
this.size = size.clone();
this.resolution = null;
},
/** Uses cached copy of resolution if available to minimize computing
*
* @returns The current map's resolution
* @type float
*/
getResolution: function() {
this.resolution = this.resolution || this.map.getResolution();
return this.resolution;
},
/**
* virtual function
*
* Draw a geometry on the specified layer.
*
* @param geometry {OpenLayers.Geometry}
* @param style {Object}
*/
drawGeometry: function(geometry, style) {},
/**
* virtual function
*
* Clear all vectors from the renderer
*
*/
clear: function() {},
/**
* virtual function
*
* Returns a geometry from an event that happened on a layer.
* How this happens is specific to the renderer.
*
* @param evt {OpenLayers.Event}
*
* @returns A geometry from an event that happened on a layer
* @type OpenLayers.Geometry
*/
getGeometryFromEvent: function(evt) {},
/**
* virtual function
*
* Remove a geometry from the renderer (by id)
*
* @param geometry {OpenLayers.Geometry}
*/
eraseGeometry: function(geometry) {},
/** @final @type String */
CLASS_NAME: "OpenLayers.Renderer"
};

View File

@@ -0,0 +1,269 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* This is another virtual class in that it should never be instantiated by
* itself as a Renderer. It exists because there is *tons* of shared
* functionality between different vector libraries which use nodes/elements
* as a base for rendering vectors.
*
* The highlevel bits of code that are implemented here are the adding and
* removing of geometries, which is essentially the same for any
* element-based renderer. The details of creating each node and drawing the
* paths are of course different, but the machinery is the same.
*
* @requires OpenLayers/Renderer.js
*/
OpenLayers.Renderer.Elements = OpenLayers.Class.create();
OpenLayers.Renderer.Elements.prototype =
OpenLayers.Class.inherit(OpenLayers.Renderer, {
/** @type DOMElement */
rendererRoot: null,
/** @type DOMElement */
root: null,
/** @type String */
xmlns: null,
/**
* @constructor
*
* @param {String} containerID
*/
initialize: function(containerID) {
OpenLayers.Renderer.prototype.initialize.apply(this, arguments);
this.rendererRoot = this.createRenderRoot();
this.root = this.createRoot();
this.rendererRoot.appendChild(this.root);
this.container.appendChild(this.rendererRoot);
},
/**
*
*/
destroy: function() {
this.clear();
this.rendererRoot = null;
this.root = null;
this.xmlns = null;
OpenLayers.Renderer.prototype.destroy.apply(this, arguments);
},
/**
* Remove all the elements from the root
*
*/
clear: function() {
if (this.root) {
while (this.root.childNodes.length > 0) {
this.root.removeChild(this.root.firstChild);
}
}
},
/**
* Cycle through the rendered nodes and reproject them (this should be
* called when the extent or size has changed);
*
* @param {OpenLayers.Bounds} extent
*/
reproject: function(extent) {
for (var i = 0; i < this.root.childNodes.length; i++) {
var node = this.root.childNodes[i];
//reproject node
// for the moment, this only really happens so as to reset
// the heaviness of the line relative to the resolution and
// the size of the circle for the Point object
this.reprojectNode(node);
}
},
/** This function is in charge of asking the specific renderer which type
* of node to create for the given geometry. All geometries in an
* Elements-based renderer consist of one node and some attributes. We
* have the nodeFactory() function which creates a node for us, but it
* takes a 'type' as input, and that is precisely what this function
* tells us.
*
* @param geometry {OpenLayers.Geometry}
*
* @returns The corresponding node type for the specified geometry
* @type String
*/
getNodeType: function(geometry) { },
/**
* Draw the geometry on the specified layer, creating new nodes,
* setting paths, setting style.
*
* @param {OpenLayers.Geometry} geometry
* @param {Object} style
*/
drawGeometry: function(geometry, style) {
if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") ||
(geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") ||
(geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) {
for (var i = 0; i < geometry.components.length; i++) {
this.drawGeometry(geometry.components[i], style);
}
return;
};
//first we create the basic node and add it to the root
var nodeType = this.getNodeType(geometry);
var node = this.nodeFactory(geometry.id, nodeType, geometry);
node.geometry = geometry;
node.olStyle = style;
this.root.appendChild(node);
//now actually draw the node, and style it
this.drawGeometryNode(node);
},
/**
* Given a node, draw a geometry on the specified layer.
*
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
* @param {Object} style
*/
drawGeometryNode: function(node, geometry, style) {
geometry = geometry || node.geometry;
style = style || node.olStyle;
var options = {
'isFilled': true,
'isStroked': true
};
switch (geometry.CLASS_NAME) {
case "OpenLayers.Geometry.Point":
this.drawPoint(node, geometry);
break;
case "OpenLayers.Geometry.Curve":
options.isFilled = false;
this.drawCurve(node, geometry);
break;
case "OpenLayers.Geometry.LineString":
options.isFilled = false;
this.drawLineString(node, geometry);
break;
case "OpenLayers.Geometry.LinearRing":
this.drawLinearRing(node, geometry);
break;
case "OpenLayers.Geometry.Polygon":
this.drawPolygon(node, geometry);
break;
case "OpenLayers.Geometry.Surface":
this.drawSurface(node, geometry);
break;
case "OpenLayers.Geometry.Rectangle":
this.drawRectangle(node, geometry);
break;
default:
break;
}
node.olStyle = style;
node.olOptions = options;
//set style
this.setStyle(node);
},
/**
* virtual functions for drawing different Geometries.
* These should all be implemented by subclasses.
*
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawPoint: function(node, geometry) {},
drawLineString: function(node, geometry) {},
drawLinearRing: function(node, geometry) {},
drawPolygon: function(node, geometry) {},
drawRectangle: function(node, geometry) {},
drawCircle: function(node, geometry) {},
drawCurve: function(node, geometry) {},
drawSurface: function(node, geometry) {},
/**
* @param evt {Object} an OpenLayers.Event object
*
* @returns A geometry from an event that happened on a layer
* @type OpenLayers.Geometry
*/
getGeometryFromEvent: function(evt) {
var node = evt.target || evt.srcElement;
var geometry = node.geometry ? node.geometry : null
return geometry;
},
/** Erase a geometry from the renderer. In the case of a multi-geometry,
* we cycle through and recurse on ourselves. Otherwise, we look for a
* node with the geometry.id, destroy its geometry, and remove it from
* the DOM.
*
* @param {OpenLayers.Geometry} geometry
*/
eraseGeometry: function(geometry) {
if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") ||
(geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") ||
(geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) {
for (var i = 0; i < geometry.components.length; i++) {
this.eraseGeometry(geometry.components[i]);
}
} else {
var element = $(geometry.id);
if (element && element.parentNode) {
if (element.geometry) {
element.geometry.destroy();
element.geometry = null;
}
element.parentNode.removeChild(element);
}
}
},
/**
* @private
*
* Create new node of the specified type, with the (optional) specified id.
*
* If node already exists with same ID and type, we remove it and then
* call ourselves again to recreate it.
*
* @param {String} id
* @param {String} type Kind of node to draw
* @param {OpenLayers.Geometry} geometry
*
* @returns A new node of the given type and id
* @type DOMElement
*/
nodeFactory: function(id, type, geometry) {
var node = $(id);
if (node) {
if (!this.nodeTypeCompare(node, type)) {
node.parentNode.removeChild(node);
node = this.nodeFactory(id, type, geometry);
}
} else {
node = this.createNode(type, id);
}
return node;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Renderer.Elements"
});

View File

@@ -0,0 +1,327 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Renderer/Elements.js
*/
OpenLayers.Renderer.SVG = OpenLayers.Class.create();
OpenLayers.Renderer.SVG.prototype =
OpenLayers.Class.inherit(OpenLayers.Renderer.Elements, {
/** @type String */
xmlns: "http://www.w3.org/2000/svg",
/**
* @constructor
*
* @param {String} containerID
*/
initialize: function(containerID) {
if (!this.supported()) {
return;
}
OpenLayers.Renderer.Elements.prototype.initialize.apply(this,
arguments);
},
/**
*
*/
destroy: function() {
OpenLayers.Renderer.Elements.prototype.destroy.apply(this, arguments);
},
/**
* @returns Whether or not the browser supports the VML renderer
* @type Boolean
*/
supported: function() {
var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG";
var supported = document.implementation.hasFeature(svgFeature, "1.1");
return supported;
},
/**
* @param {OpenLayers.Bounds} extent
*/
setExtent: function(extent) {
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
arguments);
var extentString = extent.left + " " + -extent.top + " " +
extent.getWidth() + " " + extent.getHeight();
this.rendererRoot.setAttributeNS(null, "viewBox", extentString);
},
/**
* function
*
* sets the size of the drawing surface
*
* @param size {OpenLayers.Size} the size of the drawing surface
*/
setSize: function(size) {
OpenLayers.Renderer.prototype.setSize.apply(this, arguments);
this.rendererRoot.setAttributeNS(null, "width", this.size.w);
this.rendererRoot.setAttributeNS(null, "height", this.size.h);
},
/**
* @param geometry {OpenLayers.Geometry}
*
* @returns The corresponding node type for the specified geometry
* @type String
*/
getNodeType: function(geometry) {
var nodeType = null;
switch (geometry.CLASS_NAME) {
case "OpenLayers.Geometry.Point":
nodeType = "circle";
break;
case "OpenLayers.Geometry.Rectangle":
nodeType = "rect";
break;
case "OpenLayers.Geometry.LineString":
nodeType = "polyline";
break;
case "OpenLayers.Geometry.LinearRing":
nodeType = "polygon";
break;
case "OpenLayers.Geometry.Polygon":
case "OpenLayers.Geometry.Curve":
case "OpenLayers.Geometry.Surface":
nodeType = "path";
break;
default:
break;
}
return nodeType;
},
/**
* @param {DOMElement} node
*/
reprojectNode: function(node) {
//just reset style (stroke width and point radius), since coord
// system has not changed
this.setStyle(node);
},
/**
* Use to set all the style attributes to a SVG node.
*
* Note: takes care to adjust stroke width and point radius
* to be resolution-relative
*
* @param node {SVGDomElement} an SVG element to decorate
* @param {Object} style
* @param {Object} options
* @option isFilled {boolean}
* @option isStroked {boolean}
*/
setStyle: function(node, style, options) {
style = style || node.olStyle;
options = options || node.olOptions;
if (node.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
var newRadius = style.pointRadius * this.getResolution();
node.setAttributeNS(null, "r", newRadius);
}
if (options.isFilled) {
node.setAttributeNS(null, "fill", style.fillColor);
node.setAttributeNS(null, "fill-opacity", style.fillOpacity);
} else {
node.setAttributeNS(null, "fill", "none");
}
if (options.isStroked) {
node.setAttributeNS(null, "stroke", style.strokeColor);
node.setAttributeNS(null, "stroke-opacity", style.strokeOpacity);
var newStrokeWidth = style.strokeWidth * this.getResolution();
node.setAttributeNS(null, "stroke-width", newStrokeWidth);
} else {
node.setAttributeNS(null, "stroke", "none");
}
if (style.pointerEvents) {
node.setAttributeNS(null, "pointer-events", style.pointerEvents);
}
},
/**
* @private
*
* @param {String} type Kind of node to draw
* @param {String} id Id for node
*
* @returns A new node of the given type and id
* @type DOMElement
*/
createNode: function(type, id) {
var node = document.createElementNS(this.xmlns, type);
if (id) {
node.setAttributeNS(null, "id", id);
}
return node;
},
/**
* @private
*
* @param {String} type Kind of node to draw
* @param {String} id Id for node
*
* @returns Whether or not the specified node is of the specified type
* @type Boolean
*/
nodeTypeCompare: function(node, type) {
return (type == node.nodeName);
},
/**
* @returns The specific render engine's root element
* @type DOMElement
*/
createRenderRoot: function() {
var id = this.container.id + "_svgRoot";
var rendererRoot = this.nodeFactory(id, "svg");
return rendererRoot;
},
/**
* @returns The main root element to which we'll add vectors
* @type DOMElement
*/
createRoot: function() {
var id = this.container.id + "_root";
var root = this.nodeFactory(id, "g");
// flip the SVG display Y axis upside down so it
// matches the display Y axis of the map
root.setAttributeNS(null, "transform", "scale(1, -1)");
return root;
},
/**************************************
* *
* GEOMETRY DRAWING FUNCTIONS *
* *
**************************************/
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawPoint: function(node, geometry) {
this.drawCircle(node, geometry, 1);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
* @param {float} radius
*/
drawCircle: function(node, geometry, radius) {
node.setAttributeNS(null, "cx", geometry.x);
node.setAttributeNS(null, "cy", geometry.y);
node.setAttributeNS(null, "r", radius);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawLineString: function(node, geometry) {
node.setAttributeNS(null, "points", geometry.getComponentsString());
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawLinearRing: function(node, geometry) {
node.setAttributeNS(null, "points", geometry.getComponentsString());
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawPolygon: function(node, geometry) {
var d = "";
for (var j = 0; j < geometry.components.length; j++) {
var linearRing = geometry.components[j];
d += " M";
for (var i = 0; i < linearRing.components.length; i++) {
d += " " + linearRing.components[i].toShortString();
}
}
d += " z";
node.setAttributeNS(null, "d", d);
node.setAttributeNS(null, "fill-rule", "evenodd");
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawRectangle: function(node, geometry) {
node.setAttributeNS(null, "x", geometry.x);
node.setAttributeNS(null, "y", geometry.y);
node.setAttributeNS(null, "width", geometry.width);
node.setAttributeNS(null, "height", geometry.height);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawCurve: function(node, geometry) {
var d = null;
for (var i = 0; i < geometry.components.length; i++) {
if ((i%3) == 0 && (i/3) == 0) {
d = "M " + geometry.components[i].toShortString();
} else if ((i%3) == 1) {
d += " C " + geometry.components[i].toShortString();
} else {
d += " " + geometry.components[i].toShortString();
}
}
node.setAttributeNS(null, "d", d);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawSurface: function(node, geometry) {
// create the svg path string representation
var d = null;
for (var i = 0; i < geometry.components.length; i++) {
if ((i%3) == 0 && (i/3) == 0) {
d = "M " + geometry.components[i].toShortString();
} else if ((i%3) == 1) {
d += " C " + geometry.components[i].toShortString();
} else {
d += " " + geometry.components[i].toShortString();
}
}
d += " Z";
node.setAttributeNS(null, "d", d);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Renderer.SVG"
});

View File

@@ -0,0 +1,444 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* Note that for all calculations in this class, we use toFixed() to round a
* float value to an integer. This is done because it seems that VML doesn't
* support float values.
*
* @requires OpenLayers/Renderer/Elements.js
*/
OpenLayers.Renderer.VML = OpenLayers.Class.create();
OpenLayers.Renderer.VML.prototype =
OpenLayers.Class.inherit(OpenLayers.Renderer.Elements, {
/** @type String */
xmlns: "urn:schemas-microsoft-com:vml",
/**
* @constructor
*
* @param {String} containerID
*/
initialize: function(containerID) {
if (!this.supported()) {
return;
}
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
var style = document.createStyleSheet();
style.addRule('v\\:*', "behavior: url(#default#VML);");
OpenLayers.Renderer.Elements.prototype.initialize.apply(this,
arguments);
},
/**
*
*/
destroy: function() {
OpenLayers.Renderer.Elements.prototype.destroy.apply(this, arguments);
},
/**
* @returns Whether or not the browser supports the VML renderer
* @type Boolean
*/
supported: function() {
var supported = document.namespaces;
return supported;
},
/**
* @param {OpenLayers.Bounds} extent
*/
setExtent: function(extent) {
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
arguments);
var resolution = this.getResolution();
var org = extent.left/resolution + " " +
extent.top/resolution;
this.root.setAttribute("coordorigin", org);
var size = extent.getWidth()/resolution + " " +
-extent.getHeight()/resolution;
this.root.setAttribute("coordsize", size);
},
/**
* Set the size of the drawing surface
*
* @param size {OpenLayers.Size} the size of the drawing surface
*/
setSize: function(size) {
OpenLayers.Renderer.prototype.setSize.apply(this, arguments);
this.rendererRoot.style.width = this.size.w;
this.rendererRoot.style.height = this.size.h;
this.root.style.width = this.size.w;
this.root.style.height = this.size.h
},
/**
* @param geometry {OpenLayers.Geometry}
*
* @returns The corresponding node type for the specified geometry
* @type String
*/
getNodeType: function(geometry) {
var nodeType = null;
switch (geometry.CLASS_NAME) {
case "OpenLayers.Geometry.Point":
nodeType = "v:oval";
break;
case "OpenLayers.Geometry.Rectangle":
nodeType = "v:rect";
break;
case "OpenLayers.Geometry.LineString":
case "OpenLayers.Geometry.LinearRing":
case "OpenLayers.Geometry.Polygon":
case "OpenLayers.Geometry.Curve":
case "OpenLayers.Geometry.Surface":
nodeType = "v:shape";
break;
default:
break;
}
return nodeType;
},
/**
* @param {DOMElement} node
*/
reprojectNode: function(node) {
//we have to reprojectNode the entire node since the coordinates
// system has changed
this.drawGeometryNode(node);
},
/**
* Use to set all the style attributes to a VML node.
*
* @param {DOMElement} node
* @param {Object} style
* @param {Object} options
* @option isFilled {boolean}
* @option isStroked {boolean}
*/
setStyle: function(node, style, options) {
style = style || node.olStyle;
options = options || node.olOptions;
if (node.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
this.drawCircle(node, node.geometry, style.pointRadius);
}
//fill
var fillColor = (options.isFilled) ? style.fillColor : "none";
node.setAttribute("fillcolor", fillColor);
var fills = node.getElementsByTagName("fill");
var fill = (fills.length == 0) ? null : fills[0];
if (!options.isFilled) {
if (fill) {
node.removeChild(fill);
}
} else {
if (!fill) {
fill = this.createNode('v:fill', node.id + "_fill");
node.appendChild(fill);
}
fill.setAttribute("opacity", style.fillOpacity);
}
//stroke
var strokeColor = (options.isStroked) ? style.strokeColor : "none";
node.setAttribute("strokecolor", strokeColor);
node.setAttribute("strokeweight", style.strokeWidth);
var strokes = node.getElementsByTagName("stroke");
var stroke = (strokes.length == 0) ? null : strokes[0];
if (!options.isStroked) {
if (stroke) {
node.removeChild(stroke);
}
} else {
if (!stroke) {
stroke = this.createNode('v:stroke', node.id + "_stroke");
node.appendChild(stroke);
}
stroke.setAttribute("opacity", style.strokeOpacity);
}
},
/** Get the geometry's bounds, convert it to our vml coordinate system,
* then set the node's position, size, and local coordinate system.
*
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
setNodeDimension: function(node, geometry) {
var bbox = geometry.getBounds();
var resolution = this.getResolution();
var scaledBox =
new OpenLayers.Bounds((bbox.left/resolution).toFixed(),
(bbox.bottom/resolution).toFixed(),
(bbox.right/resolution).toFixed(),
(bbox.top/resolution).toFixed());
// Set the internal coordinate system to draw the path
node.style.left = scaledBox.left;
node.style.top = scaledBox.top;
node.style.width = scaledBox.getWidth();
node.style.height = scaledBox.getHeight();
node.coordorigin = scaledBox.left + " " + scaledBox.top;
node.coordsize = scaledBox.getWidth()+ " " + scaledBox.getHeight();
},
/**
* @private
*
* @param {String} type Kind of node to draw
* @param {String} id Id for node
*
* @returns A new node of the given type and id
* @type DOMElement
*/
createNode: function(type, id) {
var node = document.createElement(type);
if (id) {
node.setAttribute('id', id);
}
return node;
},
/**
* @private
*
* @param {String} type Kind of node to draw
* @param {String} id Id for node
*
* @returns Whether or not the specified node is of the specified type
* @type Boolean
*/
nodeTypeCompare: function(node, type) {
//split type
var subType = type;
var splitIndex = subType.indexOf(":");
if (splitIndex != -1) {
subType = subType.substr(splitIndex+1);
}
//split nodeName
var nodeName = node.nodeName;
splitIndex = nodeName.indexOf(":");
if (splitIndex != -1) {
nodeName = nodeName.substr(splitIndex+1);
}
return (subType == nodeName);
},
/**
* @returns The specific render engine's root element
* @type DOMElement
*/
createRenderRoot: function() {
var id = this.container.id + "_vmlRoot";
var rendererRoot = this.nodeFactory(id, "div");
return rendererRoot;
},
/**
* @returns The main root element to which we'll add vectors
* @type DOMElement
*/
createRoot: function() {
var id = this.container.id + "_root";
var root = this.nodeFactory(id, "v:group");
return root;
},
/**************************************
* *
* GEOMETRY DRAWING FUNCTIONS *
* *
**************************************/
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawPoint: function(node, geometry) {
this.drawCircle(node, node.geometry, 1);
},
/** Size and Center a circle given geometry (x,y center) and radius
*
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
* @param {float} radius
*/
drawCircle: function(node, geometry, radius) {
var resolution = this.getResolution();
node.style.left = (geometry.x /resolution).toFixed() - radius;
node.style.top = (geometry.y /resolution).toFixed() - radius;
var diameter = radius * 2;
node.style.width = diameter;
node.style.height = diameter;
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawLineString: function(node, geometry) {
this.drawLine(node, geometry, false);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawLinearRing: function(node, geometry) {
this.drawLine(node, geometry, true);
},
/**
* @param {DOMElement} node
* @param {OpenLayers.Geometry} geometry
* @param {Boolean} closeLine Close the line? (make it a ring?)
*/
drawLine: function(node, geometry, closeLine) {
this.setNodeDimension(node, geometry);
var resolution = this.getResolution();
var path = "m";
for (var i = 0; i < geometry.components.length; i++) {
var x = (geometry.components[i].getX()/resolution);
var y = (geometry.components[i].getY()/resolution);
path += " " + x.toFixed() + "," + y.toFixed() + " l ";
}
if (closeLine) {
path += " x";
}
path += " e";
node.path = path;
},
/**
* @parm {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawPolygon: function(node, geometry) {
this.setNodeDimension(node, geometry);
var resolution = this.getResolution();
var path = "";
for (var j = 0; j < geometry.components.length; j++) {
var linearRing = geometry.components[j];
path += "m";
for (var i = 0; i < linearRing.components.length; i++) {
var x = linearRing.components[i].getX() / resolution;
var y = linearRing.components[i].getY() / resolution;
path += " " + x.toFixed() + "," + y.toFixed();
if (i==0) {
path += " l";
}
}
path += " x ";
}
path += "e";
node.path = path;
},
/**
* @parm {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawRectangle: function(node, geometry) {
var resolution = this.getResolution();
node.style.left = geometry.x/resolution;
node.style.top = geometry.y/resolution;
node.style.width = geometry.width/resolution;
node.style.height = geometry.height/resolution;
},
/**
* @parm {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawCurve: function(node, geometry) {
this.setNodeDimension(node, geometry);
var resolution = this.getResolution();
var path = "";
for (var i = 0; i < geometry.components.length; i++) {
var x = geometry.components[i].getX() / resolution;
var y = geometry.components[i].getY() / resolution;
if ((i%3)==0 && (i/3)==0) {
path += "m"
} else if ((i%3)==1) {
path += " c"
}
path += " " + x + "," + y;
}
path += " x e";
node.path = path;
},
/**
* @parm {DOMElement} node
* @param {OpenLayers.Geometry} geometry
*/
drawSurface: function(node, geometry) {
this.setNodeDimension(node, geometry);
var resolution = this.getResolution();
var path = "";
for (var i = 0; i < geometry.components.length; i++) {
var x = geometry.components[i].getX() / resolution;
var y = geometry.components[i].getY() / resolution;
if ((i%3)==0 && (i/3)==0) {
path += "m";
} else if ((i%3)==1) {
path += " c";
}
path += " " + x + "," + y;
}
path += " x e";
node.path = path;
},
CLASS_NAME: "OpenLayers.Renderer.VML"
});

View File

@@ -16,7 +16,7 @@ OpenLayers.Tile.WFS.prototype =
features: null,
/** @type Array(String) */
urls: null,
url: null,
/**
* @constructor
@@ -27,11 +27,11 @@ OpenLayers.Tile.WFS.prototype =
* @param {Array} urls
* @param {OpenLayers.Size} size
*/
initialize: function(layer, position, bounds, urls, size) {
initialize: function(layer, position, bounds, url, size) {
var newArguments = arguments;
newArguments = [layer, position, bounds, null, size];
OpenLayers.Tile.prototype.initialize.apply(this, newArguments);
this.urls = urls;
this.url = url;
this.features = new Array();
},
@@ -42,7 +42,7 @@ OpenLayers.Tile.WFS.prototype =
OpenLayers.Tile.prototype.destroy.apply(this, arguments);
this.destroyAllFeatures();
this.features = null;
this.urls = null;
this.url = null;
},
/** Clear the tile of any bounds/position-related data so that it can
@@ -57,12 +57,9 @@ OpenLayers.Tile.WFS.prototype =
*
*/
draw:function() {
if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
return false;
if (OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
this.loadFeaturesForRegion(this.requestSuccess);
}
this.loadFeaturesForRegion(this.requestSuccess);
this.drawn = true;
return true;
},
/** get the full request string from the ds and the tile params
@@ -74,21 +71,12 @@ OpenLayers.Tile.WFS.prototype =
* @param {function} failure
*/
loadFeaturesForRegion:function(success, failure) {
if (this.urls != null) {
for(var i=0; i < this.urls.length; i++) {
var params = { BBOX:this.bounds.toBBOX() };
var url = this.urls[i] + "&" +
OpenLayers.Util.getParameterString(params);
OpenLayers.loadURL(url, null, this, success, failure);
}
}
OpenLayers.loadURL(this.url, null, this, success);
},
/** Return from AJAX request
*
* @param {XMLHttpRequest} request
* @param {} request
*/
requestSuccess:function(request) {
var doc = request.responseXML;
@@ -96,9 +84,13 @@ OpenLayers.Tile.WFS.prototype =
if (!doc || request.fileType!="XML") {
doc = OpenLayers.parseXMLString(request.responseText);
}
var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS(doc, "http://www.opengis.net/gml","gml", "featureMember");
this.addResults(resultFeatures);
if (this.layer.vectorMode) {
var gml = new OpenLayers.Format.GML({extractAttributes: this.layer.options.extractAttributes});
this.layer.addFeatures(gml.read(doc));
} else {
var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS(doc, "http://www.opengis.net/gml","gml", "featureMember");
this.addResults(resultFeatures);
}
},
/**
@@ -112,6 +104,7 @@ OpenLayers.Tile.WFS.prototype =
}
},
/** Iterate through and call destroy() on each feature, removing it from
* the local array
*
@@ -128,5 +121,3 @@ OpenLayers.Tile.WFS.prototype =
CLASS_NAME: "OpenLayers.Tile.WFS"
}
);

View File

@@ -1,6 +1,6 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var bounds;
function test_01_Bounds_constructor (t) {
@@ -277,7 +277,7 @@
t.eq( bounds.top, 4, "bounds.top is set correctly" );
}
function test_14_Bounds_fromSize(t) {
function test_15_Bounds_fromSize(t) {
t.plan( 5 );
var height = 15;
@@ -291,6 +291,95 @@
t.eq( bounds.top, 0, "bounds.top is set correctly" );
}
function test_16_Bounds_extend(t) {
t.plan( 8 );
var originalBounds = new OpenLayers.Bounds(10,20,50,80);
var bounds = originalBounds.clone();
//null obj
bounds.extend(null);
t.ok(bounds.equals(originalBounds), "null to extend does not crash or change original bounds");
//obj with no classname
var object = new Object();
bounds.extend(object);
t.ok(bounds.equals(originalBounds), "extend() passing object with no classname does not crash or change original bounds")
//obj is bounds
//pushing all limits with bounds obj
var testBounds = new OpenLayers.Bounds(5, 10, 60, 90);
object = testBounds.clone();
bounds.extend(object);
t.ok(bounds.equals(testBounds), "extend by valid bounds, pushing all limits, correctly extends bounds");
//pushing no limits with bounds obj
bounds = originalBounds.clone();
testBounds = new OpenLayers.Bounds(15, 30, 40, 70);
object = testBounds.clone();
bounds.extend(object);
t.ok(bounds.equals(originalBounds), "extend by valid bounds, pushing no limits, correctly does not extend bounds");
// obj is lonlat
//left, bottom
bounds = originalBounds.clone();
object = new OpenLayers.LonLat(5, 10);
bounds.extend(object);
t.ok( ((bounds.left == object.lon) &&
(bounds.bottom == object.lat) &&
(bounds.right == originalBounds.right) &&
(bounds.top == originalBounds.top)), "obj lonlat to extends correclty modifies left and bottom");
//right, top
bounds = originalBounds.clone();
object = new OpenLayers.LonLat(60,90);
bounds.extend(object);
t.ok( ((bounds.left == originalBounds.left) &&
(bounds.bottom == originalBounds.bottom) &&
(bounds.right == object.lon) &&
(bounds.top == object.lat)), "obj lonlat to extends correclty modifies right and top");
// obj is point
//left, bottom
bounds = originalBounds.clone();
object = new OpenLayers.Geometry.Point(5, 10);
bounds.extend(object);
t.ok( ((bounds.left == object.lon) &&
(bounds.bottom == object.lat) &&
(bounds.right == originalBounds.right) &&
(bounds.top == originalBounds.top)), "obj Point to extends correclty modifies left and bottom");
//right, top
bounds = originalBounds.clone();
object = new OpenLayers.Geometry.Point(60,90);
bounds.extend(object);
t.ok( ((bounds.left == originalBounds.left) &&
(bounds.bottom == originalBounds.bottom) &&
(bounds.right == object.lon) &&
(bounds.top == object.lat)), "obj Point to extends correclty modifies right and top");
}
// -->
</script>
</head>

View File

@@ -1,6 +1,6 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);

View File

@@ -1,6 +1,6 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var lonlat;

View File

@@ -1,6 +1,6 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var pixel;

Some files were not shown because too many files have changed in this diff Show More