Open MahmoudArafaaat opened 2 months ago
Do you have a code example?
this is html of the map with the plugin : https://jsfiddle.net/kvsgt9hu/
this one i reformed of the link
<!DOCTYPE html>
def initialize_map(self):
m = folium.Map(location=[30.0444, 31.2357], zoom_start=8)
folium.TileLayer(
tiles='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
attr='Esri',
name='Esri Satellite',
overlay=False,
control=True
).add_to(m)
m.get_root().header.add_child(folium.CssLink("https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"))
m.get_root().header.add_child(folium.CssLink("https://cdn.rawgit.com/gokertanrisever/leaflet-ruler/master/src/leaflet-
ruler.css"))
m.get_root().html.add_child(folium.JavascriptLink("https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"))
m.get_root().html.add_child(folium.JavascriptLink("https://cdn.rawgit.com/gokertanrisever/leaflet-ruler/master/src/leaflet-
ruler.js"))
my_js = '''
L.control.ruler().addTo(map);
'''
m.get_root().script.add_child(folium.Element(my_js))
# Save map data to data object
data = io.BytesIO()
m.save(data, close_file=False)
html_content = data.getvalue().decode()
self.map_view.setHtml(html_content)
this is my try in folium to add the plugin
Best to create new plugin
class yourself. In the Folium plugins
directory you can find examples. A few simple plugins that you could easily follow and customize are the fullscreen
and locate_control
.
thanks for guiding me , it was easier to add the plugin to my folium library than adding it directly to my code ruler.txt
Great! If you are open to it, you can share the plugin back to Folium.
I've already linked the code to this txt file and edited the init.py inside plugins folder https://github.com/user-attachments/files/16920265/ruler.txt
If you want could you make it into a pull request on GitHub? It will be easier for the maintainers to include it. For details see: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
i used all possible functions to add leaflet ruler plugin but it gives me errors like : js: Uncaught ReferenceError: map is not defined
Add Leaflet-Ruler plugin
i got all links from here: https://github.com/gokertanrisever/leaflet-ruler