1
+ {
2
+ "metadata" : {
3
+ "name" : " " ,
4
+ "signature" : " sha256:dc08dcf599a6125d21802a4b1c8fe771a27c265b89aee5fe9fff72c4074e21db"
5
+ },
6
+ "nbformat" : 3 ,
7
+ "nbformat_minor" : 0 ,
8
+ "worksheets" : [
9
+ {
10
+ "cells" : [
11
+ {
12
+ "cell_type" : " code" ,
13
+ "collapsed" : false ,
14
+ "input" : [
15
+ " from IPython.display import HTML\n " ,
16
+ " import folium"
17
+ ],
18
+ "language" : " python" ,
19
+ "metadata" : {},
20
+ "outputs" : [],
21
+ "prompt_number" : 1
22
+ },
23
+ {
24
+ "cell_type" : " code" ,
25
+ "collapsed" : false ,
26
+ "input" : [
27
+ " def inline_map(map):\n " ,
28
+ " \"\"\"\n " ,
29
+ " Embeds the HTML source of the map directly into the IPython notebook.\n " ,
30
+ " \n " ,
31
+ " This method will not work if the map depends on any files (json data). Also this uses\n " ,
32
+ " the HTML5 srcdoc attribute, which may not be supported in all browsers.\n " ,
33
+ " \"\"\"\n " ,
34
+ " map._build_map()\n " ,
35
+ " return HTML('<iframe srcdoc=\" {srcdoc}\" style=\" width: 100%; height: 510px; border: none\" ></iframe>'.format(srcdoc=map.HTML.replace('\" ', '"')))\n " ,
36
+ " \n " ,
37
+ " def embed_map(map, path=\" map.html\" ):\n " ,
38
+ " \"\"\"\n " ,
39
+ " Embeds a linked iframe to the map into the IPython notebook.\n " ,
40
+ " \n " ,
41
+ " Note: this method will not capture the source of the map into the notebook.\n " ,
42
+ " This method should work for all maps (as long as they use relative urls).\n " ,
43
+ " \"\"\"\n " ,
44
+ " map.create_map(path=path)\n " ,
45
+ " return HTML('<iframe src=\" files/{path}\" style=\" width: 100%; height: 510px; border: none\" ></iframe>'.format(path=path))"
46
+ ],
47
+ "language" : " python" ,
48
+ "metadata" : {},
49
+ "outputs" : [],
50
+ "prompt_number" : 2
51
+ },
52
+ {
53
+ "cell_type" : " code" ,
54
+ "collapsed" : false ,
55
+ "input" : [
56
+ " map = folium.Map(width=800,height=600,location=[44, -73], zoom_start=3)\n " ,
57
+ " \n " ,
58
+ " map.add_wms_layer(wms_name=\" Temperature\" ,\n " ,
59
+ " wms_url=\" http://gis.srh.noaa.gov/arcgis/services/NDFDTemps/MapServer/WMSServer\" ,\n " ,
60
+ " wms_format=\" image/png\" ,\n " ,
61
+ " wms_layers= 16\n " ,
62
+ " )\n " ,
63
+ " \n " ,
64
+ " map.add_tile_layer(tile_name='hfradar 1km',\n " ,
65
+ " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=1')\n " ,
66
+ " map.add_tile_layer(tile_name='hfradar 2km',\n " ,
67
+ " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=2')\n " ,
68
+ " map.add_tile_layer(tile_name='hfradar 6km',\n " ,
69
+ " tile_url='http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=6')\n " ,
70
+ " \n " ,
71
+ " map.add_layers_to_map()"
72
+ ],
73
+ "language" : " python" ,
74
+ "metadata" : {},
75
+ "outputs" : [],
76
+ "prompt_number" : 3
77
+ },
78
+ {
79
+ "cell_type" : " code" ,
80
+ "collapsed" : false ,
81
+ "input" : [
82
+ " inline_map(map) "
83
+ ],
84
+ "language" : " python" ,
85
+ "metadata" : {},
86
+ "outputs" : [
87
+ {
88
+ "html" : [
89
+ " <iframe srcdoc=\" <!DOCTYPE html>\n " ,
90
+ " <head>\n " ,
91
+ " <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n " ,
92
+ " <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />\n " ,
93
+ " <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>\n " ,
94
+ " \n " ,
95
+ " <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>\n " ,
96
+ " \n " ,
97
+ " <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">\n " ,
98
+ " <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">\n " ,
99
+ " <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n " ,
100
+ " \n " ,
101
+ " <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">\n " ,
102
+ " \n " ,
103
+ " <link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">\n " ,
104
+ " <script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>\n " ,
105
+ " \n " ,
106
+ " \n " ,
107
+ " <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css">\n " ,
108
+ " <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css">\n " ,
109
+ " <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js"></script>\n " ,
110
+ " <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"></script>\n " ,
111
+ " \n " ,
112
+ " <link rel="stylesheet" href="http://birdage.github.io/Leaflet.awesome-markers/dist/leaflet.awesome.rotate.css">\n " ,
113
+ " \n " ,
114
+ " \n " ,
115
+ " \n " ,
116
+ " \n " ,
117
+ " \n " ,
118
+ " \n " ,
119
+ " <style>\n " ,
120
+ " \n " ,
121
+ " #map {\n " ,
122
+ " position:absolute;\n " ,
123
+ " top:0;\n " ,
124
+ " bottom:0;\n " ,
125
+ " right:0;\n " ,
126
+ " left:0;\n " ,
127
+ " }\n " ,
128
+ " \n " ,
129
+ " </style>\n " ,
130
+ " </head>\n " ,
131
+ " \n " ,
132
+ " <body>\n " ,
133
+ " \n " ,
134
+ " <div class="folium-map" id="folium_924324a0e0ff4353b8d1bef52a7ed0a5" style="width: 800px; height: 600px"></div>\n " ,
135
+ " \n " ,
136
+ " <script>\n " ,
137
+ " \n " ,
138
+ " \n " ,
139
+ " \n " ,
140
+ " var base_tile = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n " ,
141
+ " maxZoom: 18,\n " ,
142
+ " attribution: 'Map data (c) <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'\n " ,
143
+ " });\n " ,
144
+ " \n " ,
145
+ " var baseLayer = { \n " ,
146
+ " "Base Layer": base_tile\n " ,
147
+ " };\n " ,
148
+ " \n " ,
149
+ " /*\n " ,
150
+ " addition of the wms layers\n " ,
151
+ " */ \n " ,
152
+ " \n " ,
153
+ " \n " ,
154
+ " var Temperature = L.tileLayer.wms('http://gis.srh.noaa.gov/arcgis/services/NDFDTemps/MapServer/WMSServer',{format:'image/png',transparent: true,layers:'16'});\n " ,
155
+ " \n " ,
156
+ " \n " ,
157
+ " /*\n " ,
158
+ " addition of the tile layers\n " ,
159
+ " */\n " ,
160
+ " \n " ,
161
+ " var hfradar_1km = L.tileLayer('http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=1');\n " ,
162
+ " \n " ,
163
+ " var hfradar_2km = L.tileLayer('http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=2');\n " ,
164
+ " \n " ,
165
+ " var hfradar_6km = L.tileLayer('http://hfradar.ndbc.noaa.gov/tilesavg.php?s=10&e=100&x={x}&y={y}&z={z}&t=2014-8-18 14:00:00&rez=6');\n " ,
166
+ " \n " ,
167
+ " \n " ,
168
+ " /*\n " ,
169
+ " list of layers to be added\n " ,
170
+ " */ \n " ,
171
+ " var layer_list = {\n " ,
172
+ " \n " ,
173
+ " "Temperature": Temperature,\n " ,
174
+ " "hfradar_1km": hfradar_1km,\n " ,
175
+ " "hfradar_2km": hfradar_2km,\n " ,
176
+ " "hfradar_6km": hfradar_6km\n " ,
177
+ " \n " ,
178
+ " \n " ,
179
+ " };\n " ,
180
+ " \n " ,
181
+ " /*\n " ,
182
+ " Creates the map and adds the selected layers\n " ,
183
+ " */\n " ,
184
+ " var map = L.map('folium_924324a0e0ff4353b8d1bef52a7ed0a5', {\n " ,
185
+ " center:[44, -73],\n " ,
186
+ " zoom: 3,\n " ,
187
+ " layers: [base_tile]\n " ,
188
+ " });\n " ,
189
+ " \n " ,
190
+ " L.control.layers(baseLayer, layer_list).addTo(map);\n " ,
191
+ " \n " ,
192
+ " //cluster group\n " ,
193
+ " var clusteredmarkers = L.markerClusterGroup();\n " ,
194
+ " //section for adding clustered markers\n " ,
195
+ " \n " ,
196
+ " //add the clustered markers to the group anyway\n " ,
197
+ " map.addLayer(clusteredmarkers);\n " ,
198
+ " \n " ,
199
+ " \n " ,
200
+ " \n " ,
201
+ " \n " ,
202
+ " \n " ,
203
+ " \n " ,
204
+ " \n " ,
205
+ " \n " ,
206
+ " \n " ,
207
+ " \n " ,
208
+ " \n " ,
209
+ " </script>\n " ,
210
+ " \n " ,
211
+ " </body>\" style=\" width: 100%; height: 510px; border: none\" ></iframe>"
212
+ ],
213
+ "metadata" : {},
214
+ "output_type" : " pyout" ,
215
+ "prompt_number" : 4 ,
216
+ "text" : [
217
+ " <IPython.core.display.HTML at 0x11469a090>"
218
+ ]
219
+ }
220
+ ],
221
+ "prompt_number" : 4
222
+ },
223
+ {
224
+ "cell_type" : " code" ,
225
+ "collapsed" : false ,
226
+ "input" : [],
227
+ "language" : " python" ,
228
+ "metadata" : {},
229
+ "outputs" : [],
230
+ "prompt_number" : 4
231
+ }
232
+ ],
233
+ "metadata" : {}
234
+ }
235
+ ]
236
+ }
0 commit comments