D
D
dr sbtn2016-09-22 19:27:11
JavaScript
dr sbtn, 2016-09-22 19:27:11

How to put a label (a marker on a specific point with coordinates on the map) in OpenLayers 3?

openlayers.org/en/v3.1.1/examples/icon.js I
see this code for this example openlayers.org/en/v3.1.1/examples/icon.html
I don't understand what is responsible for the map marker here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2016-09-23
@freeExec

var iconFeature = new ol.Feature({
  geometry: new ol.geom.Point([0, 0]),
  name: 'Null Island',
  population: 4000,
  rainfall: 500
});

var iconStyle = new ol.style.Style({
  image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
    anchor: [0.5, 46],
    anchorXUnits: 'fraction',
    anchorYUnits: 'pixels',
    opacity: 0.75,
    src: 'data/icon.png'
  }))
});

iconFeature.setStyle(iconStyle);

Well, then we create the initial vector and shove our future there. Then a vector layer from our vector. And at the end we connect our vector layer to the map.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question