openlayers-3

Openlayers 3 Circle radius in meters

Deadly 提交于 2019-11-29 15:38:48
问题 How to get Circle radius in meters May be this is existing question, but i am not getting proper result. I am trying to create Polygon in postgis with same radius & center getting from openlayers circle. To get radius in meters I followed this. Running example link. var radiusInMeters = circleRadius * ol.proj.METERS_PER_UNIT['m']; After getting center, radius (in meters) i am trying to generate Polygon(WKT) with postgis (server job) & drawing that feature in map like this. select st_astext(st

How to load Open layers 3 geojson vector layer with bbox?

南笙酒味 提交于 2019-11-29 12:12:27
I am struggling with building OL3 Vector layer BBOX strategy loading. So far I can easily load Geojson file with valid json syntax, however this is one time strategy. My another approach was to use ol.ServerVector which to my understading returns Javascript with callback, but I can't make it work. Working simple Geojson layer: var vectorSource = new ol.source.GeoJSON( ({ projection: 'EPSG:3857', preFeatureInsert: function(feature) { feature.geometry.transform('EPSG:4326', 'EPSG:3857'); }, url: 'geojson2.json' })); var vectorLayer = new ol.layer.Vector({ source: vectorSource, style:

Restrict Pan outside WMS extent in OpenLayers3

放肆的年华 提交于 2019-11-29 02:30:51
问题 I have rectangle WMS of small area and want to restrict panning outside WMS extends, so there aren't white or black area outside the map visible at all. Adding extent to View does not work for me and in documentation about this option is written The extent that constrains the center, in other words, center cannot be set outside this extent. But as I understand this if center is in the area of extent, but on the very corner, it will show white area outside this extent, but I don't want to see

open layers 3 how to draw a polygon programmatically?

会有一股神秘感。 提交于 2019-11-29 01:56:55
How to draw a polygon use open layer 3 programmatically? i have a json array coordinate: [ { "lng": 106.972534, "lat": -6.147714 }, { "lng": 106.972519, "lat": -6.133398 }, { "lng": 106.972496, "lat": -6.105892 } ] and now i want to draw it on map use open layers. how to do it? You need to use the ol.geom.Polygon constructor. That constructor expects an array of rings, each ring being an array of coordinates. In your case this is how you will create the polygon (this assumes your array of lng lat pairs is named a ): // A ring must be closed, that is its last coordinate // should be the same as

OpenLayers 3: How to calculate distance between 2 points?

霸气de小男生 提交于 2019-11-29 01:37:18
Using OpenLayers 3, how can I determine the distance between two points in the Spherical Mercator (SRID: 3857) projection? I know that distanceTo was used in OpenLayers 2 point1.distanceTo(point2) I looked through the OpenLayers 3 docs , but I'm not finding anything similar... markov00 You can use the Sphere object to calculate the distance between two coordinates like this: var distance = ol.sphere.WGS84.haversineDistance([0,0],[180,0]); //20037508.34 meters Sphere provides also various algorithms to calculate the distance like cosine,equirectangular etc. You can also create the Sphere object

Openlayers 3: how to select a feature programmatically using ol.interaction.Select?

大憨熊 提交于 2019-11-28 21:59:02
I'm using OpenLayers v3.6 (this is important, because most of solutions that I found and would potentialy work are for OpenLayers 2). I have a table and when I select a row in that table, I would like to highlight/select a corresponding feature on the OpenLayers map. All features are simple polygons ( ol.geom.Polygon ) in the same vector layer ( ol.layer.Vector ). I set up select interaction like this: // there is a lot of other code here ... addSelectListener: function() { this.SelectInteraction = new ol.interaction.Select({ condition: ol.events.condition.singleClick, layers: function (layer)

Vector tiles on top of raster tiles is not getting displayed in openLayers

你。 提交于 2019-11-28 11:30:57
问题 I am trying to render vector tiles on top of raster tiles in open layers map version 4.3.3. Both the tiles are getting render but vector tiles is not getting displayed over raster tiles.For example, I have vector tiles for one of the state and want this to display as semi transparent layer on top of raster tiles. I have store my vector tiles on S3 bucket and tileLoadFunction fetching those from S3 bucket. I haven't set any projection. I think tileLoadFunction has some default projection.

How can I use a SVG image as layer on OpenLayers-3

回眸只為那壹抹淺笑 提交于 2019-11-28 06:57:27
How can I use a SVG image as a Layer (so not as a map marker) with OpenLayers-3 I was unable to get any output of my SVG image when using any of the ol.source.Vector and ol.format.Feature instances. Small example: var mapLayer = new ol.layer.Vector({ source: new ol.source.Vector({ url: 'image.svg', format: new ol.format.Feature() // http://openlayers.org/en/v3.12.1/apidoc/ol.format.Feature.html }), }); I was able to get output when using the ImageStatic layer, but this uses/generates(?) a static image so the advantages of SVG are gone. Example: // Not sure if I need this for SVG, but is is

Access to Image from origin 'null' has been blocked by CORS policy

爱⌒轻易说出口 提交于 2019-11-28 06:43:38
I have JavaScript application in OpenLayers 3, and my base layer is created from local tiles. I work only in my computer so I do not know why I have CORS error. var newLayer = new ol.layer.Tile({ source: new ol.source.OSM({ url: 'E:/Maperitive/Tiles/vychod/{z}/{x}/{y}.png' }) }); var schladming = [21.6187, 48.7327]; // longitude first, then latitude // since we are using OSM, we have to transform the coordinates... var schladmingWebMercator = ol.proj.fromLonLat(schladming); var map = new ol.Map({ layers: [ newLayer ], controls: [], target: 'mapid', view: new ol.View({ center:

How to load Open layers 3 geojson vector layer with bbox?

和自甴很熟 提交于 2019-11-28 06:01:02
问题 I am struggling with building OL3 Vector layer BBOX strategy loading. So far I can easily load Geojson file with valid json syntax, however this is one time strategy. My another approach was to use ol.ServerVector which to my understading returns Javascript with callback, but I can't make it work. Working simple Geojson layer: var vectorSource = new ol.source.GeoJSON( ({ projection: 'EPSG:3857', preFeatureInsert: function(feature) { feature.geometry.transform('EPSG:4326', 'EPSG:3857'); }, url