1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
---|
5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> |
---|
6 | <meta name="apple-mobile-web-app-capable" content="yes"> |
---|
7 | <title>OpenLayers Styles Rotation Example</title> |
---|
8 | <link rel="stylesheet" href="../theme/default/style.css" type="text/css"> |
---|
9 | <link rel="stylesheet" href="style.css" type="text/css"> |
---|
10 | <script src="../lib/OpenLayers.js" type="text/javascript"></script> |
---|
11 | <script type="text/javascript"> |
---|
12 | |
---|
13 | var map; |
---|
14 | var vectors; |
---|
15 | |
---|
16 | function init(){ |
---|
17 | map = new OpenLayers.Map('map'); |
---|
18 | var wms = new OpenLayers.Layer.WMS( |
---|
19 | "OpenLayers WMS", |
---|
20 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
---|
21 | {layers: 'basic'} |
---|
22 | ); |
---|
23 | |
---|
24 | vectors = new OpenLayers.Layer.Vector( |
---|
25 | "Simple Geometry", |
---|
26 | { |
---|
27 | styleMap: new OpenLayers.StyleMap({ |
---|
28 | "default": { |
---|
29 | externalGraphic: "../img/marker-gold.png", |
---|
30 | //graphicWidth: 17, |
---|
31 | graphicHeight: 20, |
---|
32 | graphicYOffset: -19, |
---|
33 | rotation: "${angle}", |
---|
34 | fillOpacity: "${opacity}" |
---|
35 | }, |
---|
36 | "select": { |
---|
37 | cursor: "crosshair", |
---|
38 | externalGraphic: "../img/marker.png" |
---|
39 | } |
---|
40 | }) |
---|
41 | } |
---|
42 | ); |
---|
43 | |
---|
44 | map.addLayers([wms, vectors]); |
---|
45 | |
---|
46 | var features = []; |
---|
47 | var x = -111.04; |
---|
48 | var y = 45.68; |
---|
49 | for(var i = 0; i < 10; i++){ |
---|
50 | x += i * .5; |
---|
51 | y += i * .1; |
---|
52 | features.push( |
---|
53 | new OpenLayers.Feature.Vector( |
---|
54 | new OpenLayers.Geometry.Point(x, y), {angle: (i*36)%360-180, opacity:i/10+.1} |
---|
55 | ) |
---|
56 | ); |
---|
57 | features.push( |
---|
58 | new OpenLayers.Feature.Vector( |
---|
59 | new OpenLayers.Geometry.Point(x, y), {angle: (i*36)%360, opacity:i/10+.1} |
---|
60 | ) |
---|
61 | ); |
---|
62 | } |
---|
63 | |
---|
64 | map.setCenter(new OpenLayers.LonLat(x-10, y), 5); |
---|
65 | vectors.addFeatures(features); |
---|
66 | |
---|
67 | var selectControl = new OpenLayers.Control.SelectFeature( |
---|
68 | vectors, {hover: true}); |
---|
69 | map.addControl(selectControl); |
---|
70 | selectControl.activate(); |
---|
71 | |
---|
72 | }; |
---|
73 | |
---|
74 | </script> |
---|
75 | </head> |
---|
76 | <body onload="init()"> |
---|
77 | <h1 id="title">Rotation Style Example</h1> |
---|
78 | <div id="tags"> |
---|
79 | vector, feature, stylemap, rotation, cleanup, light |
---|
80 | </div> |
---|
81 | <p id="shortdesc"> |
---|
82 | Use the rotation property of a point symbolizer to rotate |
---|
83 | point symbolizers. |
---|
84 | </p> |
---|
85 | <div id="map" class="smallmap"></div> |
---|
86 | <div id="docs"> |
---|
87 | To style point features with rotation, use the rotation property of the |
---|
88 | symbolizer. The center of the rotation is the point of the image |
---|
89 | specified by graphicXOffset and graphicYOffset. The rotation is |
---|
90 | specified in degrees clockwise. |
---|
91 | </div> |
---|
92 | </body> |
---|
93 | </html> |
---|