Skip to content

Commit c896df7

Browse files
committed
add new scattermap traces
1 parent 6e0ce80 commit c896df7

7 files changed

+67
-41
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Basic Example (Mapbox)
3+
language: plotly_js
4+
suite: scatter-tile-maps
5+
order: 10
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
Earlier examples use traces that render with [Maplibre GL JS](https://maplibre.org/maplibre-gl-js/docs/).
10+
These traces were introduced in Plotly.js 2.35.0 and replace Mapbox-based tile maps,
11+
which are now deprecated. Here's one of the earlier examples using the Mapbox-based `choroplethmapbox` trace
12+
---
13+
14+
var data = [{
15+
type:'scattermapbox',
16+
lat:['45.5017'],
17+
lon:['-73.5673'],
18+
mode:'markers',
19+
marker: {
20+
size:14
21+
},
22+
text:['Montreal']
23+
}]
24+
25+
var layout = {
26+
autosize: true,
27+
hovermode:'closest',
28+
mapbox: {
29+
bearing:0,
30+
center: {
31+
lat:45,
32+
lon:-73
33+
},
34+
pitch:0,
35+
zoom:5
36+
},
37+
}
38+
39+
Plotly.setPlotConfig({
40+
mapboxAccessToken: "your access token"
41+
})
42+
43+
Plotly.newPlot('myDiv', data, layout)

_posts/plotly_js/maps/scattermapbox/2017-08-01-scattermapbox_basic.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
name: Basic Example
33
language: plotly_js
4-
suite: scattermapbox
4+
suite: scatter-tile-maps
55
order: 1
66
sitemap: false
77
arrangement: horizontal
88
---
99

1010
var data = [{
11-
type:'scattermapbox',
11+
type:'scattermap',
1212
lat:['45.5017'],
1313
lon:['-73.5673'],
1414
mode:'markers',
@@ -21,7 +21,7 @@
2121
var layout = {
2222
autosize: true,
2323
hovermode:'closest',
24-
mapbox: {
24+
map: {
2525
bearing:0,
2626
center: {
2727
lat:45,
@@ -32,8 +32,4 @@
3232
},
3333
}
3434

35-
Plotly.setPlotConfig({
36-
mapboxAccessToken: "your access token"
37-
})
38-
3935
Plotly.newPlot('myDiv', data, layout)

_posts/plotly_js/maps/scattermapbox/2017-08-01-scattermapbox_colorscale.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: Adding Colorscale to Mapbox
2+
name: Adding Colorscale to Maps
33
language: plotly_js
4-
suite: scattermapbox
4+
suite: scatter-tile-maps
55
order: 3
66
sitemap: false
77
arrangement: horizontal
@@ -15,7 +15,7 @@
1515
scl = [[0, 'rgb(150,0,90)'],[0.125, 'rgb(0, 0, 200)'],[0.25,'rgb(0, 25, 255)'],[0.375,'rgb(0, 152, 255)'],[0.5,'rgb(44, 255, 150)'],[0.625,'rgb(151, 255, 0)'],[0.75,'rgb(255, 234, 0)'],[0.875,'rgb(255, 111, 0)'],[1,'rgb(255, 0, 0)']];
1616

1717
var data = [{
18-
type: 'scattermapbox',
18+
type: 'scattermap',
1919
mode: 'markers',
2020
text: unpack(rows, 'Globvalue'),
2121
lon: unpack(rows, 'Lon'),
@@ -44,7 +44,7 @@
4444

4545
layout = {
4646
dragmode: 'zoom',
47-
mapbox: {
47+
map: {
4848
center: {
4949
lat: 38.03697222,
5050
lon: -90.70916722
@@ -66,9 +66,5 @@
6666
showlegend: false
6767
};
6868

69-
Plotly.setPlotConfig({
70-
mapboxAccessToken: "your access token"
71-
})
72-
7369
Plotly.newPlot('myDiv', data, layout);
7470
});

_posts/plotly_js/maps/scattermapbox/2017-08-01-scattermapbox_lines.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: Adding Lines to Mapbox
2+
name: Adding Lines to Maps
33
language: plotly_js
4-
suite: scattermapbox
4+
suite: scatter-tile-maps
55
order: 4
66
sitemap: false
77
arrangement: horizontal
@@ -26,7 +26,7 @@
2626
var opacityValue = count[i]/getMaxOfArray(count);
2727

2828
var result = {
29-
type: 'scattermapbox',
29+
type: 'scattermap',
3030
lon: [ startLongitude[i] , endLongitude[i] ],
3131
lat: [ startLat[i] , endLat[i] ],
3232
mode: 'lines',
@@ -42,7 +42,7 @@
4242

4343
layout = {
4444
dragmode: 'zoom',
45-
mapbox: {
45+
map: {
4646
center: {
4747
lat: 38.03697222,
4848
lon: -90.70916722
@@ -66,10 +66,6 @@
6666
showlegend: false
6767
};
6868

69-
Plotly.setPlotConfig({
70-
mapboxAccessToken: "your access token"
71-
})
72-
7369
Plotly.newPlot("myDiv", data, layout, {showLink: false});
7470

7571
});

_posts/plotly_js/maps/scattermapbox/2017-08-01-scattermapbox_multiple.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Multiple Markers
33
language: plotly_js
4-
suite: scattermapbox
4+
suite: scatter-tile-maps
55
order: 2
66
sitemap: false
77
arrangement: horizontal
@@ -21,7 +21,7 @@
2121
return (row.class === classes);
2222
});
2323
return {
24-
type: 'scattermapbox',
24+
type: 'scattermap',
2525
name: classes,
2626
lat: unpack(rowsFiltered, 'reclat'),
2727
lon: unpack(rowsFiltered, 'reclong')
@@ -34,7 +34,7 @@
3434
color: 'white'
3535
},
3636
dragmode: 'zoom',
37-
mapbox: {
37+
map: {
3838
center: {
3939
lat: 38.03697222,
4040
lon: -90.70916722
@@ -66,9 +66,5 @@
6666
}]
6767
};
6868

69-
Plotly.setPlotConfig({
70-
mapboxAccessToken: "your access token"
71-
});
72-
7369
Plotly.newPlot('myDiv', data, layout);
7470
});
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
description: How to make scatter plots on Mapbox maps in Plotly.JS
2+
description: How to make scatter plots on tile maps in Plotly.JS
33
display_as: maps
44
language: plotly_js
55
layout: base
6-
name: Scatter Plots on Mapbox
6+
name: Scatter Plots on Tile Maps
77
order: 7
8-
permalink: javascript/scattermapbox/
8+
permalink: javascript/scatter-tile-maps/
9+
redirect_from: javascript/scattermapbox/
910
thumbnail: thumbnail/scatter-mapbox.jpg
1011
---
1112

12-
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","scattermapbox" | sort: "order" %}
13+
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","scatter-tile-maps" | sort: "order" %}
1314
{% include posts/auto_examples.html examples=examples %}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
name: Set Marker Symbols
33
language: plotly_js
4-
suite: scattermapbox
4+
suite: scatter-tile-maps
55
order: 5
66
sitemap: false
77
arrangement: horizontal
88
markdown_content: |
9-
This example uses [symbol attribute](https://plotly.com/javascript/reference/scattermapbox/#scattermapbox-marker-symbol) to set the marker symbol.
9+
This example uses [symbol attribute](https://plotly.com/javascript/reference/scattermap/#scattermap-marker-symbol) to set the marker symbol.
1010
---
1111
var data = [
1212
{
13-
type: "scattermapbox",
13+
type: "scattermap",
1414
mode: "markers+text+lines",
1515
lon: [-75, -80, -50],
1616
lat: [45, 20, -20],
@@ -21,10 +21,8 @@
2121
];
2222

2323
var layout = {
24-
mapbox: { style: "outdoors", zoom: 0.7 },
24+
map: { style: "outdoors", zoom: 0.7 },
2525
showlegend: false, height: 500, width: 700
2626
};
2727

28-
var config = {mapboxAccessToken: "your access token"};
29-
30-
Plotly.newPlot("myDiv", data, layout, config);
28+
Plotly.newPlot("myDiv", data, layout);

0 commit comments

Comments
 (0)