Features not displayed with style_function
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 38/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- jupyter-notebook, python
- Domaine
- data-visualization
Piste de recherche
Commencez par exécuter la reproduction GeoJSON de l’issue dans Jupyter Notebook avec et sans style_function, en utilisant les données demo.json jointes. Suivez le chemin de style de Folium GeoJson et vérifiez l’achèvement lorsque les features LineString sont rendues avec la couleur, l’épaisseur, l’opacité et le dashArray demandés.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
When loading a set of GeoJSON LineString features, they are not displayed on the Folium map in my Jupyter Notebook (GColab, as well) when using style_function. If style_function=style_functions is removed from the following code, the features are displayed correctly, even though without styling.
To Reproduce
import folium
import json
# Load the GeoJSON file
with open('demo.json') as f:
data = json.load(f)
# Create a Folium map centered on a location of your choice
m = folium.Map(location=[37.982759260869564, 23.901986296376812], zoom_start=18)
# Define a style function that changes the color of LineString features
def style_functions(feature):
color = 'red' # Change the color to your desired color or use a custom logic
return {
'color': 'blue',
'weight': 3,
'opacity': 0.7,
'dashArray': [5, 10]
}
# Add the GeoJSON data to the map with the style function applied
folium.GeoJson(data, style_function=style_functions).add_to(m)
# Display the map
m
Demo GeoJSON has been attached. Please remove the .txt extension for it to load.
demo.json.txt
Expected behavior
style_function should not hide the features, but display them with the styling specified.
Environment (please complete the following information):
- Browser [e.g. firefox]
- Jupyter Lab & Google Colab
- Python 3.10.12
- folium 0.14.0
- branca 0.6.0
Additional context
In a similar test, PointString features were correctly displayed, with or without the style_function argument.
- Langage dominant
- Python
- Étoiles
- 7.4k
- Forks
- 2.3k
- Merge moyen
- 17 h 22 min
- PR mergées (30 j)
- 11
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-visualization/folium
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
python-visualization/folium#2092 · 5 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 67/100
python-visualization/folium#2278 · 1 commentaire ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
python-visualization/folium#2259 ·
-
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
python-visualization/folium#2236 · 5 commentaires · 1 réaction ·
-
Touch Screen often fails Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
python-visualization/folium#2219 · 2 commentaires ·
Toutes les issues de python-visualization/folium
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
huggingface/Repo2RLEnv#163 · 1 commentaire ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
NousResearch/hermes-agent#121143 ·