Guest User

Untitled

a guest
Oct 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. var vectorLoader = function(extent, resolution, projection) {
  2. var url = 'http://demo.boundlessgeo.com/geoserver/wfs?service=WFS&' +
  3. 'version=1.1.0&request=GetFeature&typename=osm:builtup_area&' +
  4. 'outputFormat=text/javascript&format_options=callback:loadFeatures' +
  5. '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';
  6. $.ajax({
  7. url: url,
  8. dataType: 'jsonp'
  9. });
  10. };
  11.  
  12. var geoJsonFormat = new ol.format.GeoJSON();
  13.  
  14. var loadFeatures = function (response) {
  15. var features = geoJsonFormat.readFeatures(response);
  16. vectorSource.addFeatures(features);
  17. };
  18.  
  19. var vectorSource = new ol.source.Vector({
  20. format: geoJsonFormat,
  21. loader: vectorLoader,
  22. strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
  23. maxZoom: 19
  24. })),
  25. projection: 'EPSG:3857'
  26. });
  27.  
  28. var serverVector = new ol.layer.Vector({
  29. source: vectorSource,
  30. style: vectorStyle
  31. });
Add Comment
Please, Sign In to add comment