openlayers-3

Make marker zoom/rotate with map in Openlayers 3

六眼飞鱼酱① 提交于 2019-12-06 04:21:11
I'm trying to overlay an image over an OpenLayers 3.0 map by adding a point feature to the layer, and setting the icon to the image to load. How can I get it to scale with the map as it is being zoomed? Or is there a better way to overlay an image atop a layer? p=ol.proj.transform( [-78,40],'EPSG:4326','EPSG:3857') var f=new ol.Feature({ geometry: new ol.geom.Point(p) }); var imgStyle=new ol.style.Style({ image: new ol.style.Icon(({ rotateWithView: false, anchor: [.5,.5], anchorXUnits: 'fraction', anchorYUnits: 'fraction', opacity: 0.75, src: 'http://www.viseyes.org/shiva/map.jpg' })) }); f

Openlayers-3 Force a map refresh

允我心安 提交于 2019-12-06 02:06:44
问题 I have a custom styling that shows/hides features on the map, but when it is applied it doesn't activate until the map refreshes due to a feature update, but I need it to trigger immediately. I tried map.render and renderSync() but they did nothing. mapResize() doesn't appear to do anything either, but if I wait for a feature to be updated or move the map it works. Any ideas? How can I FORCE the map to redraw on demand, regardless of a feature update? 回答1: I believe you need to force your

OL3: force redraw layer

ぐ巨炮叔叔 提交于 2019-12-06 01:11:24
问题 i am currently upgrading OpenLayers client version 2.13.1 with the new version of OpenLayers, OL3. My setup consist of Mapserver as a WMS mapping server and previously mentioned OpenLayers client. In old system I made support for user interaction in the way that if a user click on some part of map, the mapfile gets generated again, and as a result I force to redraw layer to get some part of map colored. Example of the code in the OL2 version: $.ajax({ params: ... success: function (data) { if

Openlayers 3 Reproject EPSG:4326 vector to EPSG:3857

纵然是瞬间 提交于 2019-12-05 19:35:21
I am needing to transform GeoJSON vector data from EPSG:4326 to EPSG:3857... I have a map... var olMapDiv = document.getElementById('olmap'); control.map = new ol.Map({ target: olMapDiv, renderer: 'canvas', layers: layers, interactions: ol.interaction.defaults({ altShiftDragRotate: false, dragPan: false, rotate: false }).extend([new ol.interaction.DragPan({ kinetic: null })]), pixelRatio: 1, loadTilesWhileAnimating: true, loadTilesWhileInteracting: true, view: view }); and a view... var view = new ol.View({ // make sure the view doesn't go beyond the 22 zoom levels of Google Maps maxZoom: 21,

openlayers-3 in node.js app?

旧街凉风 提交于 2019-12-05 14:24:49
I'm interested in using ol3 in a node.js app (e.g. the ol.format APIs for reading GeoJSON). Is that a supported use case? I ask because it doesn't appear to work by just running npm install openlayers and then requiring it. var ol3 = require('openlayers') fails on code that's looking for the geolocation property of the window.navigation object since the window.navigation doesn't exist in a node.js environment TypeError: Cannot use 'in' operator to search for 'geolocation' in undefined at /home/me/src/ol3/node_modules/openlayers/dist/ol.js:144:823 at OPENLAYERS (/home/me/src/ol3/node_modules

How to delete a listener in OpenLayers 3

試著忘記壹切 提交于 2019-12-05 08:23:32
I make a copy of my question here at stackoverflow, because at gis.stackexchange all my questions do not attract any attention - many times I could not get an answer to simple questions there. So, my question now is how to delete a listener defined this way: map.getViewport().addEventListener('click', function (e){ console.log("clicked"); }); OL3 emmits its own kind of events you could use instead and, to answer your original question, gives an easy and quick way to unregister them. Look at this example: http://openlayers.org/en/v3.13.0/examples/vector-layer.html More specifically, at these

Display WFS layer in ol3

╄→尐↘猪︶ㄣ 提交于 2019-12-05 06:27:36
问题 I'm working with geoserver and openlayers 3, i have a hosted layer in geoserver that i want display using ol3 as a wfs layer. it doesn't show any errors, but i dont get the map. it works with wms, but not wfs. I'm using wamp server to host my application. Please can anyone help me to fix that? This is my code : var v=new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.WFS({ version: '1.1.0', url: 'http://localhost:8080/geoserver/wfs', featurePrefix: 'opengeo',

Use Semantic-UI (or Font Awesome) icons as markers in OpenLayers3

纵饮孤独 提交于 2019-12-05 03:42:31
Is there a way to use icons from Semantic UI or FontAwseome as markers icons in OpenLayers3 ? OpenLayers features the feature style Text that can be used as follows: var blackFill = new ol.style.Fill({color: 'black'}) var whiteStroke = new ol.style.Stroke({color: 'white', width: 1}) var iconText = new ol.style.Text({font: "<my font>", text: "<some string>", fill: blackFill, stroke: whiteStroke }) var featureStyle = new ol.style.Style({ text: iconText }); After checking the style of Semantic UI elements, I discovered it is using "Icons" as font-family and escaped characters to choose the symbol

Javascript editing WFS from GeoServer using OpenLayers

て烟熏妆下的殇ゞ 提交于 2019-12-05 02:30:36
问题 After reading a very good tutorial on how to edit WFS with OpenLayers, I've tried replicating it but with my own WFS layer from Geoserver. Need some Javascript help finding what's wrong with it. I managed to load the WFS and my basemap successfully and managed to get the buttons to show up. The buttons appear correctly like in the working example from that page but, for some reason the geometry data isn't being saved. Every time a user draws something, a new id is created on the table but its

node.js and geoserver CORS

£可爱£侵袭症+ 提交于 2019-12-04 23:50:35
I have node.js server 0.10.12 and express.js 4.8.5. Node.js is the web server, includes openlayers 3.9.0. Geoserver 2.1.3 serves the WMS layer. Later, I will implement vector layers. There is only one route (for the index page) var routes = require('./routes/index'); The index.js contains var express = require('express'); var router = express.Router(); router.get('/', function(req, res, next) { res.render('index', { title: 'openlayers3 testing', head: 'Welcome' }); next(); }); module.exports = router; So the app.js has var routes = require('./routes/index');//explained above var app = express(