FIx style support in format.text to allow a set of style defaults.
Also, add an extractStyles option that can be configured to false to allow th use of stylemaps. r=ahocevar (Closes #1844) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9271 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
function test_basic(t) {
|
||||
t.plan(5);
|
||||
var format = new OpenLayers.Format.Text({extractStyles: true});
|
||||
var features = format.read(OpenLayers.Util.getElement("content").value);
|
||||
t.eq(features[0].style, null, "style is null if no style props set");
|
||||
var features = format.read(OpenLayers.Util.getElement("contentMarker").value);
|
||||
t.eq(features[0].style.externalGraphic, "../../img/marker.png", "marker set correctly by default.");
|
||||
|
||||
var features = format.read(OpenLayers.Util.getElement("content2").value);
|
||||
t.eq(features.length, 2, "two features read");
|
||||
t.eq(features[0].style.externalGraphic, "marker.png", "marker set correctly from data.");
|
||||
// t.eq(format.defaultStyle.externalGraphic, "../../img/marker.png", "defaultStyle externalGraphic not changed by pulling from data");
|
||||
|
||||
var format = new OpenLayers.Format.Text();
|
||||
var features = format.read(OpenLayers.Util.getElement("content2").value);
|
||||
t.eq(features[0].style, null, "null default style results in null style property, even with style properties used");
|
||||
}
|
||||
function test_extra(t) {
|
||||
t.plan(1);
|
||||
var format = new OpenLayers.Format.Text();
|
||||
var features = format.read(OpenLayers.Util.getElement("content3").value);
|
||||
t.eq(features[0].attributes.whee, "chicken", "extra attributes are stored for later use");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="content">
|
||||
point
|
||||
5,5
|
||||
</textarea>
|
||||
<textarea id="contentMarker">
|
||||
point iconSize
|
||||
5,5 8,8
|
||||
</textarea>
|
||||
<textarea id="content2">
|
||||
point icon
|
||||
5,5 marker.png
|
||||
10,10 marker2.png
|
||||
</textarea>
|
||||
<textarea id="content3">
|
||||
point whee
|
||||
5,5 chicken
|
||||
</textarea>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user