question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapboxVectorLayer does not correctly set additional options

See original GitHub issue

Describe the bug

If I pass an additional property to a MapboxVectorLayer, layer.get(‘customProp’) does not return it.

For example:


    const layer = new MapboxVector({
      type: 'ol/layer/MapboxVector',
      styleUrl: 'mapbox://styles/mapbox/light-v10',
      accessToken: 'xxxx',
      id: 'mapbox-gray',
    });
    
    layer.get('id') // -> undefined

Expected behavior

Most (if not all) other openlayers layer objects allow this. The use case is that I can populate the layer with some additional metadata that lets me find the layer in the future. I think that to ensure consistency in the API the mapbox layer should also allow this.

I am able to contribute a pull request if this is an acceptable solution.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-000commented, Feb 10, 2021

As arbitrary user properties are accessed using getProperties() and setProperties() then in constructors instead of

name: 'My Layer',

it would be more logical to use

properties: {name: 'My Layer'},

In the case of features it would make OpenLayers features more consistent with GeoJSON features and avoid ambiguities in the use of geometry, id and style.

0reactions
stale[bot]commented, Jun 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styles | Mapbox Studio manual
There are several options to add a new layer to your style: Source, Upload data, Add tileset by ID, Convert to background layer,...
Read more >
Recipe specification | Mapbox Tiling Service
A tileset recipe is a JSON document containing configuration options that tell Mapbox Tiling Service (MTS) how to turn tileset source data into...
Read more >
Upload data to Mapbox | Help
To add your data to a dataset, you can create a new, blank dataset through Mapbox Studio or through the Mapbox Datasets API...
Read more >
Properties and options | Mapbox GL JS
Set the map's access token, test whether the browser support Mapbox GL JS, ... These layers can be added between any regular layers...
Read more >
Data-driven styling | Maps SDK v9 | Android - Mapbox docs
Adding a source won't instantly make data appear on the map because sources ... All layers that use a vector source must specify...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found