Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Last active December 17, 2015 04:39
Show Gist options
  • Save wrobstory/5552293 to your computer and use it in GitHub Desktop.
Save wrobstory/5552293 to your computer and use it in GitHub Desktop.
Folium Simple Markers

A terrain map with two markers generated by Folium. Click on the markers for popover information. This map was generated with the following Python code:

#Mt Hood, with Mapbox custom tiles
tileset = r'http://a.tiles.mapbox.com/v3/wrobstory.map-ze418b98/{z}/{x}/{y}.png'
map = folium.Map(location=[45.372, -121.6972], zoom_start=12, 
                 tiles=tileset)
map.simple_marker([45.3288, -121.6625], popup_txt='Mt. Hood Meadows')
map.simple_marker([45.3311, -121.7113], popup_txt='Timberline Lodge')
map.create_map()
import folium
#Standard OSM tiles
tileset = r'http://a.tiles.mapbox.com/v3/wrobstory.map-ze418b98/{z}/{x}/{y}.png'
map = folium.Map(location=[45.372, -121.6972], zoom_start=12,
tiles=tileset)
map.simple_marker([45.3288, -121.6625], popup_txt='Mt. Hood Meadows')
map.simple_marker([45.3311, -121.7113], popup_txt='Timberline Lodge')
map.create_map()
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css" />
<![endif]-->
<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 src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.372, -121.6972], 12);
L.tileLayer('http://a.tiles.mapbox.com/v3/wrobstory.map-ze418b98/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: ''
}).addTo(map);
var marker_1 = L.marker([45.3288, -121.6625]).addTo(map);
marker_1.bindPopup("Mt. Hood Meadows");
var marker_2 = L.marker([45.3311, -121.7113]).addTo(map);
marker_2.bindPopup("Timberline Lodge");
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment