Skip to content

Commit

Permalink
added new compliance criteria with changed values
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmccann committed Sep 23, 2014
1 parent 9b050bc commit fc1eb72
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 117 deletions.
47 changes: 27 additions & 20 deletions js/veos.js
Expand Up @@ -62,13 +62,20 @@ window.veos = (function(veos) {
// Google Analytics
// self.analytics(ev);

// add all installation markers
// // add all installation markers
var installations = new veos.model.Installations();
installations.on('reset', function(collection) {
veos.map.overviewMap.addInstallationMarkers(collection);
});
installations.fetch({reset:true});

// add nearby installations?
// var installations = new veos.model.NearbyInstallations();
// installations.on('reset', function(collection) {
// veos.map.overviewMap.addInstallationMarkers(collection);
// });
// installations.fetch({reset:true});

// start following user
veos.map.overviewMap.startFollowing();
})
Expand All @@ -78,7 +85,7 @@ window.veos = (function(veos) {
var installationId = 0;
var editReport = false;
var ref = '';

// Google Analytics
// self.analytics(ev);

Expand Down Expand Up @@ -116,9 +123,9 @@ window.veos = (function(veos) {
var installationSuccess = function (model, response) {
self.currentInstallation = model; // used to set initial location for EditReport
self.currentReport = model.startAmending();

self.reportForm = new self.view.ReportEditForm({el: '#report-page', model: self.currentReport});
self.currentReport.on('change', self.reportForm.render, self.reportForm);
self.currentReport.on('change', self.reportForm.render, self.reportForm);

jQuery('#report-header-text').text('Edit the Installation');
};
Expand Down Expand Up @@ -161,13 +168,13 @@ window.veos = (function(veos) {
console.log("Pointing ReportForm to "+ev.target);
self.reportForm.setElement(ev.target);
self.reportForm.$el.data('initialized', true);
}
self.reportForm.render();
}

self.reportForm.render();
}
})


/** refine-location.html (refine-location-page) **/
.delegate("#refine-location-page", "pageshow", function(ev) {
if (!veos.reportForm) {
Expand Down Expand Up @@ -211,13 +218,13 @@ window.veos = (function(veos) {
el: ev.target,
collection: installations
});

view.showLoader();
installations.fetch({
success: function () {view.hideLoader();},
reset:true
});
})
})

/** report-selection.html (report-selection-page) **/
.delegate("#report-selection-page", "pageshow", function(ev) {
Expand All @@ -232,16 +239,16 @@ window.veos = (function(veos) {
el: ev.target,
collection: nearbyInstallations
});

view.showLoader();
nearbyInstallations.fetch({
success: function () {
view.hideLoader();
// could go in the view, but is non-dynamic, and better to do it as early as possible
if (nearbyInstallations.length > 0) {
jQuery('.report-selection-dynamic-text').text("The following installations are within " + MAX_DISTANCE_TO_INST*1000 + "m of your current location. If you see an installation listed here that you wish to revise, select it. Otherwise, choose New Installation.");
jQuery('.report-selection-dynamic-text').text("The following installations are within " + MAX_DISTANCE_TO_INST*1000 + "m of your current location. If you see an installation listed here that you wish to revise, select it. Otherwise, choose New Installation.");
} else {
jQuery('.report-selection-dynamic-text').text("There are no installations within " + MAX_DISTANCE_TO_INST*1000 + "m of your current location. Please choose New Installation.");
jQuery('.report-selection-dynamic-text').text("There are no installations within " + MAX_DISTANCE_TO_INST*1000 + "m of your current location. Please choose New Installation.");
}
}
});
Expand All @@ -262,8 +269,8 @@ window.veos = (function(veos) {
el: ev.target,
model: self.currentInstallation
});
view.showLoader();

view.showLoader();
view.model.fetch();
})

Expand Down Expand Up @@ -293,8 +300,8 @@ window.veos = (function(veos) {
el: photoContainer,
model: photo
});
// view.showLoader();

// view.showLoader();
view.model.fetch();
})

Expand All @@ -310,8 +317,8 @@ window.veos = (function(veos) {
el: ev.target,
model: installation
});
view.showLoader();

view.showLoader();
view.model.fetch();
});

Expand Down Expand Up @@ -339,4 +346,4 @@ window.veos = (function(veos) {
// };

return self;
})(window.veos || {});
})(window.veos || {});
48 changes: 24 additions & 24 deletions js/veos.map.js
Expand Up @@ -43,7 +43,7 @@
zoomControl: true, // changed this back to true - pinch zoom not working on some phones (note ZoomControl must be set to +/- or will not show up on Android 3.0 and later)
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
}
}
};

jQuery(mapDiv).empty(); // empty out the div in case it was previously used to init another map...
Expand All @@ -61,10 +61,10 @@
};

self.Map.prototype = {

};


/**
Shows the current location marker and continuously updates its
position based on incoming GPS data.
Expand All @@ -76,7 +76,7 @@
navigator.geolocation.clearWatch(this.posWatcher);
}


console.log("Started following user...");

map.posWatcher = navigator.geolocation.watchPosition(function (geoloc) {
Expand Down Expand Up @@ -125,22 +125,22 @@
// this would reframe the map to the accuracy circle
//self.gmap.fitBounds(self.currentLocRadius.getBounds());


map.currentLocMarker.setPosition(glatlng);
map.currentLocRadius.setCenter(glatlng);
map.currentLocRadius.setRadius(accuracy);
});
};

/**
/**
Stops updating the current location marker.
**/
self.Map.prototype.stopFollowing = function () {
console.log("Stopped following user...");
navigator.geolocation.clearWatch(this.posWatcher);
};

/**
/**
Removes the current location marker from the map.
**/
self.Map.prototype.clearCurrentLocation = function () {
Expand All @@ -164,7 +164,7 @@
veos.markersArray = [];

map.infowindow = new google.maps.InfoWindow({
// do you seriously need a plugin for styling infowindows?!?! Puke
// do you seriously need a plugin for styling infowindows?!?! Puke
// http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html
// http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries
});
Expand All @@ -179,13 +179,13 @@
if (i.get('compliance_level') === 'compliant') {
compliancePinOn = '/images/pin-green-on.png';
compliancePinOff = '/images/pin-green-off.png';
} else if (i.get('compliance_level') === 'missing_info') {
compliancePinOn = '/images/pin-yellow-on.png';
compliancePinOff = '/images/pin-yellow-off.png';
} else if (i.get('compliance_level') === 'min_compliant') {
compliancePinOn = '/images/pin-yellow-green-on.png';
compliancePinOff = '/images/pin-yellow-green-off.png';
} else if (i.get('compliance_level') === 'no_sign') {
} else if (i.get('compliance_level') === 'low_compliant') {
compliancePinOn = '/images/pin-yellow-on.png';
compliancePinOff = '/images/pin-yellow-off.png';
} else if (i.get('compliance_level') === 'non_compliant') {
compliancePinOn = '/images/pin-red-on.png';
compliancePinOff = '/images/pin-red-off.png';
} else {
Expand Down Expand Up @@ -213,7 +213,7 @@
if (i.has('photos') && i.get('photos').length > 0) {
var photoID = i.get('photos')[0].id;
thumb = "<img class='photo photo-"+photoID+"' />";
}
}

mapPopupContent = "<a class='styled-link-text' href=installation-details.html?id="+i.id+">"+thumb+buttonText+"</a>";

Expand All @@ -229,7 +229,7 @@
google.maps.event.addListener(map.infowindow, 'closeclick', function() {
_.each(veos.markersArray, function(m) {
m.setIcon(m.iconSelected);
});
});
});

marker.setMap(map.gmap);
Expand All @@ -254,7 +254,7 @@
var injectThumbnail = function(installation) {
if (installation.has('photos') && installation.get('photos').length > 0) {
var photoID = installation.get('photos')[0].id;

console.log('Trying to retrieve photo thumb URL for photo with ID: '+photoID);

var thumbPhoto = new veos.model.Photo({id: photoID});
Expand All @@ -281,16 +281,16 @@
});

// set the clicked marker as selected (necessary because the _.each will only catch markers with known owner_names)
marker.setIcon(marker.iconSelected);
marker.setIcon(marker.iconSelected);

var ownerInstallations = new veos.model.Installations();

var ownerSuccess = function (model, response) {
ownerInstallations.each(function(i) {
console.log('related installation ids: ' + i.get('id'));

// this is very inefficient, but working (will ping once for *each* match... lots of duplicate higlights)
// can we use pluck or filter or find here? Or even better, can we count on the fact that all ownerInstallations have the same name?
// can we use pluck or filter or find here? Or even better, can we count on the fact that all ownerInstallations have the same name?
_.each(veos.markersArray, function(m) {
// if the owner_names match
if (m.title === i.get('owner_name')) {
Expand Down Expand Up @@ -357,9 +357,9 @@
self.generateStaticMapURL = function(geoloc) {
var glatlng = veos.map.convertGeolocToGmapLatLng(geoloc);

var url = "https://maps.googleapis.com/maps/api/staticmap?zoom=14&size=200x100&scale=2&sensor=true&center=" +
var url = "https://maps.googleapis.com/maps/api/staticmap?zoom=14&size=200x100&scale=2&sensor=true&center=" +
glatlng.lat() + "," + glatlng.lng();

// add the current location as red pin to the map
url += "&markers=color:blue%7C" + glatlng.lat() + "," + glatlng.lng();

Expand All @@ -372,7 +372,7 @@
console.log("Looking up address for ", geoloc);
var geocoder = new google.maps.Geocoder();
var glatlng = veos.map.convertGeolocToGmapLatLng(geoloc);

geocoder.geocode({'latLng': glatlng}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[0]) {
Expand All @@ -389,13 +389,13 @@
self.lookupLocForAddress = function(address, successCallback) {
console.log("Looking up loc for address ", address);
var geocoder = new google.maps.Geocoder();

geocoder.geocode({'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();

console.log("Reverse geocoding for address: " + address + " returned this latitute: " + lat + " and longitude: " + lng);
console.log("Reverse geocoding for address: " + address + " returned this latitute: " + lat + " and longitude: " + lng);
successCallback(lat, lng);
} else {
console.error("Geocoder failed due to: " + status);
Expand All @@ -404,4 +404,4 @@
};

veos.map = self;
})(window.veos);
})(window.veos);

0 comments on commit fc1eb72

Please sign in to comment.