Skip to content

Instantly share code, notes, and snippets.

@sconnelley
Last active August 29, 2015 14:11
Show Gist options
  • Save sconnelley/a5142dd2de7c6734b51d to your computer and use it in GitHub Desktop.
Save sconnelley/a5142dd2de7c6734b51d to your computer and use it in GitHub Desktop.
ImageMapType attribution for maps.stamen.com
// Adds attribution for maps.stamen.com tiles to Google maps
// You will need to add these CSS styles
/*
#stamen-maps-attribution {
font-family: Roboto, Arial, sans-serif;
z-index: 1;
}
#stamen-maps-attribution > div {
background-color: rgb(245, 245, 245);
opacity: 0.7;
}
#stamen-maps-attribution p {
margin: 0;
font-size: 10px;
padding: 0 6px;
}
*/
// I am the attribution function,
// call me after initializing the map
function stamenMapAttribution(map) {
var attributionElm = document.createElement('div');
attributionElm.id = "stamen-maps-attribution";
var controlUI = document.createElement('div');
attributionElm.appendChild(controlUI);
var controlText = document.createElement('p');
controlText.innerHTML = '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>.';
controlUI.appendChild(controlText);
map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(attributionElm);
}
/* ----------------------------------------------------------- */
// EXAMPLE USAGE:
/*
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
// Add attribution
stamenMapAttribution(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment