~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/examples/graphic-name.html

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html xmlns="http://www.w3.org/1999/xhtml">
 
2
  <head>
 
3
    <title>OpenLayers Graphic Names</title>
 
4
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
 
5
    <link rel="stylesheet" href="style.css" type="text/css" />
 
6
    <script src="../lib/OpenLayers.js"></script>
 
7
    <script type="text/javascript">
 
8
        var map;
 
9
 
 
10
        function init() {
 
11
            map = new OpenLayers.Map('map');
 
12
 
 
13
            // list of well-known graphic names
 
14
            var graphics = ["star", "cross", "x", "square", "triangle", "circle"];
 
15
            
 
16
            // Create one feature for each well known graphic.
 
17
            // Give features a type attribute with the graphic name.
 
18
            var num = graphics.length;
 
19
            var slot = map.maxExtent.getWidth() / num;
 
20
            var features = Array(num);
 
21
            for(var i=0; i<graphics.length; ++i) {
 
22
                lon = map.maxExtent.left + (i * slot) + (slot / 2);
 
23
                features[i] = new OpenLayers.Feature.Vector(
 
24
                    new OpenLayers.Geometry.Point(
 
25
                        map.maxExtent.left + (i * slot) + (slot / 2), 0
 
26
                    ), {
 
27
                        type: graphics[i]
 
28
                    }
 
29
                );
 
30
            }
 
31
            
 
32
            // Create a style map for painting the features.
 
33
            // The graphicName property of the symbolizer is evaluated using
 
34
            // the type attribute on each feature (set above).
 
35
            var styles = new OpenLayers.StyleMap({
 
36
                "default": {
 
37
                    graphicName: "${type}",
 
38
                    pointRadius: 10,
 
39
                    strokeColor: "fuchsia",
 
40
                    strokeWidth: 2,
 
41
                    fillColor: "lime",
 
42
                    fillOpacity: 0.6
 
43
                },
 
44
                "select": {
 
45
                    pointRadius: 20,
 
46
                    fillOpacity: 1
 
47
                }
 
48
            });
 
49
 
 
50
            // Create a vector layer and give it your style map.
 
51
            var layer = new OpenLayers.Layer.Vector(
 
52
                "Graphics", {styleMap: styles, isBaseLayer: true}
 
53
            );
 
54
            layer.addFeatures(features);
 
55
            map.addLayer(layer);
 
56
            
 
57
            // Create a select feature control and add it to the map.
 
58
            var select = new OpenLayers.Control.SelectFeature(layer, {hover: true});
 
59
            map.addControl(select);
 
60
            select.activate();
 
61
            
 
62
            map.setCenter(new OpenLayers.LonLat(0, 0), 0);
 
63
        }
 
64
    </script>
 
65
  </head>
 
66
  <body onload="init()">
 
67
    <h1 id="title">Named Graphics Example</h1>
 
68
 
 
69
    <div id="tags"></div>
 
70
 
 
71
    <p id="shortdesc">
 
72
        Shows how to use well-known graphic names.
 
73
    </p>
 
74
 
 
75
    <div id="map" class="smallmap"></div>
 
76
 
 
77
    <div id="docs">
 
78
        OpenLayers supports well-known names for a few graphics.  You can use
 
79
        the names "star", "cross", "x", "square", "triangle", and "circle" as
 
80
        the value for the graphicName property of a symbolizer.
 
81
    </div>
 
82
  </body>
 
83
</html>
 
 
b'\\ No newline at end of file'