Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mapbox.style description + use mapbox-gl v1.1.1 #4035

Merged
merged 9 commits into from
Jul 23, 2019

Conversation

etpinard
Copy link
Contributor

@plotly/plotly_js @nicolaskruchten

@antoinerg
Copy link
Contributor

This description is much clearer 👍

@antoinerg
Copy link
Contributor

💃 from me

@etpinard
Copy link
Contributor Author

More from @nicolaskruchten on slack:

what does this line mean? https://github.com/plotly/plotly.js/blob/master/src/plots/mapbox/layout_attributes.js#L141

Is this line up to date wrt to raster and image source types? https://github.com/plotly/plotly.js/blame/master/src/plots/mapbox/layout_attributes.js#L120

would be good to clarify this line if it only applies when sourcetype is geojson: https://github.com/plotly/plotly.js/blob/master/src/plots/mapbox/layout_attributes.js#L143


these will be addressed in this PR.

@etpinard etpinard added this to the v1.49.0 milestone Jul 11, 2019
@nicolaskruchten
Copy link
Contributor

Would be good to point out that this is only needed for certain values of layout.mapbox.style: https://github.com/plotly/plotly.js/blob/master/src/plots/mapbox/layout_attributes.js#L40

@nicolaskruchten
Copy link
Contributor

The relationship between layers.type and layers.sourcetype is pretty nebulous to me at the moment... Would be good to clarify.

@nicolaskruchten
Copy link
Contributor

The attr for choroplethmapbox.below here https://github.com/plotly/plotly.js/blob/master/src/traces/choroplethmapbox/attributes.js#L63 should be expanded a bit to say something like "the default value is 'water', which is the ID of a layer that is often present in Mapbox styles. If no layer with this ID is implicitly or explicitly defined via layout.mapbox.style or explicitly present in layout.mapbox.layers then this trace will be positioned as usual."

... or something. that's basically a clearer description of the current behaviour and assumptions IMO.

@etpinard
Copy link
Contributor Author

The attr for choroplethmapbox.below here https://github.com/plotly/plotly.js/blob/master/src/traces/choroplethmapbox/attributes.js#L63 should be expanded a bit to say something like "the default value is 'water', which is the ID of a layer that is often present in Mapbox styles.

That's not exactly true, here's the logic:

proto.getBelow = function(optsAll) {
if(optsAll.below !== undefined) {
return optsAll.below;
}
var mapLayers = this.subplot.map.getStyle().layers;
var out = '';
// find layer just above top-most "water" layer
for(var i = 0; i < mapLayers.length; i++) {
var layerId = mapLayers[i].id;
if(typeof layerId === 'string') {
var isWaterLayer = layerId.indexOf('water') === 0;
if(out && !isWaterLayer) {
out = layerId;
break;
}
if(isWaterLayer) {
out = layerId;
}
}
}
return out;
};

The default below value is the layer just above the last water* layer. It's unfortunate that mapbox-gl doesn't have an above attribute, it would have been easier to describe.

@etpinard
Copy link
Contributor Author

etpinard commented Jul 18, 2019

Based off this branch's latest commit

https://github.com/plotly/plotly.js/blob/ca762e96d9f8ea77966cfe4918c292e48661f3b0/src/plots/mapbox/layout_attributes.js

here are some TODOs that will done on this branch:

Defines the map layers that are rendered by default below the trace layers defined in `data`, 
which are themselves by default rendered below the layers defined in `layout.mapbox.layers`.

These layers can be defined either explicitly as a Mapbox Style object which can contain multiple 
layer definitions that load data from any public or private Web Map Service (WMS), or implicitly 
by using one of the builtin plotly.js style objects which use WMSes which do not require any 
access tokens, or by using a  default Mapbox style or custom Mapbox style URL, both of 
which require a Mapbox access token.

Mapbox Style objects are of the form described in the Mapbox GL JS documentation available at
https://docs.mapbox.com/mapbox-gl-js/style-spec

The built-in plotly.js styles objects are... (provide name and the tile source)

The built-in Mapbox styles are...

Mapbox style URLs are of the form...

done in b933528

  • mention new non-mapbox-server style shortcuts (once @antoinerg 's work is merged)

done in b933528

  • Clarify relationship between layers.type and layers.sourcetype - done in d81f28c

  • anything else?

@nicolaskruchten
Copy link
Contributor

This is already a big set of improvements, thank you very much :)

One small adjustment to my initial proposal: the phrase public or private Web Map Service (WMS) should be expanded to say public or private Tile Map Service (TMS or XYZ) or Web Map Service (WMS)

@etpinard
Copy link
Contributor Author

@plotly/plotly_js @nicolaskruchten this PR is now reviewable again.

Note that I merged master (with @antoinerg 's attributions and non-mapbox styles work) and I bumped mapbox-gl to v1.1.1 - so this is essentially on-track to be the "last" mapbox PR for 1.49.0 😏

@etpinard etpinard changed the title Improve mapbox.style description Improve mapbox.style description + use mapbox-gl v1.1.1 Jul 22, 2019
@etpinard etpinard added status: reviewable bug something broken labels Jul 22, 2019
@@ -117,7 +137,7 @@ var attrs = module.exports = overrideAll({
'Sets the source data for this layer (mapbox.layer.source).',
'Source can be either a URL,',
'a geojson object (with `sourcetype` set to *geojson*)',
'or an array of tile URLS (with `sourcetype` set to *vector*).'
'or an array of URLs (with `sourcetype` set to *vector* or *raster*).'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does sourcetype have to be if source is a URL?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And actually I would leave the word "tile" in there, as it's not super clear what the URL should point to otherwise. We should try to say what the non-array URL should point to also: an image? a GeoJSON file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is:

'Sets the source data for this layer (mapbox.layer.source).',
'When `sourcetype` is set to *geojson*, `source` can be a URL to a GeoJSON',
'or a GeoJSON object.',
'When `sourcetype` is set to *vector* or *raster*, `source` can be a URL or',
'an array of tile URLs.',
'When `sourcetype` is set to *image*, `source` can be a URL to an image.'

'With `sourcetype` set to *geojson*, *circle*, *line*, *fill* and *symbol* are available',
'but note that *line* and *fill* are not compatible with Point',
'GeoJSON geometries.',
'With `sourcetype` set to *vector*, *circle*, *line*, *fill* and *symbol* are available.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'With `sourcetype` set to *vector*, *circle*, *line*, *fill* and *symbol* are available.',
'With `sourcetype` set to *vector*, the following values are allowed: *circle*, *line*, *fill* and *symbol*.',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is:

'Sets the layer type,',
'that is the how the layer data set in `source` will be rendered',
'With `sourcetype` set to *geojson*, the following values are allowed:',
'*circle*, *line*, *fill* and *symbol*.',
'but note that *line* and *fill* are not compatible with Point',
'GeoJSON geometries.',
'With `sourcetype` set to *vector*, the following values are allowed:',
' *circle*, *line*, *fill* and *symbol*.',
'With `sourcetype` set to *raster* or `*image*`, only the *raster* value is allowed.'

@nicolaskruchten
Copy link
Contributor

💃 thanks very much, this is a huge step up in terms of users' ability to bootstrap their understanding of how to do things :)

@etpinard etpinard merged commit a9e7480 into master Jul 23, 2019
@etpinard etpinard deleted the mapbox-style-better-docs branch July 23, 2019 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants