|
| 1 | +--- |
| 2 | +name: GeoJSON Layers |
| 3 | +plot_url: https://codepen.io/plotly/embed/zYOZVWW/?height=510&theme-id=15263&default-tab=result |
| 4 | +language: plotly_js |
| 5 | +suite: filled-area-on-mapbox |
| 6 | +order: 3 |
| 7 | +sitemap: false |
| 8 | +arrangement: horizontal |
| 9 | +markdown_content: | |
| 10 | + |
| 11 | + This example shows an area below [water layer](https://plot.ly/javascript/reference/#choroplethmapbox-below), and sets geojson object of type feature and geometries of type [MultiPolygon](https://plot.ly/javascript/reference/#choroplethmapbox-geojson). |
| 12 | +--- |
| 13 | +var data = [{ |
| 14 | + type: "scattermapbox", mode: "markers", |
| 15 | + lon: [-73.605], lat: [45.51], |
| 16 | + marker: { size: 20, color: ["cyan"] } |
| 17 | + }]; |
| 18 | + |
| 19 | +var layout = { |
| 20 | + mapbox: { |
| 21 | + style: "dark", |
| 22 | + center: { lon: -73.6, lat: 45.515}, |
| 23 | + zoom: 12, layers: [{ |
| 24 | + source: { |
| 25 | + type: "FeatureCollection", |
| 26 | + features: [{ |
| 27 | + type: "Feature", |
| 28 | + geometry: { |
| 29 | + type: "MultiPolygon", |
| 30 | + coordinates: [[[ |
| 31 | + [-73.606352888, 45.507489991], [-73.606133883, 45.50687600], |
| 32 | + [-73.605905904, 45.506773980], [-73.603533905, 45.505698946], |
| 33 | + [-73.602475870, 45.506856969], [-73.600031904, 45.505696003], |
| 34 | + [-73.599379992, 45.505389066], [-73.599119902, 45.505632008], |
| 35 | + [-73.598896977, 45.505514039], [-73.598783894, 45.505617001], |
| 36 | + [-73.591308727, 45.516246185], [-73.591380782, 45.516280145], |
| 37 | + [-73.596778656, 45.518690062], [-73.602796770, 45.521348046], |
| 38 | + [-73.612239983, 45.525564037], [-73.612422919, 45.525642061], |
| 39 | + [-73.617229085, 45.527751983], [-73.617279234, 45.527774160], |
| 40 | + [-73.617304713, 45.527741334], [-73.617492052, 45.527498362], |
| 41 | + [-73.617533258, 45.527512253], [-73.618074188, 45.526759105], |
| 42 | + [-73.618271651, 45.526500673], [-73.618446320, 45.526287943], |
| 43 | + [-73.618968507, 45.525698560], [-73.619388002, 45.525216750], |
| 44 | + [-73.619532966, 45.525064183], [-73.619686662, 45.524889290], |
| 45 | + [-73.619787038, 45.524770086], [-73.619925742, 45.524584939], |
| 46 | + [-73.619954486, 45.524557690], [-73.620122362, 45.524377961], |
| 47 | + [-73.620201713, 45.524298907], [-73.620775593, 45.523650879] |
| 48 | + ]]] |
| 49 | + } |
| 50 | + }] |
| 51 | + }, |
| 52 | + type: "fill", below: "water", color: "teal" |
| 53 | + }] |
| 54 | + }, |
| 55 | + height: 450, width: 700 |
| 56 | +}; |
| 57 | + |
| 58 | +var config = {mapboxAccessToken: "your access token"}; |
| 59 | + |
| 60 | +Plotly.newPlot("graph", data, layout, config); |
0 commit comments