Port vector examples to new vector API

This commit is contained in:
Éric Lemoine
2015-04-03 22:15:55 +02:00
parent 09b90c8424
commit bdb326c310
24 changed files with 346 additions and 311 deletions

View File

@@ -5,31 +5,34 @@ goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.loadingstrategy');
goog.require('ol.source.BingMaps');
goog.require('ol.source.ServerVector');
goog.require('ol.source.Vector');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.tilegrid.XYZ');
var vectorSource = new ol.source.ServerVector({
format: new ol.format.GeoJSON(),
// format used to parse WFS GetFeature responses
var geojsonFormat = new ol.format.GeoJSON();
var vectorSource = new ol.source.Vector({
loader: function(extent, resolution, projection) {
var url = 'http://demo.boundlessgeo.com/geoserver/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
'outputFormat=text/javascript&format_options=callback:loadFeatures' +
'&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';
$.ajax({
url: url,
dataType: 'jsonp'
});
// use jsonp: false to prevent jQuery from adding the "callback"
// parameter to the URL
$.ajax({url: url, dataType: 'jsonp', jsonp: false});
},
strategy: ol.loadingstrategy.createTile(new ol.tilegrid.XYZ({
strategy: ol.loadingstrategy.tile(new ol.tilegrid.XYZ({
maxZoom: 19
})),
projection: 'EPSG:3857'
}))
});
// the global function whose name is specified in the URL of JSONP WFS
// GetFeature requests
var loadFeatures = function(response) {
vectorSource.addFeatures(vectorSource.readFeatures(response));
vectorSource.addFeatures(geojsonFormat.readFeatures(response));
};
var vector = new ol.layer.Vector({