1

I'm using Django and Openlayers to add some data from my PostGIS database to the map but can't seem to work out how to style the vector layer that uses the kml.

var layer = new ol.layer.Vector({
    title: 'Polygon',
    source: new ol.source.Vector({
      projection:new ol.proj.get("EPSG:3857"),
      url:'http://localhost:8000/layer',
      format: new ol.format.KML(),
      extractStyles: false,
    }),
    });

    map.addLayer(layer);

I've been through lots of tutorials attempting to use ol.style.Style and styleMaps and more but whatever I do the layer stays as just white. I was wondering if anyone knew if this was just a recent change in the OpenLayers code meaning there aren't any tutorials or if there is a solution anyone may know about.

1

I'm still using OL2, because it seems to me that OL3 doesn't add any functionality that justifies the enormous coding effort in rewriting existing pages to use it, and moreover, I can't get any of the more recent OL3 releases to work with Firebug or the developer tools in the latest version of FF. Nevertheless, I do have a working OL3 example here ... http://www.macfh.co.uk/JavaJive/ProgScriptWeb/UKOSOpenLayers.shtml which contains two examples of styling, an 'old' way and a 'new' way - yes, that's right, they've already changed some things completely within the lifetime of OL3! The working demo is uncrunched and uncompressed (I hope, tell me if it isn't - I've been doing some work on the site recently and haven't had time to check out every single page yet), so hopefully you can read the code fairly easily - the 'old' method was via coding, the 'new' method uses CSS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.