Questions tagged [openlayers]

Use when the version you are using of the OpenLayers JavaScript client toolkit is 3 or later

ollogo

General Information

OpenLayers is a JavaScript library that provides developers with an API for browser-based mapping. Using the latest technologies, the API claims a high-performance and feature-rich experience. OpenLayers makes it easy to put a dynamic map in any web page. It can display map tiles, vector data and markers loaded from any source. OpenLayers has been developed to further the use of geographic information of all kinds. It is completely free, Open Source JavaScript, released under the 2-clause BSD License (also known as the FreeBSD).

The OpenLayers library supports a wide variety of tile and vector formats including XYZ, WFS, WMS, KML, GML, and GeoJSON. Bing Maps and OSM base maps are supported. Access to the Google Maps API's base maps is available through a third party utility. Utilities for projections and transformations are also provided.

With v3.x, OpenLayers was completely rewritten, and as such the paradigm known from OpenLayers 2 has completely changed. The examples page is useful for beginners, and the API documentation is helpful in finding functions that are not exemplified. Both examples and API are available on the openlayers.org and update with every version.


Examples

Use the examples to get a feel for how the API works, and leverage the jsFiddle integration to try out other things.

latest release
http://openlayers.org/en/latest/examples/

master
http://openlayers.org/en/master/examples/


API

The API details all functions of the application, but some may be flagged as 'experimental' and may be deprecated or altered in future releases.

latest release
http://openlayers.org/en/latest/apidoc/

master
http://openlayers.org/en/master/apidoc/


Source Code

For advanced developers, the entire source code is available on GitHub. Due to being open source, the latest version of the API

Source (latest release)
https://github.com/openlayers/openlayers/releases/latest

Source (main)
https://github.com/openlayers/openlayers/tree/main


Issues

Known issues and logged issues are kept on GitHub.

https://github.com/openlayers/openlayers/issues


For information on tagging guidelines for OpenLayers questions see the Meta Q&A at http://meta.gis.stackexchange.com/questions/4425/updating-openlayers-openlayers-2-and-openlayers-3-tags

3637 questions
16
votes
1 answer

How to resize a feature and prevent it from scaling when zooming in OpenLayers 3

I have initialized a custom OpenLayers 3 map (used to show houses for sale in the neighborhood) with an image as the map. Then, I create additionnal features and layers dynamically for each house (each feature's anchor is set as the middle of its…
Jeff Noel
  • 227
  • 1
  • 3
  • 10
15
votes
7 answers

Equivalent of layer.redraw(true) in OpenLayers 3?

I have a geojson layer in my OL3 app which I want to redraw every 5 seconds (to show movement on map) . How do I do it ? Couldn't find the equivalent of Layer.redraw().
Alophind
  • 2,707
  • 5
  • 40
  • 75
12
votes
1 answer

OpenLayers Hide/Show Layers from external checkboxes

I'm using OpenLayers with mapserver to display a lot of raster images and queryable wms layers. Everything works fine, the layers can be turned on/off in the OpenLayers layer switcher...But now I want to turn on/off the layers by external checkboxes…
Peter
  • 129
  • 1
  • 1
  • 3
11
votes
1 answer

Add properties name label or id to a feature

I'm new to OpenLayers 3 and I'm trying to add a property (id, name or label) to a feature to get it back on click later, to identify that particular feature. Is it possible? I haven't found any answer doing this yet. Something like: var…
Ademus
  • 119
  • 1
  • 1
  • 3
10
votes
3 answers

Setting OpenLayers 3 Layer Visibility

I'm trying to upgrade my Openlayers 2.12 map to Openlayers 3 to take advantage of the fantastic transition effects on transparent layers (Something OL2 and Leaflet can't do attractively). This and I don't want to lag behind upgrading my sites when…
Phill
  • 195
  • 1
  • 1
  • 10
10
votes
3 answers

What are the possible listeners and event types for an openlayers map (ol.Map)?

I cannot find this in the docs anywhere but it should be an easy answer for anyone who knows OpenLayers on the inside. In OpenLayers 4.2, what are the possible key values for listeners: during instantiation of an ol.Map object and what are the…
medley56
  • 365
  • 1
  • 3
  • 13
10
votes
1 answer

OpenLayers 3: getting rid of 'blue dot' selection icon

I am working on a digitizing tool. There are four buttons as of now: add point add line add polygon remove geometry The user always starts by first drawing some geometries. I am using the Draw interaction (ol.interaction.Draw) and the geometries…
BritishSteel
  • 6,637
  • 4
  • 38
  • 64
10
votes
2 answers

Openlayers simple custom control example

On the official openlayers site there is a custom control example which demonstration a class base control. Can anyone give an example of a simple custom control without class usage? According to the ol.control.Control specification, it should be…
yaugenka
  • 829
  • 2
  • 12
  • 23
10
votes
1 answer

OpenLayers 3 - draw multiple lines/paths based on coordinates

I am trying to draw a line(s) based on give coordinates (starting and ending point). Googled , found few examples but non of them seem to work probably because they are for OL2, so this is my last resort. The coordinates are located in markers…
Malinois
  • 103
  • 1
  • 1
  • 4
9
votes
1 answer

OpenLayers 4 differences from 3.x

In OpenLayers 4 changelogs, it explains: Unlike the switch from v2.x to v3.x, which marked a complete rewrite of the library with an entirely new API, major version increments now simply mean that users should pay attention to the 'Breaking…
TonyGis
  • 213
  • 2
  • 11
9
votes
3 answers

How to force a ol.source.Vector to reload data from server?

I have a ol.source.Vector like this: var geoJSONFormat = new ol.format.GeoJSON(); vectorSource = new ol.source.Vector({ strategy: ol.loadingstrategy.bbox, loader: function(extent, resolution, projection) { var url = getUrl( extent…
Magno C
  • 2,140
  • 3
  • 24
  • 63
9
votes
2 answers

Creating new buttons and removing default ones - Openlayers-3

I am trying to create new buttons but I seem to use the wrong function. To delete the default buttons I added the following code: var map = new ol.Map({ target: 'map', controls: [], layers: [ new ol.layer.Tile({ ... etc This works…
PIDZB
  • 465
  • 2
  • 8
  • 15
9
votes
2 answers

Remove selected feature Openlayers 3

I'm using openlayers 3 to create web application that allow to user to draw LineString features in the map. this is the code: var raster = new ol.layer.Tile({ source: new ol.source.MapQuest({ layer: 'sat' }) }); var source = new…
Ahmed Abd Elmoniem
  • 103
  • 1
  • 1
  • 4
9
votes
2 answers

How to draw a polygon in OpenLayers 3?

As my project requirement I want to draw a polygon look like this (>. In this case draw polygon sides too dense for arc. Successfully draw this using LineString but how to draw it using polygon. Need polygon because I have to fill color in between. …
Sowvik Roy
  • 445
  • 2
  • 5
  • 13
9
votes
1 answer

what is the rightclick handler in openlayers3

I used rightclick handler with openlayers2 and now I am upgrading my website to openlayers3 and I cannot find this handler in ol3
Mariam Malak
  • 603
  • 1
  • 6
  • 17
1
2 3
41 42