p.add_tools(WheelZoomTool(), PanTool()) # add base layer tile_options = {} tile_options['url'] = 'http://tile.stamen.com/toner/{Z}/{X}/{Y}.png' tile_source = WMTSTileSource(**tile_options) p.add_tile(tile_source) # add dynamic data layer # National Land Cover Dataset (http://www.mrlc.gov/nlcd2011.php) service_url = 'http://raster.nationalmap.gov/arcgis/rest/services/LandCover/USGS_EROS_LandCover_NLCD/MapServer/export?' service_url += 'bbox={XMIN},{YMIN},{XMAX},{YMAX}&bboxSR=102100&size={HEIGHT}%2C{WIDTH}&imageSR=102100&format=png32&transparent=true&f=image' image_source_options = {} image_source_options['url'] = service_url image_source = ImageSource(**image_source_options) p.add_dynamic_image(image_source) # create labels layer tile_label_options = {} tile_label_options[ 'url'] = 'http://tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png' tile_label_source = WMTSTileSource(**tile_label_options) p.add_tile(tile_label_source, **dict(render_parents=True)) doc = Document() doc.add(p) if __name__ == "__main__": filename = "dynamic_map.html" with open(filename, "w") as f: f.write(file_html(doc, INLINE, title))
p.add_tools(WheelZoomTool(), PanTool()) # add base layer tile_options = {} tile_options['url'] = 'http://tile.stamen.com/toner/{Z}/{X}/{Y}.png' tile_source = WMTSTileSource(**tile_options) p.add_tile(tile_source) # add dynamic data layer # National Land Cover Dataset (http://www.mrlc.gov/nlcd2011.php) service_url = 'http://raster.nationalmap.gov/arcgis/rest/services/LandCover/USGS_EROS_LandCover_NLCD/MapServer/export?' service_url += 'bbox={XMIN},{YMIN},{XMAX},{YMAX}&bboxSR=102100&size={HEIGHT}%2C{WIDTH}&imageSR=102100&format=png32&transparent=true&f=image' image_source_options = {} image_source_options['url'] = service_url image_source = ImageSource(**image_source_options) p.add_dynamic_image(image_source) # create labels layer tile_label_options = {} tile_label_options['url'] = 'http://tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png' tile_label_source = WMTSTileSource(**tile_label_options) p.add_tile(tile_label_source, **dict(render_parents=True)) doc = Document() doc.add(p) if __name__ == "__main__": filename = "dynamic_map.html" with open(filename, "w") as f: f.write(file_html(doc, INLINE, title)) print("Wrote %s" % filename)