1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<html>
<head>
<script src="../OLLoader.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.externalGraphic, format.defaultStyle.externalGraphic, "style is set to defaults if no style props set in text file");
var features = format.read(OpenLayers.Util.getElement("contentMarker").value);
t.eq(features[0].style.externalGraphic, OpenLayers.Util.getImagesLocation() + "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({extractStyles: false});
var features = format.read(OpenLayers.Util.getElement("content2").value);
t.eq(features[0].style, null, "extractStyles: false 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>
|