openlayers-3

Convert point to lat lon

泪湿孤枕 提交于 2019-12-02 23:14:24
I wonder, how can I get map click event's coordinates as lat,lon? Here is my code: map.on('click', function(evt) { var element = popup.getElement(); var coordinate = evt.coordinate; var latLon = ol.proj.transform(coordinate, 'EPSG:3857', 'EPSG:4326'); $(element).popover('destroy'); popup.setPosition(coordinate); Normally, coordinate value gives me an array etc: [48654.02545, 3265468.45455] But I need lat lon etc:([39,54876,32,547821]) Abstract: I need to convert epsg:3857 coordinate to epsg:4326 coordinate (lat/lon) Any idea? If your map view projection is Web Mercator (EPSG:3857), which is

How to get coordinates on double click on Openstreetmap?

纵然是瞬间 提交于 2019-12-02 13:18:41
I am using angular-openlayers-directive , I want to get coordinates of the point where I double click. A similar question: Convert point to lat lon But I want to use it in angularjs. You should check this example out: http://tombatossals.github.io/angular-openlayers-directive/examples/080-events-propagation-example.html . It shows how you can find the lat-long coordinates for mouseover. Also, here is a fiddle I made showing how you can extend it for double click: http://jsfiddle.net/anushamc/6q2az5xz/ . Briefly, you need to listen for the events on the map by including it in the defaults like:

Error when posting features to postgis by openlayers and geoserver

无人久伴 提交于 2019-12-02 09:28:17
问题 I found an error when posting features to postgis by openlayers and geoserver. The code is listed below. And the error was that the var 'data' which was converted from the var 'node' by XMLSerializer was wrong, the order of X and Y in it was reverse, just like "28.795251846313476 116.4409589767456 ". So geoserver rejected the request, because the coordinates of Y were outside of (-90,90). var feature = evt.feature; var node = format.writeTransaction([feature], null, null, { gmlOptions:

Selecting map objects using ol.source.TileWMS in open layers 3

不问归期 提交于 2019-12-02 07:52:25
问题 I am using open layers 3, and I am using this code for displaying the map: wmsSource = new ol.source.TileWMS({ url: 'http://demo.boundlessgeo.com/geoserver/wms', params: { 'LAYERS': 'ne:ne' }, serverType: 'geoserver', crossOrigin: '' }); var wmsLayer = new ol.layer.Tile({ source: wmsSource }); I am using dragbox to make the rectangular selection and when I do the shift + drag I am not able to select the objects in map. Can somebody please help me on how to achieve it? This is the code I am

How to add shapefiles to a Bing Map using Openlayers 3

戏子无情 提交于 2019-12-02 07:32:14
I am using Openlayers3 with Bing Maps to build my application. I have a point shapefile and would like to show it on the map. I could do it using Openlayers2 using the OpenLayers.Layer.GML() construct but am facing difficulty while trying to the same with Openlayers 3. I tried searching for this and the openlayer example gives me an error: 'Cannot read property 'ogc' of undefined'. My shapefile is on GeoServer in my own system. So any help regarding this matter is highly appreciated :) The example you linked is from a very old beta version of OpenLayers 3. You can find the examples from the

Selecting map objects using ol.source.TileWMS in open layers 3

可紊 提交于 2019-12-02 04:38:22
I am using open layers 3, and I am using this code for displaying the map: wmsSource = new ol.source.TileWMS({ url: 'http://demo.boundlessgeo.com/geoserver/wms', params: { 'LAYERS': 'ne:ne' }, serverType: 'geoserver', crossOrigin: '' }); var wmsLayer = new ol.layer.Tile({ source: wmsSource }); I am using dragbox to make the rectangular selection and when I do the shift + drag I am not able to select the objects in map. Can somebody please help me on how to achieve it? This is the code I am using for rectangular selection. dragBox.on('boxend', function(e) { // features that intersect the box

Error when posting features to postgis by openlayers and geoserver

我只是一个虾纸丫 提交于 2019-12-02 04:32:49
I found an error when posting features to postgis by openlayers and geoserver. The code is listed below. And the error was that the var 'data' which was converted from the var 'node' by XMLSerializer was wrong, the order of X and Y in it was reverse, just like "28.795251846313476 116.4409589767456 ". So geoserver rejected the request, because the coordinates of Y were outside of (-90,90). var feature = evt.feature; var node = format.writeTransaction([feature], null, null, { gmlOptions: {srsName: "EPSG:4326"}, featureNS: "ucoc.zhtx.com", featureType: "landblock" }); var data=new XMLSerializer()

Polygon Selection OpenLayers 3

ε祈祈猫儿з 提交于 2019-12-02 00:44:03
问题 How can you select features with a polygon draw? It can be done with a square box select as per the examples. I'm wondering if there's a way to trigger an event after creating the polygon to go and check for intersections with it and other features. In my case I'm trying to capture datapoints. var select = new ol.interaction.Select(); map.addInteraction(select); var selectedFeatures = select.getFeatures(); // a DragBox interaction used to select features by drawing boxes var dragBox = new ol

How to make ol.source.ImageWMS send POST request

孤街醉人 提交于 2019-12-01 18:46:58
In our project, we're using OpenLayers-3's ol.source.ImageWMS to show image provided by Mapserver WMS. Since we're using Mapserver runtime substitution, our request can become quite long, wich could cause a problem for a GET request. Is there a way to make ol.source.ImageWMS send POST request? I answer this just for the reference based on this Openlayers dev thread , hopefully it will help someone in the future!. I needed to pass a very long CQL request to a Geoserver wms, and GET was limited in size, so I used POST like the following: var POSTWMSLayer = new ol.layer.Image({ source: new ol

Ensuring all tiles are loaded in Open Layers 3 XYZ source

僤鯓⒐⒋嵵緔 提交于 2019-12-01 15:58:46
We have some layers that make use of a ol.source.XYZ source. For the loading strategy we use ol.loadingstrategy.tile(new ol.tilegrid.createXYZ({})) . We need to ensure that all tiles have been completely loaded in the map view before proceeding with other operations. We have come across multiple articles regarding this and haven't found a 100% solution yet that will give us the solution we need. The logic returns true even when it's not the case. We've tried to make use of the tileloadstart, tileloadend, tileloaderror events as shown on the example page but this doesn't seem to always return