Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Last active Mar 20, 2017
Embed
What would you like to do?
Using WMS in maps

Using WMS in web maps.

<!DOCTYPE html>
<meta charset='utf-8'>
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
<style>
#map {
height: 500px;
width: 1000px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js"></script>
<script>
// Create a Leaflet map and center it
var map = L.map('map').setView([37.3382, -121.8863], 10);
// Add an CARTO basemap
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
// Add WMS layer - railways
L.tileLayer.wms('https://geowebservices.stanford.edu/geoserver/wms', {
// specify layers
layers: 'druid:cf342kq2270',
// specify the format & transparency
format: 'image/png',
transparent: true
}).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment