Skip to content

Commit

Permalink
Made XYZ tiles attribution required #83
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Jul 12, 2021
1 parent fe3272d commit ad6b0d1
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 82 deletions.
2 changes: 1 addition & 1 deletion docs/notebooks/02_using_basemaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\")\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\", attribution=\"Google\")\n",
"m"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/04_cog_mosaic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"outputs": [],
"source": [
"pre_event_tile = 'https://api.cogeo.xyz/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?'\n",
"m.add_tile_layer(pre_event_tile, name=\"Pre-event\")"
"m.add_tile_layer(pre_event_tile, name=\"Pre-event\", attribution=\"Maxar\")"
]
},
{
Expand All @@ -127,7 +127,7 @@
"outputs": [],
"source": [
"post_event_tile = 'https://api.cogeo.xyz/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?'\n",
"m.add_tile_layer(post_event_tile, name=\"Post-event\")"
"m.add_tile_layer(post_event_tile, name=\"Post-event\", attribution=\"Maxar\")"
]
},
{
Expand Down
165 changes: 145 additions & 20 deletions docs/notebooks/16_heremap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"cells": [
{
"cell_type": "markdown",
"id": "12cfe54d-808e-46ce-9e8a-94091db4aa1b",
"metadata": {},
"source": [
"[![image](https://binder.pangeo.io/badge_logo.svg)](https://gishub.org/leafmap-pangeo)\n",
Expand All @@ -13,7 +12,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5ff7727a-1af7-4a9a-8b2a-47f40e03b06c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,7 +20,6 @@
},
{
"cell_type": "markdown",
"id": "f47e6626-4a32-4409-a445-92fd65c815a6",
"metadata": {},
"source": [
"## Prerequisites\n",
Expand All @@ -39,7 +36,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "451c22f6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -50,7 +46,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "95d0909c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -61,7 +56,6 @@
},
{
"cell_type": "markdown",
"id": "1f06c52a",
"metadata": {},
"source": [
"## HERE default basemap"
Expand All @@ -70,7 +64,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0c5ad5ab",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -81,7 +74,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bb139d74",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -92,7 +84,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "65a0ec08",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -103,7 +94,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3b29edad",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -113,7 +103,6 @@
},
{
"cell_type": "markdown",
"id": "acfbe5de",
"metadata": {},
"source": [
"## Basemaps"
Expand All @@ -122,18 +111,32 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7e809f50",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, basemap=\"HERE_RASTER_TERRAIN_MAP\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### zoom to bounds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m.zoom_to_bounds((-9.0882278, -55.3228175, 168.2249543, 72.2460938)) # South West North East"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ce18955",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -143,18 +146,16 @@
{
"cell_type": "code",
"execution_count": null,
"id": "22eef167",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, layers_control=True)\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\")\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\", attribution=\"Google\")\n",
"m"
]
},
{
"cell_type": "markdown",
"id": "440502a1",
"metadata": {},
"source": [
"## Add vector data\n",
Expand All @@ -164,7 +165,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cf48e92f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -179,7 +179,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "20713602",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -195,7 +194,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7b9e69c9",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -212,9 +210,94 @@
"m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"in_shp = '../data/countries.shp'\n",
"in_geojson = '../data/us-states.json'\n",
"in_kml = '../data/us-states.kml'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"m.add_shp(in_shp, layer_name=\"Shapefile\")\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[40.273502, -86.126976], zoom=4)\n",
"m.add_kml(in_kml, layer_name=\"KML\")\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"url = \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson\"\n",
"m.add_vector(url, layer_name=\"Countries\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Point style for GeoJSON"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"\n",
"url = \"http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.geojson\"\n",
"point_style = {\"strokeColor\": 'white', \"lineWidth\": 1, \"fillColor\": \"red\", \"fillOpacity\": 0.7, \"radius\": 5}\n",
"m.add_geojson(url, layer_name=\"Countries\", point_style=point_style, default_popup=True)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import geopandas\n",
"import json\n",
"import os\n",
"\n",
"countries = geopandas.read_file(geopandas.datasets.get_path(\"naturalearth_cities\"))\n",
"point_style = {\"strokeColor\": 'white', \"lineWidth\": 1, \"fillColor\": \"blue\", \"fillOpacity\": 0.7, \"radius\": 5}\n",
"\n",
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=3)\n",
"m.add_gdf(countries, zoom_to_layer=False, point_style=point_style, default_popup=True)\n",
"m"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -230,7 +313,49 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.8.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
Expand Down
11 changes: 7 additions & 4 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ m

```python
m = leafmap.Map()
m.add_tile_layer(url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", name="Google Satellite")
m.add_tile_layer(url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", name="Google Satellite", attribution="Google")
m
```

Expand All @@ -70,12 +70,15 @@ m
## Use HERE Map Widget for Jupyter plotting backend

### Prerequisites
- A HERE developer account, free and available under [HERE Developer Portal](https://developer.here.com)
- An [API key](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/dev-apikey.html) from the [HERE Developer Portal](https://developer.here.com)
- Export API key into environment variable `HEREMAPS_API_KEY`

- A HERE developer account, free and available under [HERE Developer Portal](https://developer.here.com)
- An [API key](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/dev-apikey.html) from the [HERE Developer Portal](https://developer.here.com)
- Export API key into environment variable `HEREMAPS_API_KEY`

```bash
export HEREMAPS_API_KEY=YOUR-ACTUAL-API-KEY
```

```python
import leafmap.heremap as leafmap
```
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/02_using_basemaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\")\n",
"m.add_tile_layer(url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\", name=\"Google Satellite\", attribution=\"Google\")\n",
"m"
]
},
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/04_cog_mosaic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"outputs": [],
"source": [
"pre_event_tile = 'https://api.cogeo.xyz/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?'\n",
"m.add_tile_layer(pre_event_tile, name=\"Pre-event\")"
"m.add_tile_layer(pre_event_tile, name=\"Pre-event\", attribution=\"Maxar\")"
]
},
{
Expand All @@ -127,7 +127,7 @@
"outputs": [],
"source": [
"post_event_tile = 'https://api.cogeo.xyz/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?'\n",
"m.add_tile_layer(post_event_tile, name=\"Post-event\")"
"m.add_tile_layer(post_event_tile, name=\"Post-event\", attribution=\"Maxar\")"
]
},
{
Expand Down
Loading

0 comments on commit ad6b0d1

Please sign in to comment.