javascript - Set extent of view in OpenLayers 3 -
After
I just started getting an eye on OpenLayers 3 and there was one feature to which the extent of one is happening. Attempting to zoom for the geographical location sent by the server (which will change in each refresh, so I can not code the hard / zoom / central point). . I want to get the page load as quickly as this, but I am struggling to get it to work
I keep getting an error saying: "Uncaught TypeError is not undefined function Is "the line where I try to read geometry from the geo-jsn object, and I'm not really sure how to fix it. Geographical string looks fine (I tried to parse it before passing it to read guitar, but he gave the same result)
If I am doing this since then, then its There is an easy / fast way for me to be interested in hearing this too! Any help is greatly appreciated.
var feature = new ol.Feature ({}); Var View = New ol.View ({center: [0, 0], zoom: 1}); Var Client = New XMLHttpRequest (); Client.open ('GET', 'http: // localhost: 3000 / extent'); Client.send (); Client.onreadystatechange = function () {if (client.readyState == 4 & client.status == 200} {var geomstring = client.responseText; Console.log (geomstring) var geojson = new ol.format.GeoJSON (); Var geom = geojson.readGeometry (geomstring); Var size = (map.getSize ()); Feature.setGeometry (geom); See: Fat Grammetry (Geome, Size, {Padding: [170, 50, 30, 150], Prevent Obstacle: Incorrect}};}} Var map = new ol.Map ({layers: [raster, vector, feature] , Target: 'map',});
geometry reading should work like this :
verjojan = new ol.format.GeoJSON (); on json = {"st_asgeojson": "{\" type \ ": \" polygon \ ", \" coordinate \ ": [[[2416.91312435933,6700304.87650272], [- 2416.91312435933,6700339.02584392], [- 2255.97853651961.66700339.02584392], [- 2255.97853651961,6700304.87650272], [- 2416.91312435933,6700304.87650272]]]]} "}; var geom = geojson.readGeometry (json ['St_asgeojson']); console.log (geom.getArea ());
Comments
Post a Comment