[OpenLayers-Dev] Simple Styling Problem

Toby Rainthorpe toby.rainthorpe at frsltd.co.uk
Mon Nov 24 06:10:42 EST 2008


Given the simple test below, does anyone know how I would style the  
test_territory polygon? Or for that matter the whole of the  
vector_layer?

Thanks for your help,

Toby

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <link rel="stylesheet" href="../theme/default/style.css"  
type="text/css" />
     <link rel="stylesheet" href="style.css" type="text/css" />
     <script src="../lib/OpenLayers.js"></script>
     <script type="text/javascript">
     var lon = 0.30271;
     var lat = 53.29408;
         var zoom = 8;
         var map, layer;

         function init(){
             map = new OpenLayers.Map( 'map' );
             layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                     "http://labs.metacarta.com/wms/vmap0",
                     {layers: 'basic'} );
             map.addLayer(layer);
             map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
					
             var test_territory = {"type":"Polygon","coordinates": 
[[[0.30271,53.29408],[0.32185,53.27152],[0.23484,53.19422], 
[0.19443,53.21331],[0.16971,53.21241],[0.08345,53.23488], 
[0.02083,53.24781],[-0.01269,53.17102],[-0.13717,53.14185], 
[-0.15075,53.12439],[-0.13071,53.02398],[-0.22929,53.00390], 
[-0.33850,53.06091],[-0.40868,53.05562],[-0.45224,53.05795], 
[-0.48515,53.12857],[-0.52103,53.14277],[-0.54183,53.19215], 
[-0.49520,53.22299],[-0.48566,53.22575],[-0.51875,53.22722], 
[-0.53484,53.22819],[-0.53926,53.22850],[-0.53759,53.23366], 
[-0.55354,53.25197],[-0.57064,53.23427],[-0.56796,53.23333], 
[-0.54251,53.22764],[-0.54796,53.21912],[-0.55416,53.20214], 
[-0.56246,53.19333],[-0.57082,53.17395],[-0.67832,53.10239], 
[-0.69929,53.07564],[-0.71693,53.11059],[-0.67402,53.21872], 
[-0.66818,53.25521],[-0.77575,53.24668],[-0.76478,53.26913], 
[-0.75146,53.32024],[-0.56708,53.35294],[-0.54906,53.42575], 
[-0.46125,53.42901],[-0.45928,53.43568],[-0.49191,53.49760], 
[-0.41390,53.55006],[-0.31045,53.52675],[-0.21935,53.52730], 
[-0.21503,53.50638],[-0.20327,53.46674],[-0.12254,53.45489], 
[0.02643,53.46201],[0.08385,53.49654],[0.22836,53.40840], 
[0.26803,53.34254],[0.30271,53.29408]],[[-0.40406,53.32102], 
[-0.41035,53.29527],[-0.42949,53.26455],[-0.36920,53.22594], 
[-0.37631,53.20236],[-0.31336,53.18250],[-0.28899,53.17916], 
[-0.25398,53.23297],[-0.30694,53.33457],[-0.40406,53.32102]]]};

            var geojson_format = new OpenLayers.Format.GeoJSON();
            var vector_layer = new OpenLayers.Layer.Vector();

            map.addLayer(vector_layer);
             
vector_layer.addFeatures(geojson_format.read(test_territory));
         }
     </script>
   </head>
   <body onload="init()">
     <h1 id="title">GeoJSON Example</h1>
     <div id="map" class="smallmap"></div>
   </body>
</html>




More information about the Dev mailing list