Openshift with Geoserver and PostGIS DB configured...now what? -
i've set geoserver , postgis db on openshift. can confirm have data in db because can connect qgis , add layers....now trying create simple map 1 layer can not find tutorials on this... below code works local instance of data create simple map...what url use layers created on openshift? can't seem find them.
<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>ogr2layers</title> <style> #map{width:400px;height:400px;} </style> <script src="http://www.openlayers.org/api/2.13/openlayers.js"></script> <script type="text/javascript"> var map, selectscontrols function init(){ var option = { projection: new openlayers.projection("epsg:900913"), displayprojection: new openlayers.projection("epsg:4326") }; map = new openlayers.map('map', option); var attribution = {attribution:"© <a href='http://www.openstreetmap.org/copyright'>openstreetmap</a> contributors"}; olmapnik = new openlayers.layer.osm("openstreetmap mapnik", "http://tile.openstreetmap.org/${z}/${x}/${y}.png", attribution); map.addlayer(olmapnik); map.setbaselayer(olmapnik); var ls= new openlayers.control.layerswitcher(); map.addcontrol(ls); ls.maximizecontrol(); map.addcontrol(new openlayers.control.mouseposition()); map.addcontrol(new openlayers.control.navigation()); var block = new openlayers.layer.vector("block geojson", { protocol: new openlayers.protocol.http({ url: "block.geojson", format: new openlayers.format.geojson() }), strategies: [ new openlayers.strategy.fixed() ] }); map.addlayer(block); extent = new openlayers.bounds(-97.640446,21.693337,-80.768595,32.375889).transform(new openlayers.projection("epsg:4326"), new openlayers.projection("epsg:900913")); map.zoomtoextent(extent); }; </script> </head> <body onload="init()"> <h1>this test</h1> <div id="map"></div> </body> </html>
based on example, think need http://demo.boundlessgeo.com/geoserver
changed domain gave openshift instance:
// format used 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'; // use jsonp: false prevent jquery adding "callback" // parameter url $.ajax({url: url, datatype: 'jsonp', jsonp: false}); }, strategy: ol.loadingstrategy.tile(ol.tilegrid.createxyz({ maxzoom: 19 })) });
Comments
Post a Comment