web_maps/dc_potholes/js/index.js
// button functionality - get value from textfield and change layer
button functionality - get value from textfield and change layer
button functionality - get value from textfield and change layer
function change(e) {
group.removeLayer(geojsonlayer);
if (e.target.value == "init") {
 query = querystem;
} else if (e.target.value == "layer1") {
query = querystem + " WHERE serviceorderstatus = 'IN-PROGRESS'";
} else if (e.target.value == "layer2") {
query = querystem + " WHERE serviceorderstatus = 'CLOSED'";
}
console.log("Changed query: " + query);
$.getJSON(query, function(data) {
geojsonlayer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
layer.bindPopup("<b>" + "Address: " + "</b>" + feature.properties.streetaddress + '</b><br>' + "<b>" + "City: " + "</b>" + feature.properties.city + '</b><br>' + "<b>" + "State: " + "</b>" + feature.properties.state + '</b><br>' + "<b>" + "Zip Code: " + "</b>" + feature.properties.zipcode + '</b><br>' + "<b>" + "Coordinates: " + "</b>" + feature.properties.y + "," +feature.properties.x + '</b><br>' + "<b>" + "Service Request ID: " + "</b>" + feature.properties.servicerequestid + '</b><br>' + "<b>" + "Service Order Date: " + "</b>" + feature.properties.serviceorderdate + '</b><br>' + "<b>" + "Service Due Date: " + "</b>" + feature.properties.serviceduedate + '</b><br>' + "<b>" + "Service Status: " + "</b>" + feature.properties.serviceorderstatus + '</b><br>' + "<b>" + "Resolution Date: " + "</b>" + feature.properties.resolutiondate);
},
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
}
}).addTo(group);
});
}
function change ( e ) { group . removeLayer ( geojsonlayer ) ; if ( e . target . value == "init" ) { query = querystem ; } else if ( e . target . value == "layer1" ) { query = querystem + " WHERE serviceorderstatus = 'IN-PROGRESS'" ; } else if ( e . target . value == "layer2" ) { query = querystem + " WHERE serviceorderstatus = 'CLOSED'" ; } console . log ( "Changed query: " + query ) ; $ . getJSON ( query , function ( data ) { geojsonlayer = L . geoJson ( data , { onEachFeature : function ( feature , layer ) { layer . bindPopup ( "<b>" + "Address: " + "</b>" + feature . properties . streetaddress + '</b><br>' + "<b>" + "City: " + "</b>" + feature . properties . city + '</b><br>' + "<b>" + "State: " + "</b>" + feature . properties . state + '</b><br>' + "<b>" + "Zip Code: " + "</b>" + feature . properties . zipcode + '</b><br>' + "<b>" + "Coordinates: " + "</b>" + feature . properties . y + "," + feature . properties . x + '</b><br>' + "<b>" + "Service Request ID: " + "</b>" + feature . properties . servicerequestid + '</b><br>' + "<b>" + "Service Order Date: " + "</b>" + feature . properties . serviceorderdate + '</b><br>' + "<b>" + "Service Due Date: " + "</b>" + feature . properties . serviceduedate + '</b><br>' + "<b>" + "Service Status: " + "</b>" + feature . properties . serviceorderstatus + '</b><br>' + "<b>" + "Resolution Date: " + "</b>" + feature . properties . resolutiondate ) ; } , pointToLayer : function ( feature , latlng ) { return L . circleMarker ( latlng , geojsonMarkerOptions ) ; } } ) . addTo ( group ) ; } ) ; }
button functionality - get value from textfield and change layer
button functionality - get value from textfield and change layer
// updating the layer means deleting the old one and // adding a new one //debugger; // add popup with some info //style the point marker //map.fitBounds(group.getBounds()); // zooms to fit data