[OpenLayers-Commits] r7052 - in sandbox/vector-behavior: examples lib/OpenLayers lib/OpenLayers/Format lib/OpenLayers/Format/SLD lib/OpenLayers/Layer lib/OpenLayers/Popup tests tests/Layer
commits at openlayers.org
commits at openlayers.org
Fri May 2 10:59:54 EDT 2008
Author: elemoine
Date: 2008-05-02 10:59:54 -0400 (Fri, 02 May 2008)
New Revision: 7052
Modified:
sandbox/vector-behavior/examples/attribution.html
sandbox/vector-behavior/examples/click.html
sandbox/vector-behavior/lib/OpenLayers/Ajax.js
sandbox/vector-behavior/lib/OpenLayers/Format/SLD.js
sandbox/vector-behavior/lib/OpenLayers/Format/SLD/v1.js
sandbox/vector-behavior/lib/OpenLayers/Layer/GeoRSS.js
sandbox/vector-behavior/lib/OpenLayers/Layer/Text.js
sandbox/vector-behavior/lib/OpenLayers/Layer/Vector.js
sandbox/vector-behavior/lib/OpenLayers/Popup/Anchored.js
sandbox/vector-behavior/lib/OpenLayers/Rule.js
sandbox/vector-behavior/lib/OpenLayers/Util.js
sandbox/vector-behavior/tests/Layer/GeoRSS.html
sandbox/vector-behavior/tests/Layer/Vector.html
sandbox/vector-behavior/tests/Style.html
Log:
svn merge -r 6890:HEAD trunk/openlayers
Modified: sandbox/vector-behavior/examples/attribution.html
===================================================================
--- sandbox/vector-behavior/examples/attribution.html 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/examples/attribution.html 2008-05-02 14:59:54 UTC (rev 7052)
@@ -11,6 +11,7 @@
}
</style>
<script src="../lib/OpenLayers.js"></script>
+
<script type="text/javascript">
var map;
function init(){
@@ -20,11 +21,15 @@
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
{'attribution': 'Provided by <a href="http://labs.metacarta.com/">MetaCarta</a>'});
- var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
- "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
- {layers: "landsat7"},{attribution:"Provided by Telascience"});
+ var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
+ "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
+ {layers: "landsat7"},{attribution:"Provided by Telascience"});
- map.addLayers([ol_wms, jpl_wms]);
+ var vector = new OpenLayers.Layer.Vector("Simple Geometry",
+ {attribution:"Vector Attibution in 2nd arg"});
+
+ map.addLayers([ol_wms, jpl_wms, vector]);
+
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Attribution());
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
@@ -36,6 +41,7 @@
<h1 id="title">Attribution Example</h1>
<div id="tags">
+ copyright watermark logo attribution
</div>
<p id="shortdesc">
@@ -47,7 +53,9 @@
<div id="docs">
This is an example of how to add an attribution block to the OpenLayers window. In order to use an
attribution block, an attribution parameter must be set in each layer that requires attribution. In
- addition, an attribution control must be added to the map.
+ addition, an attribution control must be added to the map, though one is added to all OpenLayers Maps by default.
+ Be aware that this is a layer *option*: the options hash goes in
+ different places depending on the layer type you are using.
</div>
</body>
</html>
Modified: sandbox/vector-behavior/examples/click.html
===================================================================
--- sandbox/vector-behavior/examples/click.html 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/examples/click.html 2008-05-02 14:59:54 UTC (rev 7052)
@@ -30,7 +30,7 @@
);
this.handler = new OpenLayers.Handler.Click(
this, {
- 'click': this.trigger,
+ 'click': this.trigger
}, this.handlerOptions
);
},
@@ -39,7 +39,7 @@
var lonlat = map.getLonLatFromViewPortPx(e.xy);
alert("You clicked near " + lonlat.lat + " N, " +
+ lonlat.lon + " E");
- },
+ }
});
var map;
Modified: sandbox/vector-behavior/lib/OpenLayers/Ajax.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Ajax.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Ajax.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -43,7 +43,9 @@
*
* Parameters:
* uri - {String} URI of source doc
- * params - {String} Params on get (doesnt seem to work)
+ * params - {String} or {Object} GET params. Either a string in the form
+ * "?hello=world&foo=bar" (do not forget the leading question mark)
+ * or an object in the form {'hello': 'world', 'foo': 'bar}
* caller - {Object} object which gets callbacks
* onComplete - {Function} Optional callback for success. The callback
* will be called with this set to caller and will receive the request
Modified: sandbox/vector-behavior/lib/OpenLayers/Format/SLD/v1.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Format/SLD/v1.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Format/SLD/v1.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -3,6 +3,11 @@
* full text of the license. */
/**
+ * @requires OpenLayers/Rule.js
+ * @requires OpenLayers/Filter.js
+ * @requires OpenLayers/Filter/FeatureId.js
+ * @requires OpenLayers/Filter/Logical.js
+ * @requires OpenLayers/Filter/Comparison.js
* @requires OpenLayers/Format/SLD.js
*/
Modified: sandbox/vector-behavior/lib/OpenLayers/Format/SLD.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Format/SLD.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Format/SLD.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Style.js
+ * @requires OpenLayers/Rule.js
* @requires OpenLayers/Filter/FeatureId.js
* @requires OpenLayers/Filter/Logical.js
* @requires OpenLayers/Filter/Comparison.js
Modified: sandbox/vector-behavior/lib/OpenLayers/Layer/GeoRSS.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Layer/GeoRSS.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Layer/GeoRSS.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -190,6 +190,10 @@
new OpenLayers.Size(250, 120);
if (title || description) {
+ // we have supplemental data, store them.
+ data.title = title;
+ data.description = description;
+
var contentHTML = '<div class="olLayerGeoRSSClose">[x]</div>';
contentHTML += '<div class="olLayerGeoRSSTitle">';
if (link) {
Modified: sandbox/vector-behavior/lib/OpenLayers/Layer/Text.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Layer/Text.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Layer/Text.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -171,8 +171,8 @@
// FIXME: At the moment, we only use this if we have an
// externalGraphic, because icon has no setOffset API Method.
- if (feature.style.graphicXOffset
- && feature.style.graphicYOffset) {
+ if (feature.style.graphicXOffset !== null
+ && feature.style.graphicYOffset !== null) {
iconOffset = new OpenLayers.Pixel(
feature.style.graphicXOffset,
feature.style.graphicYOffset);
Modified: sandbox/vector-behavior/lib/OpenLayers/Layer/Vector.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Layer/Vector.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Layer/Vector.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -12,8 +12,8 @@
/**
* Class: OpenLayers.Layer.Vector
* Instances of OpenLayers.Layer.Vector are used to render vector data from
- * a variety of sources. Create a new image layer with the
- * <OpenLayers.Layer.Vector> constructor.
+ * a variety of sources. Create a new vector layer with the
+ * <OpenLayers.Layer.Vector> constructor.
*
* Inherits from:
* - <OpenLayers.Layer>
@@ -151,7 +151,7 @@
*
* Parameters:
* name - {String} A name for the layer
- * options - {Object} options Object with non-default properties to set on
+ * options - {Object} Optional object with non-default properties to set on
* the layer.
*
* Returns:
@@ -534,5 +534,24 @@
preFeatureInsert: function(feature) {
},
+ /**
+ * APIMethod: getDataExtent
+ * Calculates the max extent which includes all of the features.
+ *
+ * Returns:
+ * {<OpenLayers.Bounds>}
+ */
+ getDataExtent: function () {
+ var maxExtent = null;
+ if( this.features && (this.features.length > 0)){
+ var maxExtent = this.features[0].geometry.getBounds();
+ for(var i=0; i < this.features.length; i++){
+ maxExtent.extend(this.features[i].geometry.getBounds());
+ }
+ }
+
+ return maxExtent;
+ },
+
CLASS_NAME: "OpenLayers.Layer.Vector"
});
Modified: sandbox/vector-behavior/lib/OpenLayers/Popup/Anchored.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Popup/Anchored.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Popup/Anchored.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -18,7 +18,7 @@
/**
* Parameter: relativePosition
- * {String} Relative position of the popup ("lr", "ll", "tr", or "tl").
+ * {String} Relative position of the popup ("br", "tr", "tl" or "bl").
*/
relativePosition: null,
@@ -126,7 +126,7 @@
* px - {<OpenLayers.Pixel>}
*
* Returns:
- * {String} The relative position ("br" "tr" "tl "bl") at which the popup
+ * {String} The relative position ("br" "tr" "tl" "bl") at which the popup
* should be placed.
*/
calculateRelativePosition:function(px) {
Modified: sandbox/vector-behavior/lib/OpenLayers/Rule.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Rule.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Rule.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -65,7 +65,11 @@
/**
* Property: symbolizer
* {Object} Symbolizer or hash of symbolizers for this rule. If hash of
- * symbolizers, keys are one or more of ["Point", "Line", "Polygon"]
+ * symbolizers, keys are one or more of ["Point", "Line", "Polygon"]. The
+ * latter if useful if it is required to style e.g. vertices of a line
+ * with a point symbolizer. Note, however, that this is not implemented
+ * yet in OpenLayers, but it is the way how symbolizers are defined in
+ * SLD.
*/
symbolizer: null,
Modified: sandbox/vector-behavior/lib/OpenLayers/Util.js
===================================================================
--- sandbox/vector-behavior/lib/OpenLayers/Util.js 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/lib/OpenLayers/Util.js 2008-05-02 14:59:54 UTC (rev 7052)
@@ -197,10 +197,9 @@
* Function: createDiv
* Creates a new div and optionally set some standard attributes.
* Null may be passed to each parameter if you do not wish to
- * set a particular attribute.d
+ * set a particular attribute.
+ * Note - zIndex is NOT set on the resulting div.
*
- * Note: zIndex is NOT set
- *
* Parameters:
* id - {String} An identifier for this element. If no id is
* passed an identifier will be created
@@ -416,8 +415,8 @@
position, border, sizing,
opacity) {
- OpenLayers.Util.modifyDOMElement(div, id, px, sz,
- null, null, null, opacity);
+ OpenLayers.Util.modifyDOMElement(div, id, px, sz, position,
+ null, null, opacity);
var img = div.childNodes[0];
Modified: sandbox/vector-behavior/tests/Layer/GeoRSS.html
===================================================================
--- sandbox/vector-behavior/tests/Layer/GeoRSS.html 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/tests/Layer/GeoRSS.html 2008-05-02 14:59:54 UTC (rev 7052)
@@ -16,7 +16,7 @@
}
function test_Layer_GeoRSS_constructor (t) {
- t.plan( 5 );
+ t.plan( 7 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt );
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
t.eq( layer.location, georss_txt, "layer.location is correct" );
@@ -25,8 +25,12 @@
t.delay_call( 1, function() {
t.eq( layer.markers.length, 40, "marker length is correct" );
var ll = new OpenLayers.LonLat(-71.142197, 42.405696);
+ var theTitle = "Knitting Room";
+ var theDescription = 'This little shop is jammed full. Yarn, yarn everywhere. They make the most of every possible nook and cranny. I like this place also because they have a lot of different kinds of knitting needles in all different sizes. Also, the people who work here are younger and hipper than in the other stores I go to. I reccomend buying supplies here and then knitting your way through a good documentary at the Capitol Theater across the street.<br/>Address: 2 lake St, Arlington, MA <br/>Tags: knitting, yarn, pins and needles, handspun, hand dyed, novelty yarn, fancy, simple, young, hip, friendly, needles, addy, cute hats<br /><br /><a href="http://platial.com/place/90306">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/90306">Grab this on Platial</a> ';
t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
t.eq( layer.name, "Crschmidt's Places At Platial", "Layer name is correct." );
+ t.eq( layer.features[0].data.title, theTitle);
+ t.eq( layer.features[0].data.description, theDescription);
} );
}
Modified: sandbox/vector-behavior/tests/Layer/Vector.html
===================================================================
--- sandbox/vector-behavior/tests/Layer/Vector.html 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/tests/Layer/Vector.html 2008-05-02 14:59:54 UTC (rev 7052)
@@ -16,7 +16,7 @@
}
function test_Layer_Vector_addFeatures(t) {
- t.plan(4);
+ t.plan(8);
var layer = new OpenLayers.Layer.Vector(name);
@@ -25,10 +25,19 @@
layer.preFeatureInsert = function(feature) {
t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls preFeatureInsert with the right arg");
- }
+ };
layer.onFeatureInsert = function(feature) {
t.ok(feature == pointFeature, "OpenLayers.Layer.Vector.addFeatures calls onFeatureInsert with the right arg");
- }
+ };
+ layer.events.register('beforefeatureadded', null, function(obj) {
+ t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers beforefeatureadded with correct feature passed to callback");
+ });
+ layer.events.register('featureadded', null, function(obj) {
+ t.ok(pointFeature == obj.feature, "OpenLayers.Layer.Vector.addFeatures triggers featureadded with correct feature passed to callback");
+ });
+ layer.events.register('featuresadded', null, function(obj) {
+ t.ok(pointFeature == obj.features[0], "OpenLayers.Layer.Vector.addFeatures triggers featuresadded with correct features passed to callback");
+ });
layer.addFeatures([pointFeature]);
@@ -37,12 +46,24 @@
layer.preFeatureInsert = function(feature) {
t.fail("OpenLayers.Layer.Vector.addFeatures calls preFeatureInsert while it must not");
- }
+ };
layer.onFeatureInsert = function(feature) {
t.fail("OpenLayers.Layer.Vector.addFeatures calls onFeatureInsert while it must not");
- }
+ };
+ layer.events.register('beforefeatureadded', null, function(obj) {
+ t.fail("OpenLayers.Layer.Vector.addFeatures triggers beforefeatureadded while it must not");
+ });
+ layer.events.register('featureadded', null, function(obj) {
+ t.fail("OpenLayers.Layer.Vector.addFeatures triggers featureadded while it must not");
+ });
+ layer.events.register('featuresadded', null, function(obj) {
+ t.fail("OpenLayers.Layer.Vector.addFeatures triggers featuresadded while it must not");
+ });
layer.addFeatures([pointFeature], {silent: true});
+
+ var extent = layer.getDataExtent();
+ t.eq(extent.toBBOX(), "-111.04,45.68,-111.04,45.68", "extent from getDataExtent is correct");
}
function test_Layer_Vector_removeFeatures(t) {
Modified: sandbox/vector-behavior/tests/Style.html
===================================================================
--- sandbox/vector-behavior/tests/Style.html 2008-05-02 14:50:14 UTC (rev 7051)
+++ sandbox/vector-behavior/tests/Style.html 2008-05-02 14:59:54 UTC (rev 7052)
@@ -127,7 +127,7 @@
}
function test_Style_context(t) {
- t.plan(1);
+ t.plan(2);
var rule = new OpenLayers.Rule({
symbolizer: {"Point": {externalGraphic: "${img1}"}},
filter: new OpenLayers.Filter.Comparison({
@@ -145,8 +145,18 @@
feature.attributes = {size: 10};
var styleHash = style.createSymbolizer(feature);
t.eq(styleHash.externalGraphic, "myImage.png", "correctly evaluated rule and calculated property styles from a custom context");
- }
-
+
+ // same as above, but without rule (#1526)
+ style = new OpenLayers.Style(
+ {externalGraphic: "${getExternalGraphic}"},
+ {context: {
+ getExternalGraphic: function(feature) {
+ return "foo" + feature.attributes.size + ".png";
+ }
+ }});
+ t.eq(style.createSymbolizer(feature).externalGraphic, "foo10.png", "correctly evaluated symbolizer without rule");
+ };
+
function test_Style_findPropertyStyles(t) {
t.plan(4);
var rule1 = new OpenLayers.Rule({symbolizer: {
More information about the Commits
mailing list