text over of a map

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

text over of a map

I hope anybody will help a dummy to solve the problem. I want to place
two texts at different positions over a map.
I took an API-example and tried to simplify it for my task. The above
script works, but it places BOTH texts at BOTH positions.
Which is the misunderstanding? Can I find everywhere more explanations
than in the API-docs and exmaples?
Which is the easiest solution for the following script?

<!DOCTYPE html>
<title>Clustering example</title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet"
<link rel="stylesheet"
    <div id="map" class="map"></div>

var features = new Array(2);
features[0] = new ol.Feature(new ol.geom.Point([4000000, 4000000]));
features[1] = new ol.Feature(new ol.geom.Point([6000000, 2000000]));

var styles = new Array();
styles[0] = new ol.style.Style({
        text: new ol.style.Text({
                text: 'hello world!',
                fill: new ol.style.Fill({
                        color: '#fff'

styles[1] = new ol.style.Style({
        text: new ol.style.Text({
                text: 'hello new world!',
                fill: new ol.style.Fill({
                        color: '#fff'

var clusters = new ol.layer.Vector({
                source: new ol.source.Vector({
                        features: features,
  style: styles,

var raster = new ol.layer.Tile({
                  source: new ol.source.MapQuest({
                        layer: 'sat'

var map = new ol.Map({
  layers: [raster, clusters],
  target: 'map',
  view: new ol.View({ center: [0, 0], zoom: 2 })


Users mailing list
[hidden email]