Skip to content

Commit

Permalink
Merge pull request #33 from keokilee/master
Browse files Browse the repository at this point in the history
Remove unused file and update with new API.
  • Loading branch information
keokilee committed Jul 14, 2015
2 parents 914fef4 + 7c99484 commit bd5d510
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 227 deletions.
203 changes: 0 additions & 203 deletions www/api/incidents.json

This file was deleted.

52 changes: 29 additions & 23 deletions www/js/controllers/home_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@
}

//if the incident coordinates exist, center the map on that point
if(incident.lat !== null || incident.lng !== null){
if (incident.geometry) {
var geometry = incident.geometry;

vm.MapController.map.center = {
lat : incident.lat,
lng : incident.lng,
lat : geometry.latitude,
lng : geometry.longitude,
zoom : zoom_level
};
}
Expand All @@ -107,37 +109,41 @@
* @return {object} marker [marker associated with the location]
*/
vm.MapController.findMarker = function (incident) {
if (!incident.geometry) {
return null;
}

var markers_obj = vm.MapController.map.markers;
var geometry = incident.geometry;

for (var marker in markers_obj) {
if(markers_obj[marker].lat === incident.lat && markers_obj[marker].lng === incident.lng) {
if(markers_obj[marker].lat === geometry.latitude && markers_obj[marker].lng === geometry.longitude) {
return markers_obj[marker];
}
}
}

vm.MapController.updateMarkers = function (incidents) {
vm.MapController.map.markers = {};
var incident_num = 1;
incidents.forEach(function (incident, index, array) {
//html for marker message
var html = "<h5 class='incident_type'>" + incident.type + "</h5>"
+ "<p class='marker_text'>" + incident.date + "</p>"
+ "<p class='marker_text'>" + incident.address + "</p>"
+ "<p class='marker_text'>" + incident.area + "</p>";
// + "<button class='marker_text zoom' ng-click='focusHere(incident)'>Zoom Here</button>";

//set marker location
var marker = {
lat: incident.lat,
lng: incident.lng,
message: html,
}
incidents.forEach(function (incident, index) {
if (incident.geometry) {
var geometry = incident.geometry;

//html for marker message
var html = "<h5 class='incident_type'>" + incident.type + "</h5>"
+ "<p class='marker_text'>" + incident.date + "</p>"
+ "<p class='marker_text'>" + incident.address + "</p>"
+ "<p class='marker_text'>" + incident.area + "</p>";

//set marker location
var marker = {
lat: geometry.latitude,
lng: geometry.longitude,
message: html,
}

//Only add to list of markers if there are coordinates
if(marker.lat !== null || marker.lng !== null){
vm.MapController.map.markers["Incident" + incident_num] = marker;
vm.MapController.map.markers["Incident" + (index + 1)] = marker;
}
incident_num++;
});
}

Expand Down
2 changes: 1 addition & 1 deletion www/js/services/incidents_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

return {
all: function() {
return $http.get('http://api.hitraffic.org/api/incidents/').then(function (response) {
return $http.get('http://api.hitraffic.org/v1/incidents/').then(function (response) {
return prepareDataForDisplay(filterIncidents(response.data));
});
},
Expand Down

0 comments on commit bd5d510

Please sign in to comment.