Questions tagged [openlayers-3]

OpenLayers 3 is the complete rewrite of the OpenLayers 2.x mapping library, targeting modern features of HTML5 and CSS3. It is not compatible with OpenLayers 2. OpenLayers is completely free and open source, having been released under the 2-clause BSD License.

OpenLayers 3

OpenLayers 3 is a high-performance, feature-packed library for creating interactive maps on the web.

Beginners may wish to consult the following resources:

Usual search keywords are 'OpenLayers' and 'ol'.

Source code can be found on GitHub at https://github.com/openlayers/openlayers.

Tag usage

Use of the tag was encouraged by OpenLayers developers for questions specific to OpenLayers 3, but it no longer is. The tag will probably get more attention.

2413 questions
103
votes
11 answers

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

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:…
Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174
67
votes
4 answers

how to add markers with OpenLayers 3

I'm trying to add makers on a OpenLayers 3 map. The only example I have found is this one in the OpenLayers example list. But the example uses ol.Style.Icon instead of something like OpenLayers.Marker in OpenLayers 2. First Question The only…
Marc
  • 16,170
  • 20
  • 76
  • 119
24
votes
2 answers

how to get the current zoom in openlayers

i have a question. i need to know the actual zoom of the open layers map $scope.refreshMap = function (lat, long) { map.setView(new ol.View({ projection: 'EPSG:4326', center: [long, lat], zoom: "here I do not know what…
24
votes
12 answers

How to change the cursor on hover in openlayers 3?

I managed to add interactivity to a feature layer added from a remote GeoJSON resource. When I click on a feature I get its ID, fire an AJAX request and display some relevant info about the feature, on the page outside of the map area. I used a…
Pierre Henry
  • 16,658
  • 22
  • 85
  • 105
23
votes
2 answers

React Native Webview with openlayers

I have seen this info: https://stackshare.io/stackups/leaflet-vs-mapbox-vs-openlayers I'm developing at the same time a web application with react using OpenLayers. And I have to make the same app on mobile using react native but I don't know how to…
Javier
  • 231
  • 2
  • 4
23
votes
1 answer

Convert point to lat lon

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,…
gokhangokce
  • 461
  • 3
  • 8
  • 17
22
votes
3 answers

ZoomToExtent OpenLayers 3

OpenLayers 2 had a very useful map.zoomToExtent(extent) feature. Is there something similar in OpenLayers 3? I can get the extent of interest with source.getExtent(), but I can't figure out how to apply that extent as a "zoom level".
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
21
votes
5 answers

OpenLayers 3 Extent of all features on a vector layer?

I have an OpenLayers 3 map with a base layer and a vector layer. this.topoLayer = new ol.layer.Vector({ source: new ol.source.Vector(), style: style }); var baseLayer = new ol.layer.Tile({ source: new ol.source.XYZ({ url:…
SomeBdyElse
  • 427
  • 1
  • 4
  • 11
19
votes
3 answers

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

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…
Matthijs
  • 1,112
  • 2
  • 12
  • 28
19
votes
2 answers

How to get features from vector layer in Openlayers 3

I am trying to get the features from my vector layer. The vector layer is composed from a GeoJSON document loaded via Geoserver. I tried vector.features but in vain. Could anyone help with this?
ThisIsJ
  • 269
  • 2
  • 4
  • 10
19
votes
4 answers

Open Layers 3 Zoom map event handler

I need to handle a zoom event in Open Layers 3. The following is my code: map_object = new ol.Map({ target: 'map', controls: controls_list, interactions: interactions_list, overlays: [overlay], layers: [OSM_raster, WFS_layer], view:…
Single Entity
  • 2,925
  • 3
  • 37
  • 66
19
votes
3 answers

Openlayers 3: Select a feature programmatically

I am trying to upgrade my system from Openlayers 2 to Openlayers 3 and I have having one particular issue that I cannot seem to figure out. My application has a grid and a map and when a user clicks on the grid I want to select the relevant point on…
AMadmanTriumphs
  • 4,888
  • 3
  • 28
  • 44
17
votes
3 answers

Openlayers 3 center map

I'm sing OpenLayers 3 to display a map. I want to center the map using latLon coordinates. I'm using the quickstart code to begin with. Using this code, I cannot change the center of the map. I think this has something to do with Spherical Mercator…
user936965
16
votes
1 answer

open layers 3 how to draw a polygon programmatically?

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 …
yozawiratama
  • 4,209
  • 12
  • 58
  • 106
16
votes
3 answers

Adding event handler to feature in OpenLayers 3?

I am using the following code to add a feature to a vector layer in OpenLayers 3 (OL3): marker = new ol.Feature({ geometry: new ol.geom.Point([longitude, latitude]), name: "Location Marker" }); markerStyle = new ol.style.Style({ image: new…
ProfNimrod
  • 4,142
  • 2
  • 35
  • 54
1
2 3
99 100