NGW CORS

CORS testing with OL3 WFS

by _DR_

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.js"></script>
<div id='map'>
</div>

CSS

#map {
    height: 100%;
    width: 100%;
    position:fixed;
}

JavaScript

var url = 'http://rykovd.nextgis.com/api/resource/66/wfs?' +
    'SERVICE=WFS&' +
    'REQUEST=GetFeature&' +
    'TYPENAME=track&' +
    'VERSION=1.0.0';

var map = new ol.Map({
    layers: [
        new ol.layer.Tile({
            source: new ol.source.OSM()
        }),
        new ol.layer.Vector({
            source: new ol.source.Vector({
                format: new ol.format.WFS({
                    featureNS: 'http://featureserver.org/fs',
                    featureType: 'track',
                    gmlFormat: new ol.format.GML2()
                }),
                url: url
            }),
            style: new ol.style.Style({
                stroke: new ol.style.Stroke({
                    width: 3,
                    color: [255, 120, 0, 0.9],
                    lineDash: [10, 5]
                })
            })
        })
    ],
    target: 'map',
    view: new ol.View({
        center: [9449777.3, 6914882.51],
        zoom: 7
    })
});