map.pug 2.29 KB
extends layout
block content
    script.
        function relocate_home()
        {
        location.href = "/map/" + nome.value;
        }
    #map
    script(type='text/javascript').
        var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            southWest = L.latLng(#{bndSW}),
            northEast = L.latLng(#{bndNE}),
            bounds = L.latLngBounds(southWest, northEast),
            osmAttrib = '',
            osm = L.tileLayer(osmUrl,  
                {attribution: osmAttrib}),
            map = L.map('map', {
                center: new L.LatLng(#{lat},#{lng}),
                zoom: #{fator_zoom}, 
                maxBounds: bounds
            });

            map.attributionControl.setPrefix('');
            wmsLayer= L.tileLayer.wms("#{geoserverWMS}", {
                layers: "#{waterLayers}",
                format: 'image/png',
                transparent: true,
                maxZoom: 23
                }),
            drawnItems = L.featureGroup().addTo(map);
        
        // places the logomark
        L.Control.Watermark = L.Control.extend({
            onAdd: function(map) {
                var img = L.DomUtil.create('img');
                //- img.src = "http://www.saesascs.sp.gov.br/wp-content/themes/portaldae/img/logo-saesa.png";
                img.src = 'https://nexusbr.com/images/logo.png';
                img.style.width = '130px';
                return img;
            },
            onRemove: function(map) {
                // Nothing to do here
            }
        });
        L.control.watermark = function(opts) {
            return new L.Control.Watermark(opts);
        }
        L.control.watermark({ position: 'bottomright' }).addTo(map);
        
        // places the layer control to on and off
        L.control.layers({
            "OSM": osm.addTo(map),
            "Google": L.tileLayer('http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', {
                attribution: 'google'
                })
            }, 
            {'Redes': wmsLayer, 'Ocorrências': drawnItems}, 
            { position: 'topright', collapsed: false }
            ).addTo(map);

        // places the marker that was found
        var marker = L.marker([#{lat},#{lng}]).addTo(map);
        marker.bindPopup("<b>#{codigo}</b><br>#{consumidor}").openPopup();