Skip to content

Instantly share code, notes, and snippets.

@eltonsantos
Created March 8, 2018 19:18
Show Gist options
  • Save eltonsantos/cadf6513e47cb78a9756d4802c078461 to your computer and use it in GitHub Desktop.
Save eltonsantos/cadf6513e47cb78a9756d4802c078461 to your computer and use it in GitHub Desktop.
Trying WMS with leaflet
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ==" crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
crossorigin=""></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
#map {
width: 950px;
height: 700px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
var camadaMapa;
var objBasemaps;
var objCamadas;
var stComerciaisLayer;
var quadrasLayer;
var camadasControle;
map = L.map("map", {
center: [-3.794, -38.545],
zoom: 12
});
camadaMapa = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'mapbox.light'
}).addTo(map);
stComerciaisLayer= L.tileLayer.wms("http://172.25.131.53:8080/geoserver/wms/", {
layers: 'IGEO:setor_comercial_geo',
format: 'image/png',
transparent: true,
attribution: "Algum texto de teste"
}).addTo(map);
objBasemaps = {
"Mapa tradicional": camadaMapa
};
objCamadas = {
"Setores Comerciais" : stComerciaisLayer,
"Quadras" : quadrasLayer
};
camadasControle = L.control.layers(objBasemaps, objCamadas).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment