Interactive Map
This commit is contained in:
parent
14ddbf0ce4
commit
ae0eecbea0
26
apis/interactive_maps.py
Normal file
26
apis/interactive_maps.py
Normal file
@ -0,0 +1,26 @@
|
||||
import folium
|
||||
from folium import plugins
|
||||
import json
|
||||
|
||||
#OpenStreetMap
|
||||
m = folium.Map(location=[46.8132, 8.2242], tiles='CartoDB', zoom_start=7.6, min_zoom = 6, max_zoom = 12)
|
||||
|
||||
|
||||
# Hard coded location list
|
||||
location_list = [('Center of Switzerland' , [46.8132, 8.2242]), ('Zermatt', [46.11654, 7.445683])]
|
||||
|
||||
for place, coordinates in location_list:
|
||||
folium.Marker(
|
||||
location=coordinates, # coordinates for the marker
|
||||
popup=place, # pop-up label for the marker
|
||||
icon=folium.Icon(color="red")#, icon_color = 'red', icon="fa-map-marker-alt", prefix='fa')
|
||||
).add_to(m)
|
||||
|
||||
|
||||
m.save('foliummap.html')
|
||||
|
||||
html_string = m.get_root().render()
|
||||
print(html_string)
|
||||
print('finish')
|
||||
|
||||
return html_string
|
30
apis/sbb.py
30
apis/sbb.py
@ -1,5 +1,6 @@
|
||||
import tortilla
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class SBBWrapper:
|
||||
@ -25,7 +26,30 @@ class SBBWrapper:
|
||||
# 'X-Conversation-Id': str(conv_id),
|
||||
}
|
||||
return auth
|
||||
|
||||
"""
|
||||
sbb=SBBWrapper()
|
||||
print(sbb.wrapper.get('name':'Bern'))
|
||||
"""
|
||||
|
||||
def get_closest_station(self, station_name):
|
||||
pass
|
||||
"""
|
||||
header_dict = {'api_key' : '814d86a3ffc49c350bb7dcc48cac69b3'}
|
||||
|
||||
response = requests.get('https://journey-maps.api.sbb.ch:443', headers=header_dict)
|
||||
print(response.text)
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
header_dict = {'api_key' : 'xxxxx'}
|
||||
response = requests.get('https://journey-pois-int.api.sbb.ch/', headers=header_dict)
|
||||
print(response)
|
||||
|
||||
"""
|
||||
""""
|
||||
|
||||
header_dict = {'key':'yourtest-outdoora-ctiveapi',
|
||||
'project' : 'api-dev-oa' }
|
||||
response = requests.get('http://www.outdooractive.com/api', headers=header_dict).json()
|
||||
print(response)
|
||||
print('finish')
|
||||
"""
|
@ -0,0 +1,28 @@
|
||||
import tortilla
|
||||
import requests
|
||||
|
||||
class WeatherWrapper:
|
||||
def __init__(self) -> None:
|
||||
self.wrapper = tortilla.wrap('https://weather.api.sbb.ch/')
|
||||
self.wrapper.config.headers = self.get_auth()
|
||||
|
||||
def get_auth(self):
|
||||
token_query = {
|
||||
'grant_type': 'client_credentials',
|
||||
'client_id': '56bae62c',
|
||||
'client_secret': '59603134536c874e47245b4de403e3d3'
|
||||
}
|
||||
|
||||
#response = requests.post('https://sso-int.sbb.ch/auth/realms/SBB_Public/protocol/openid-connect/token', data=token_query).json()
|
||||
response = requests.post('https://sso.sbb.ch/auth/realms/SBB_Public/protocol/openid-connect/token', data=token_query).json()
|
||||
token = response["access_token"]
|
||||
auth = {
|
||||
'Authorization': f"Bearer {token}",
|
||||
'X-Contract-Id': 'PLY223P',
|
||||
# 'X-Conversation-Id': str(conv_id),
|
||||
}
|
||||
return auth
|
||||
|
||||
weather = WeatherWrapper()
|
||||
print('TEST')
|
||||
print(weather.wrapper.get('2021-07-12T00:00ZP50D:PT30M/sfc_pressure:hPa,msl_pressure:hPa/47.36669,8.54858+47.35209,7.90779/json'))
|
113
foliummap.html
Normal file
113
foliummap.html
Normal file
@ -0,0 +1,113 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<script>
|
||||
L_NO_TOUCH = false;
|
||||
L_DISABLE_3D = false;
|
||||
</script>
|
||||
|
||||
<style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
|
||||
<style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css"/>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>
|
||||
|
||||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<style>
|
||||
#map_d4ac73c2df9c41bea14c016835811cc9 {
|
||||
position: relative;
|
||||
width: 100.0%;
|
||||
height: 100.0%;
|
||||
left: 0.0%;
|
||||
top: 0.0%;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="folium-map" id="map_d4ac73c2df9c41bea14c016835811cc9" ></div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
|
||||
var map_d4ac73c2df9c41bea14c016835811cc9 = L.map(
|
||||
"map_d4ac73c2df9c41bea14c016835811cc9",
|
||||
{
|
||||
center: [46.8132, 8.2242],
|
||||
crs: L.CRS.EPSG3857,
|
||||
zoom: 7.6,
|
||||
zoomControl: true,
|
||||
preferCanvas: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var tile_layer_6e44d0eabedd40aeb144e24806bc8cda = L.tileLayer(
|
||||
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{"attribution": "Data by \u0026copy; \u003ca href=\"http://openstreetmap.org\"\u003eOpenStreetMap\u003c/a\u003e, under \u003ca href=\"http://www.openstreetmap.org/copyright\"\u003eODbL\u003c/a\u003e.", "detectRetina": false, "maxNativeZoom": 12, "maxZoom": 12, "minZoom": 6, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||
).addTo(map_d4ac73c2df9c41bea14c016835811cc9);
|
||||
|
||||
|
||||
var marker_bf25bd7f39b44ac5b551564b8a5b7c27 = L.marker(
|
||||
[46.8132, 8.2242],
|
||||
{}
|
||||
).addTo(map_d4ac73c2df9c41bea14c016835811cc9);
|
||||
|
||||
|
||||
var icon_7de26889b7ff4e619d6c67754637c7a1 = L.AwesomeMarkers.icon(
|
||||
{"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"}
|
||||
);
|
||||
marker_bf25bd7f39b44ac5b551564b8a5b7c27.setIcon(icon_7de26889b7ff4e619d6c67754637c7a1);
|
||||
|
||||
|
||||
var popup_68bd288fe9ff4339a145fa1ad4225693 = L.popup({"maxWidth": "100%"});
|
||||
|
||||
|
||||
var html_0cdcd383f2d74fb89cdb0e817d289dcd = $(`<div id="html_0cdcd383f2d74fb89cdb0e817d289dcd" style="width: 100.0%; height: 100.0%;">Center of Switzerland</div>`)[0];
|
||||
popup_68bd288fe9ff4339a145fa1ad4225693.setContent(html_0cdcd383f2d74fb89cdb0e817d289dcd);
|
||||
|
||||
|
||||
marker_bf25bd7f39b44ac5b551564b8a5b7c27.bindPopup(popup_68bd288fe9ff4339a145fa1ad4225693)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
var marker_d1bccc00b9f240739ed8cd81a499af5e = L.marker(
|
||||
[46.11654, 7.445683],
|
||||
{}
|
||||
).addTo(map_d4ac73c2df9c41bea14c016835811cc9);
|
||||
|
||||
|
||||
var icon_48e2aecfade240b58c286204bca3b48a = L.AwesomeMarkers.icon(
|
||||
{"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"}
|
||||
);
|
||||
marker_d1bccc00b9f240739ed8cd81a499af5e.setIcon(icon_48e2aecfade240b58c286204bca3b48a);
|
||||
|
||||
|
||||
var popup_b5014cc24e6f422caebfa8d714b48ebd = L.popup({"maxWidth": "100%"});
|
||||
|
||||
|
||||
var html_97e6624386104c2a8799f2e441e63714 = $(`<div id="html_97e6624386104c2a8799f2e441e63714" style="width: 100.0%; height: 100.0%;">Zermatt</div>`)[0];
|
||||
popup_b5014cc24e6f422caebfa8d714b48ebd.setContent(html_97e6624386104c2a8799f2e441e63714);
|
||||
|
||||
|
||||
marker_d1bccc00b9f240739ed8cd81a499af5e.bindPopup(popup_b5014cc24e6f422caebfa8d714b48ebd)
|
||||
;
|
||||
|
||||
|
||||
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user