-
Hi, I would like to create a simple interactive leafmap on python that I can then export to be used inside gradio (using #364). My javascript website is really simple and it looks like it can be mirrored inside the python wrapper. However, I don't see how I can create interactive events for the moment that are simply constructed in dataset with Is there a way to do so with the python wrapper? My final goal is to be able to give input through a map, see: https://github.com/gradio-app/gradio/discussions/3492 <!DOCTYPE html>
<html lang="en">
<head>
<base target="_top">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
<style>
html, body {
height: 100%;
margin: 0;
}
.leaflet-container {
height: 400px;
width: 600px;
max-width: 100%;
max-height: 100%;
}
</style>
</head>
<body>
<div id="map" style="width: 600px; height: 400px;"></div>
<script>
const map = L.map('map').setView([51.505, -0.09], 13);
const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var coords = null;
var circle = null;
var circle_size = 20;
function onMapClick(e){
if (circle) {
map.removeLayer(circle);
}
coords = e.latlng;
circle = L.circle(e.latlng, {color: 'red', fillColor: '#f03', fillOpacity: 0.5, radius: circle_size}).addTo(map);
}
function updateMap(circle_size_new){
if (circle_size_new != circle_size) {
map.removeLayer(circle);
circle_size_new = circle_size
circle = L.circle(coords, {color: 'red', fillColor: '#f03', fillOpacity: 0.5, radius: circle_size}).addTo(map);
}
}
map.on('click', onMapClick);
</script>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I don't think gradio supports bidirectional community with mapping libraries yet. If you use streamlit, you can try out streamlit-folium. |
Beta Was this translation helpful? Give feedback.
I don't think gradio supports bidirectional community with mapping libraries yet.
If you use streamlit, you can try out streamlit-folium.