are clipping options from leaflet implemented in folium?
See original GitHub issueI’m completely new to folium
and leaflet
as of today, so maybe this is a silly question. I am plotting a LineString
(though Polygon
has the same behavior) on map and I noticed that I get visual artifacts when I scroll the map such that the perimeter is off the viewable area.
From googling around, I think it sounds and looks pretty much like this issue.
Edit 10/22: fixed a wrong variable name Here’s a simple version to illustrate:
import folium
lat, lon = (44, -93)
m = folium.Map(location=(lat, lon),
zoom_start=12)
## used to be in the variable `box`; fixed as noted above
coords = [[-93.2, 43.8], [-92.8, 43.8], [-92.8, 44.2], [-93.2, 44.2]]
line = {'type': 'Feature',
'geometry': {'type': 'LineString',
'coordinates': coords }
}
folium.GeoJson(line, name='line',
style_function=lambda x: {'color': '#999999',
'fill': '#999999',
'opacity': 0.8,
'fillOpacity': 0.5}).add_to(m)
m
This is what I get on Chromium 62.0.3202.62
and Firefox 56.0.1
:
Is this an instance of the clipping documented on the leaflet
issue? If so, is there a way to get at CLIP_PADDING
or padding
as referenced over there?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Folium 0.12.1 documentation
**kwargs – These values will map directly to the Leaflet Options. More info available here: ... no_clip (Bool, default False) – Disable polyline...
Read more >How to select a polygon and use it as a clipping mask for other ...
I want the user to select a polygon (one of the local authorities) and then turn on other layers. I want these layers...
Read more >Inserting an URL link in marker's popup in Folium
I want to insert a live url link into my marker's popup in Python Folium but I don't know what class and code...
Read more >TUTO: Draw nice maps with folium - Kaggle
Markers are probably the most basic way to indicate some point of interest on a folium map. We will illustrate it with a...
Read more >Displaying a gridded dataset on a web-based map
There are many options, but Dash-Leaflet is one of the best. It's a Python implementation of the popular LeafletJS mapping library and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Bah. Well, as is not that surprising (as it happens to me often), in the process of clarifying my thoughts for an issue at leaflet, I had a sudden burst of insight: what if the issue is the fact that I defined a
LineString
and then said to give it afill
?Reviewing some documentation I’d run into when starting to play with
folium
, I found this on that geometry:Huh. Well that’s interesting. Only one way to find out how this plays out in
folium/leaflet
and that was to specify'type': 'Polygon'
instead, which I also learned requires one more level of list nesting. With the original example above, I just changed it to this:It worked! I don’t get that triangle artifact with this method. Pretty sure it’s a fluke that you can specify a
fill
for a line, but perhaps that’s an abuse of the shape’s intent and it just doesn’t handle it well?Mystery solved, programmer’s angst resolved, thorn in brain removed… I can now sleep well tonight, and thanks once again for the assistance/patience! Hopefully this trail of breadcrumbs helps someone down the road.
Figured it out. 0.5.0 release is dated 2017-09-13; looks like
vector_layers
were created or refactored on 2017-09-17. I installed fromgit
and now I can use this.My real shape is a complex polygon and I still show clipping/glitching with
GeoJson
, butvector_layers.Polygon
is working great. Thanks!