I have been tasked with adding a feature to an existing application.
At the moment it shows a google map where and a overlay of a specific area using coordinates will be color coded red if there are no codes in the XML HTTP response. Then if there is a value then color it green.
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
stationground = xmlhttp.responseText.split(",");
}
}
xmlhttp.open("GET","stationareas.asp",true);
xmlhttp.send();
console.log(stationground);
}
function areaStatus() {
loadXMLDoc();
map.data.setStyle( function(feature) {
var featurecountry = feature.getProperty('letter');
if (stationground.indexOf(featurecountry) != -1) {
return/** @type {google.maps.Data.StyleOptions} */ {
fillColor: 'red' , fillOpacity: 0.25 };
} else {
return/** @type {google.maps.Data.StyleOptions} */ {
fillColor: 'green' , fillOpacity: 0.25 };
}
console.log(featurecountry);
});
}
The console.log returns a list of items that are listed in the SQL query in stationareas.asp.
Is it possible within the areaStatus()
function to somehow check if the response already exists and if so can we count that to say if there is 3 values of "Apple" then color that section Green. But if there is >5 color that section "Purple".
Hope this makes sense. Any help would be very helpful!
Structure of response:
["C04", "C04", "C09", "C21", "C24", "C26", "C43", "C46", "C46", "C66", "C68", "C21", "C09", "C21", "C21", "C21", "E10", "E11", "E13", "E14", "E20", "E20", "E22", "E26", "G10", "G10", "G10", "G10", "G10", "G10", "G10", "G10", "G23", "G38", "G38", "G60", "G60", "G60", "G10", "G10", "G10", "G60", "L15", "L30", "L30", "L30", "L31", "L32", "L32", "L35", "L55", "L55", "L72", "L95", "L30", "L30", "L55", "L30", ""]