|
17 | 17 | "source": [ |
18 | 18 | "from traitlets import Unicode, Dict\n", |
19 | 19 | "\n", |
| 20 | + "# This is a custom VectorTileLayer subclass, allowing to pass our api key to the url\n", |
20 | 21 | "class CustomVectorTileLayer(VectorTileLayer):\n", |
21 | | - " api_key = Unicode('gCZXZglvRQa6sB2z7JzL1w').tag(sync=True, o=True)\n", |
22 | | - " attribution = Unicode('<a href=\"https://nextzen.com/\">© NextZen</a>, <a href=\"http://www.openstreetmap.org/copyright\">© OpenStreetMap</a> contributors').tag(sync=True, o=True)\n" |
| 22 | + " api_key = Unicode('gCZXZglvRQa6sB2z7JzL1w').tag(sync=True, o=True)" |
23 | 23 | ] |
24 | 24 | }, |
25 | 25 | { |
|
80 | 80 | "aeroway = dict(\n", |
81 | 81 | " weight=1, fillColor=\"#51aeb5\", color=\"#51aeb5\", fillOpacity=0.2, opacity=0.4\n", |
82 | 82 | ")\n", |
| 83 | + "\n", |
83 | 84 | "road = dict(\n", |
84 | 85 | " weight=1, fillColor=\"#f2b648\", color=\"#f2b648\", fillOpacity=0.2, opacity=0.4\n", |
85 | 86 | ")\n", |
| 87 | + "\n", |
86 | 88 | "transit = dict(\n", |
87 | 89 | " weight=0.5, fillColor=\"#f2b648\", color=\"#f2b648\", fillOpacity=0.2, opacity=0.4\n", |
88 | 90 | ")\n", |
| 91 | + "\n", |
89 | 92 | "buildings = dict(\n", |
90 | 93 | " fill=\"true\",\n", |
91 | 94 | " weight=1,\n", |
|
94 | 97 | " fillOpacity=0.2,\n", |
95 | 98 | " opacity=0.4,\n", |
96 | 99 | ")\n", |
| 100 | + "\n", |
97 | 101 | "water_name = dict(\n", |
98 | 102 | " weight=1, fillColor=\"#022c5b\", color=\"#022c5b\", fillOpacity=0.2, opacity=0.4\n", |
99 | 103 | ")\n", |
| 104 | + "\n", |
100 | 105 | "transportation_name = dict(\n", |
101 | 106 | " weight=1, fillColor=\"#bc6b38\", color=\"#bc6b38\", fillOpacity=0.2, opacity=0.4\n", |
102 | 107 | ")\n", |
| 108 | + "\n", |
103 | 109 | "place = dict(\n", |
104 | 110 | " weight=1, fillColor=\"#f20e93\", color=\"#f20e93\", fillOpacity=0.2, opacity=0.4\n", |
105 | 111 | ")\n", |
| 112 | + "\n", |
106 | 113 | "housenumber = dict(\n", |
107 | 114 | " weight=1, fillColor=\"#ef4c8b\", color=\"#ef4c8b\", fillOpacity=0.2, opacity=0.4\n", |
108 | 115 | ")\n", |
| 116 | + "\n", |
109 | 117 | "poi = dict(weight=1, fillColor=\"#3bb50a\", color=\"#3bb50a\", fillOpacity=0.2, opacity=0.4)\n", |
| 118 | + "\n", |
110 | 119 | "earth = dict(\n", |
111 | 120 | " fill=\"true\",\n", |
112 | 121 | " weight=1,\n", |
113 | 122 | " fillColor=\"#c0c0c0\",\n", |
114 | 123 | " color=\"#c0c0c0\",\n", |
115 | 124 | " fillOpacity=0.2,\n", |
116 | 125 | " opacity=0.4,\n", |
117 | | - ")\n" |
| 126 | + ")" |
118 | 127 | ] |
119 | 128 | }, |
120 | 129 | { |
|
124 | 133 | "outputs": [], |
125 | 134 | "source": [ |
126 | 135 | "url = 'https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt?api_key={apiKey}'\n", |
127 | | - "vectorTileLayerStyles=dict(water=water_style,\n", |
128 | | - " waterway=waterway_style,\n", |
129 | | - " admin=admin_style,\n", |
130 | | - " andcover=landcover_style,\n", |
131 | | - " landuse=landuse_style,\n", |
132 | | - " park=park_style,\n", |
133 | | - " boundaries=boundary_style,\n", |
134 | | - " aeroway=aeroway,\n", |
135 | | - " roads=road,\n", |
136 | | - " transit=transit,\n", |
137 | | - " buildings=buildings,\n", |
138 | | - " water_name=water_name,\n", |
139 | | - " transportation_name=transportation_name,\n", |
140 | | - " places=place,\n", |
141 | | - " housenumber=housenumber,\n", |
142 | | - " pois=poi,\n", |
143 | | - " earth=earth,)\n", |
| 136 | + "vector_tile_layer_styles = dict(\n", |
| 137 | + " water=water_style,\n", |
| 138 | + " waterway=waterway_style,\n", |
| 139 | + " admin=admin_style,\n", |
| 140 | + " andcover=landcover_style,\n", |
| 141 | + " landuse=landuse_style,\n", |
| 142 | + " park=park_style,\n", |
| 143 | + " boundaries=boundary_style,\n", |
| 144 | + " aeroway=aeroway,\n", |
| 145 | + " roads=road,\n", |
| 146 | + " transit=transit,\n", |
| 147 | + " buildings=buildings,\n", |
| 148 | + " water_name=water_name,\n", |
| 149 | + " transportation_name=transportation_name,\n", |
| 150 | + " places=place,\n", |
| 151 | + " housenumber=housenumber,\n", |
| 152 | + " pois=poi,\n", |
| 153 | + " earth=earth\n", |
| 154 | + ")\n", |
| 155 | + "\n", |
144 | 156 | "m = Map(center=(52.204793, 360.121558), zoom=9)\n", |
145 | | - "vl = CustomVectorTileLayer(url=url, vector_tile_layer_styles=vectorTileLayerStyles)\n", |
| 157 | + "vl = CustomVectorTileLayer(url=url, vector_tile_layer_styles=vector_tile_layer_styles)\n", |
146 | 158 | "m.add_layer(vl)\n", |
147 | 159 | "m" |
148 | 160 | ] |
|
153 | 165 | "metadata": {}, |
154 | 166 | "outputs": [], |
155 | 167 | "source": [ |
156 | | - "m.zoom=3.58" |
| 168 | + "m.zoom = 3.58" |
157 | 169 | ] |
158 | 170 | }, |
159 | 171 | { |
|
164 | 176 | "source": [ |
165 | 177 | "vl.url = \"https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf\"" |
166 | 178 | ] |
167 | | - }, |
168 | | - { |
169 | | - "cell_type": "code", |
170 | | - "execution_count": null, |
171 | | - "metadata": {}, |
172 | | - "outputs": [], |
173 | | - "source": [ |
174 | | - "m.remove_layer(m.layers[0])" |
175 | | - ] |
176 | 179 | } |
177 | 180 | ], |
178 | 181 | "metadata": { |
|
191 | 194 | "name": "python", |
192 | 195 | "nbconvert_exporter": "python", |
193 | 196 | "pygments_lexer": "ipython3", |
194 | | - "version": "3.7.3" |
| 197 | + "version": "3.8.2" |
195 | 198 | } |
196 | 199 | }, |
197 | 200 | "nbformat": 4, |
|
0 commit comments