Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Last active February 10, 2020 00:57
Show Gist options
  • Save wrobstory/5609718 to your computer and use it in GitHub Desktop.
Save wrobstory/5609718 to your computer and use it in GitHub Desktop.
Folium Simple Markers

A Leaflet.js map created with Folium. This map was generated with the following Python code:

import folium

map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
                   tiles='Stamen Terrain')
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows')
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge')
map_1.create_map(path='mthood.html')
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>
<style>
#map {
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
}
</style>
</head>
<body>
<div id="map" style="width: 960px; height: 500px"></div>
<script>
var map = L.map('map').setView([45.372, -121.6972], 12);
L.tileLayer('http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.jpg', {
maxZoom: 18,
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.'
}).addTo(map);
var marker_1 = L.marker([45.3288, -121.6625]);
marker_1.bindPopup("Mt. Hood Meadows");
map.addLayer(marker_1)
var marker_2 = L.marker([45.3311, -121.7113]);
marker_2.bindPopup("Timberline Lodge");
map.addLayer(marker_2)
</script>
</body>
import folium
#Simple Markers with Stamen Terrain
map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
tiles='Stamen Terrain')
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows')
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge')
map_1.create_map(path='mthood.html')
Copy link

ghost commented Nov 28, 2019

Which folium version using? At latest, there is not a "simple_marker()" function.

@bitcloudx
Copy link

I am having the same issue. Looks like I would have to use a for loop to add markers but I dont want to do that?? Does anyone know what replaced simple_markers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment