1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>OpenLayers Fill, Stroke, and Graphic Example</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" type="text/javascript"></script>
7 <script type="text/javascript">
11 map = new OpenLayers.Map('map');
13 var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
14 "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
17 // allow testing of specific renderers via "?renderer=Canvas", etc
18 var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
19 renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
21 var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {
22 styleMap: new OpenLayers.StyleMap({
23 'default': new OpenLayers.Style(null, {
28 label: "Label for invisible point"
30 filter: new OpenLayers.Filter.Comparison({
33 value: "point_invisible"
40 label: "Polygon with stroke and fill defaults"
42 filter: new OpenLayers.Filter.Comparison({
45 value: "polygon_defaults"
52 label: "Point without fill",
55 filter: new OpenLayers.Filter.Comparison({
67 // create a point feature
68 var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
69 var pointFeature = new OpenLayers.Feature.Vector(point);
70 pointFeature.attributes = {
71 topic: "point_invisible"
74 // create a polygon feature from a linear ring of points
76 for(var p=0; p<6; ++p) {
77 var a = p * (2 * Math.PI) / 7;
78 var r = Math.random(1) + 1;
79 var newPoint = new OpenLayers.Geometry.Point(point.x + 5 + (r * Math.cos(a)),
80 point.y + 5 + (r * Math.sin(a)));
81 pointList.push(newPoint);
83 pointList.push(pointList[0]);
85 var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
86 var polygonFeature = new OpenLayers.Feature.Vector(
87 new OpenLayers.Geometry.Polygon([linearRing]));
88 polygonFeature.attributes = {
89 topic: "polygon_defaults"
92 multiFeature = new OpenLayers.Feature.Vector(
93 new OpenLayers.Geometry.Collection([
94 new OpenLayers.Geometry.LineString([
95 new OpenLayers.Geometry.Point(-105,40),
96 new OpenLayers.Geometry.Point(-95,45)
98 new OpenLayers.Geometry.Point(-105, 40)
101 topic: "point_nofill"
104 map.addLayer(vectorLayer);
105 vectorLayer.drawFeature(multiFeature);
106 map.setCenter(new OpenLayers.LonLat(point.x, point.y), 4);
107 vectorLayer.addFeatures([pointFeature, polygonFeature, multiFeature]);
111 <body onload="init()">
112 <h1 id="title">OpenLayers Example</h1>
113 <div id="tags"></div>
115 Demonstrate fill, stroke, and graphic property of symbolizers.
117 <div id="map" class="smallmap"></div>
119 This example shows how to use symbolizers with defaults for stroke, fill, and graphic.