-4

I want to change the text of a place on OpenLayers map, it needs to be changed from Persian Gulf to Arabian Gulf

I tried to see if there is any way I can make this change using the OpenLayers API documentation and found no luck.

https://openlayers.org/en/latest/apidoc/

Following is the map location

enter image description here

Following is code :

import TileLayer from 'ol/layer/Tile';
import VectorLayer from 'ol/layer/Vector';

....


vectorSource = new VectorSource({
    // url: '/assets/data/countries.geojson',
    url: '/assets/data/countries.json',
    format: new GeoJSON()
  });
  

  mapLayer = new VectorLayer({
    source: this.vectorSource,
    declutter: true
  });

 
  markerLayer = new VectorLayer({
    source: new VectorSource({}),
    style: this.mapStyle
  });

  linesLayer = new VectorLayer({
    source: new VectorSource({}),
    style: this.lineStyle
  });
....

Is there any way to change this? I am still going through the OpenLayers API to find if there is anyway.

Praveen Rao Chavan.G
  • 2,772
  • 3
  • 22
  • 33

2 Answers2

2

You cannot change labels on a TileLayer with the OpenLayers API, because the map image is provided as png images that OpenLayers renders as it receives them.

If your layer were a VectorTileLayer, you'd have access to the feature attributes, and could modify their values.

If you continue using a TileLayer with data from Mapbox, as you currently do, you could create a custom style using Mapbox Studio, where you could change labels as part of the style.

ahocevar
  • 5,448
  • 15
  • 29
0

I got the solution for this, this can be achieved by editing the map style in https://www.mapbox.com/mapbox-studio/ ( MapBox Studio ), OpenLayers has nothing to do with the content of your map.

I created a custom style and integrated the URL into our app, then everything was just fine.

Praveen Rao Chavan.G
  • 2,772
  • 3
  • 22
  • 33