FAQ Database Discussion Community


How to display a track on a layer with lat and long

javascript,dictionary,openlayers,latitude-longitude,gpx
i just want to show a track on my map i tried as follow but the problem is i don't want to load track point in layer from GPX File (because i don't want to generate file from coordinates witch i get from GPSdevice programmatically) is there any way to...

OpenLayers - Get Geometry Projection

javascript,openlayers,gis,map-projections
How can I get projection of a point or geometry in openlayers (2.12)? for example: x = 30.453789 , y = 35.637485 ==> EPSG:4326 and x = 3667550.3453 , y = 2205578.3453 ==> EPSG:900913 appreciate any help...

How to check if a polygon contains another polygon in OL3?

algorithm,openlayers,geospatial,openlayers-3
Is there any possibility to check if a polygon is contained in another polygon in OL3? I noticed there is a couple of methods in ol.extent e.g. ol.extent.containsExtent(extent1, extent2). But this checks only the extents and not the entire polygon. So in some cases I get "true" although the polygon...

remove layer from open layers not working

javascript,openlayers,openlayers-3
I am trying to add layers from GeoServer; it's working fine but removing layers is not working. This is my code: function loadTOCLayer(layerName) { var tl = new ol.layer.Tile({ extent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34], source: new ol.source.TileWMS( /** @type {olx.source.TileWMSOptions} */ ({ url: 'http://172.16.1.58:8080/geoserver/KBJNL/gwc/service/wms', params: { 'LAYERS': layerName, 'TILED': true...

Replacement of OpenLayers.Control.NavigationHistory in OpenLayers 3

openlayers,openlayers-3
Is there any replacement of OpenLayers.Control.NavigationHistory (OpenLayers 2) in OpenLayers 3? I did not find any example in the OpenLayers 3 Examples page.

Openlayers 3.5 undefined coordinate

javascript,openlayers,openlayers-3
I'm trying to get the coordinates of the Circle drawing in ol 3.5. I use the evt.coordinate function to get the coordinates, but I keep getting undefined. Here's a piece of my code: this.boundingCircle = new ol.interaction.Draw({ condition: ol.events.condition.always, source: source, style: new ol.style.Style({ fill: new ol.style.Fill({ color: [50,50,255,0.5] }),...

OpenLayers.Format.CQL fails when parsing after/before

openlayers,cql,geoserver
I am trying to add a filter to my OpenLayers WMS layer var format = new OpenLayers.Format.CQL(); var date = this.controls.UploadAfter.getValue(); filterArray.push("upload_time after " + date.format("Y-m-d") + "T00:00:00"); Then i try to parse it var filter; try { filter = format.read(filterArray.join(" and ")); } catch (err) { alert("Filter cannot be...

Compare a value with all the values in array in Javascript

javascript,openlayers
I am trying to make the following function run but I have stucked badly. I have an object "gidsAll" which I want to compare with each feature: feature.attributes.__gid. The function is used in Openlayers for styling purpose of the features (points and lines). It is executed for each "feature.attributes.__gid" and...

Openlayers: select a feature programmatically from GeoJson

openlayers,geojson
I am working on a project that uses openlayers (version2.14)to display a Bing layer(GeoJSON format), I have no problem reading the GeoJSON and display features, but I want to select a feature programmatically, for example, there is a table displaying all the features attributes(GeoJSON format.sample: {"type": "FeatureCollection", "features": [ {"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-7923751.4232522,5233536.7371399]},"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}}...

Geolocation with openlayers limits

geolocation,openlayers
Are there any limitations to the geolocation with openlayers? (number of requests, unreliability etc?) Thank you, Alex...

Filter (no display) layers in GeoExt.LegendPanel using LIKE operator [closed]

filter,panel,openlayers,legend,geoext
This works to avoid Basemap layers such as Google Maps and overlays such as WMS to appear in the GeoExt Legend Panel: var legendPanel = new GeoExt.LegendPanel({ border: false, filter: function(record){ if(!(record.getLayer().isBaseLayer) && (record.getLayer() instanceof OpenLayers.Layer.WMS)){ return true; } } }); The problem is that I need to filter (ie....

Openlayers: Vector Layer from Local Variable

javascript,json,openlayers
I am using OpenLayers to make a map from json data. I have to load it once already (with PHP) to check timestamps and verify information. At that point, I'd rather output a javascript variable and just have OL use that. I can't seem anything in the docs to accomplish...

the map wont show up using openlayer

javascript,openlayers,openstreetmap
i'm trying to use openlayer to display a map, but nothing is showing up, all i can see is a white page here is my code <!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js"></script> <script> function init() { map = new OpenLayers.Map("basicMap"); var mapnik = new OpenLayers.Layer.OSM(); var epsg4326 = new...

Drawing a Speed Leader line in OpenLayers

openlayers,openlayers-3
I'm trying to draw an icon representing a entity on an OpenLayers map that includes a "speed leader", which is a small line segment that originates at the icon and draws outward in the direction the entity is moving. The length of the line indicates the speed of entity. The...

How to create without click? [duplicate]

javascript,jquery,html5,openlayers,openlayers-3
This question already has an answer here: Download image with JavaScript 2 answers I have the following jQuery and HTML code and It works perfectly: <a id="bmpFormat">.BMP</a> <script> var exportBMPElement = document.getElementById('bmpFormat'); exportBMPElement.addEventListener('click', function(e) { map.once('postcompose', function(event) { var canvas = event.context.canvas; exportBMPElement.download = 'mapa.bmp' exportBMPElement.href = canvas.toDataURL('image/bmp'); });...

Offline OpenLayers web app using offline OSM

asp.net,openlayers,openstreetmap,offlineapps
I'm trying to create map based web app which user can set landmark on the provided map. Boundaries of map is limited to a small city, and the client computer is always offline, no internet access at all. After a whole day of googling I've found that combination of OpenLayers...

Strange error in WFS request with Openlayers

javascript,python,openlayers,geoserver
I have written a script using OpenLayers library to get some layers from Geoserver and display them on the map. I use both WMS and WFS layers. Everything worked fine in my localhost (MAMP) in windows OS. Now I have to migrate in an UBUNTU 12.10 system. Although I get...

Does an event get fired after the Mapview is fully rendered in openlayers 3?

javascript,ios,openlayers,openlayers-3
I am rendering about 27000 Markers in different layers on a mapview. Everything works fine on a fast device. I have a problem on older devices (like the iPad3). When i hide one layer and set another layer to visible = true, it takes several seconds for the change to...

How can I know which projection code a layer is using?

openlayers,openlayers-3
I've spent a lot of time realizing this: var view = new ol.View({ //this doesn't work //center: [-73.979681,40.7033127], //this works center: ol.proj.transform([-73.979681,40.7033127], 'EPSG:4326', 'EPSG:3857'), zoom: 8 }); I've found on OpenLayer's quickstart how to transform a projection from one to another. However, that isn't very clear on another tutorials. I'm...

Only show one layer at a time in OpenLayers

javascript,openlayers
I have two overlays in OpenLayers and I don't want them to show at the same time. Here's the code I'm using so that when someone uses the layer switcher the other layer turns off. The problem is this code triggers the 'changeLayer' event listener again and the function hides...

Using Stamen tiles in OpenLayers map over HTTPS

javascript,https,openlayers
I'm using Stamen's "toner-lite" tiles in an OpenLayers map like so: var bkgLayer = new ol.layer.Tile({ source: new ol.source.Stamen({ layer: "toner-lite" }) }); var map = new ol.Map({ controls: [zoomInCtrl, scaleLineCtrl, fullScreenCtrl], renderer: 'webgl', target: 'mapViewport' }); map.addLayer(bkgLayer); Everything works fine when the website is running under HTTP. However, if...

How to export a map to fullscreen way (using OpenLayer)?

javascript,jquery,canvas,openlayers
I have the following code and It works perfectly: <style> .map { width: 100%; height: 350px; } </style> <div id="map" class="map"></div> /* Export map to PNG Format */ var exportPNGElement = document.getElementById('pngFormat'); if ('download' in exportPNGElement) { exportPNGElement.addEventListener('click', function(e) { map.once('postcompose', function(event) { var canvas = event.context.canvas; exportPNGElement.href = canvas.toDataURL('image/png');...

Placing a WMS layer above a WFS layer makes WFS layer not selectable

openlayers,layer,geoserver,wms
I have two different layers which I call from Geoserver. The first one is a WMS layer with points and the second one is WFS layer with lines. I need to display the points above the lines and I also need to be able to select each line and get...

Openlayers 3: Binding click event to several maps using a for loop

jquery,for-loop,closures,openlayers,openlayers-3
I would appreciate a little help. Right now I'm learning Openlayers 3. I want to bind a click event to several map objects within a for loop. When I do it like this, the event is only applied to the last map object within the for loop: for(var i =...

Openlayers 2. z-axis and select control

javascript,openlayers,z-axis
I've got a couple vector layers one has polygons, one has lines. We have a need to add lines to the line layer that attach to the polygons (database procedure requires the polygons IDs, which are stored in attributes on the polygons) So I have a drawFeature control on the...

How to rotate text with view using OpenLayers 3

text,view,rotation,openlayers,openlayers-3
I am developing a navigation application, which draws planned route on a map. Planned route consists of points connected with a line. Each point is labelled with distance and direction. When I initially draw the route on the map, I calculate text position in a way, where it doesn't interfere...

Openlayers3 get map from element

javascript,openlayers,gwt-openlayers
Is there a way in Openlayers 3 to get the map that is attached to a specific html element? Something like: var map = new ol.Map({ view: new ol.View({ center: [0, 0], zoom: 1 }), layers: [ new ol.layer.Tile({ source: new ol.source.MapQuest({layer: 'osm'}) }) ], target: 'map' }); //Later on,...

Transformation between projections doesn't work

openlayers,projection
I am trying to make a transformation between two different projections using openlayers but I can not make it work. I am sure that my source projection is EPSG:2100 and I need to transform it to my maps Projection which is the Spherical Mercator. What ever I do the marker...

OpenLayers 3: simple LineString example

javascript,vector,openlayers,openlayers-3
i'm new to OpenLayers and i am looking for some help drawing lines on a map, i've been trying various things from various different posts about drawing LineStrings but i can't get it to work! I just need to figure out how to draw a line between to coordinates. heres...

Openlayers 3 interaction.draw()

javascript,openlayers,openlayers-3
I am trying to create a user interactive circle using the example code from the openlayers example website: var draw = new ol.interaction.Draw({ features: featureOverlay.getFeatures(), type: 'Circle' }); map.addInteraction(draw); I always get a TypeError when I set, type: 'Circle', but when I set the type to Point, LineString, or Polygon...

How to test OpenLayers app with Selenium?

selenium,openlayers
I know this is and oldie, and I apologize for that. But I still haven't found a solution to this. I have recently tried to test my OpenLayers-based app with Selenium. But when I click on the map, it doesn't detect the click in Selenium. I have searched all over...

Using OpenLayers 3 in IE8 (canvas issues)?

javascript,canvas,internet-explorer-8,openlayers,openlayers-3
Does OpenLayers 3 support IE8? I've implemented a map on one of my sites but when I checked it in IE8 on XP then I get an error which traces back to canvas.getContext("2d") on line 27951 of ol-debug.js. It seems that IE8 does not support the canvas element, so should...

Mouse wheel scroll limitation in OpenLayers 3

openlayers
I know that the OpenLayers 3 ol.interaction.MouseWheelZoom accumulates mouse wheel events for an amount of time before it actually fires the event, which is a wanted behavior. However it seems that it limits the maximum zoom step to a constant range. This can be seen in the following function: /**...

Drag & drop something from outside the map onto a feature (openlayers)?

javascript,drag-and-drop,openlayers,openlayers-3
I'm developing a website with openlayers where the user should be able to drag the name of a building from a list of buildings(outside the map) onto a feature on the map. Since I have found no way to do this with openlayers I thought about doing this by using...

OpenLayers 2: draw path with only two points

javascript,openlayers
I want to draw a path with no more then 2 points. On the second point I want the path to be finished. can anyone help me how to get this functionality achieved in openlayers 2. I tried this code but it gives error although lines are created well. _singleLineControl...

Why does the OpenLayers Bing Layer disappear at low/high zoom levels?

zoom,openlayers,bing-maps
I have noticed that the Bing layer from OpenLayers disappears at low (0) and high (20) zoom levels. How could I avoid it? Is it possible to force some limit on the zoom levels? var apiKey = "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf"; var map; map = new OpenLayers.Map('map', { allOverlays: false, autoUpdateSize: true, displayProjection:...