Skip to content

Commit

Permalink
Complete setup My location view
Browse files Browse the repository at this point in the history
  • Loading branch information
malithjkmt committed Jun 15, 2016
1 parent 0fd8925 commit b7dc259
Show file tree
Hide file tree
Showing 21 changed files with 651 additions and 413 deletions.
506 changes: 215 additions & 291 deletions .idea/workspace.xml

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion client/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,18 @@ $font-stack: Helvetica, sans-serif;

.container.pageType{
margin-top: 21px;
}
}

#notiButtons{
margin: 2% 5% 0 5%;
}

#notiButtons button {
width: 100%;
}

#saveLoc{
margin: 2% 5% 0 12%;
width: 75%;
}

10 changes: 5 additions & 5 deletions imports/startup/client/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../../ui/pages/nav.js';

import '../../ui/pages/map/map.js';
import '../../ui/pages/driver/driver.js';
import '../../ui/pages/townsman/registerTownsman.js';
import '../../ui/pages/townsman/setupMyLocation.js';
import '../../ui/pages/truck/truck.js';
import '../../ui/pages/home/home.js';
import '../../ui/pages/feedback/feedback.js';
Expand Down Expand Up @@ -158,13 +158,13 @@ Router.route('/updateDriver/:_id', function () {
});


Router.route('/registerTownsman', function () {
Router.route('/setupMyLocation', function () {
this.layout('myLayout', {
data: function () {
return "Register Townsman";
return "My Location";
}
});
this.render('registerTownsman');
this.render('setupMyLocation');
this.render('nav', {to: 'nav'});
});

Expand Down Expand Up @@ -248,7 +248,7 @@ Router.route('/subscribe', function () {
Router.route('/setupNotifications/:route_id/:user_id', function () {
this.layout('myLayout', {
data: function () {
return "Notifications";
return "Setup Notifications";
}
});
this.render('setupNotifications', {
Expand Down
18 changes: 13 additions & 5 deletions imports/ui/pages/SetupNotifications/setupNotifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
{{saveRoute_id route_id}}
{{saveUser_id user_id}}

<div class="container">
{{>notiMap}}
</div>


{{>notiMap}}


<div class="row" id="notiButtons">
<div class="col s6">
<button id="undo" class="btn waves-effect waves-light " type="click" name="undo">Undo
<i class="material-icons right">assignment_return</i>
</button>

</div>
<div class="col s6">
<button id="save" class="btn waves-effect waves-light" type="click" name="save">Save
<i class="material-icons right">assignment_turned_in</i>
</button>
</div>

</div>

</template>

Expand Down
81 changes: 66 additions & 15 deletions imports/ui/pages/SetupNotifications/setupNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import './setupNotifications.html';
var ZOOM_LEVEL = 15;
var routeID;
var userID;
var notiCircles = [];
var notiPoints = [];


Template.setupNotifications.onCreated(function() {
Meteor.subscribe('notifications');
});

Template.setupNotifications.helpers({
saveRoute_id(id){
routeID = id;
Expand Down Expand Up @@ -57,7 +62,7 @@ Template.notiMap.helpers({
},
});

Template.notiMap.onCreated(function() {
Template.notiMap.onCreated(function () {
this.state = new ReactiveDict();
Meteor.subscribe('routes');

Expand All @@ -67,6 +72,7 @@ Template.notiMap.onCreated(function() {

Template.notiMap.onRendered(()=> {

document.getElementById('undo').disabled = true;

console.log("notiMap created");

Expand All @@ -75,32 +81,45 @@ Template.notiMap.onRendered(()=> {

console.log(" notiMap is ready");

var display = new google.maps.DirectionsRenderer({
//############# draw the route on map: begin
var ren = new google.maps.DirectionsRenderer({
draggable: false,
map: map.instance,
});

var temp = JSON.parse(Routes.findOne({_id: routeID}).mapRoute);
display.setDirections(temp);
var os = JSON.parse(Routes.findOne({_id: routeID}).mapRoute);
ser = new google.maps.DirectionsService();

var wp = [];
for (var i = 0; i < os.waypoints.length; i++)
wp[i] = {'location': new google.maps.LatLng(os.waypoints[i][0], os.waypoints[i][1]), 'stopover': false}

ser.route({
'origin': new google.maps.LatLng(os.start.lat, os.start.lng),
'destination': new google.maps.LatLng(os.end.lat, os.end.lng),
'waypoints': wp,
'travelMode': google.maps.DirectionsTravelMode.DRIVING
}, function (res, sts) {
if (sts == 'OK')ren.setDirections(res);
});

//############# draw the route on map: end

google.maps.event.addListener(map.instance, 'click', function (event) {

google.maps.event.addListener(map.instance, 'click', function(event) {
new google.maps.Marker({
position: new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()),
map: map.instance
});
notiPoints.push({lat:event.latLng.lat() , lng: event.latLng.lng()});
console.log(notiPoints);
notiPoints.push({'lat':event.latLng.lat(), 'lng':event.latLng.lng()});

var cityCircle = new google.maps.Circle({
notiCircles.push(new google.maps.Circle({
strokeColor: '#006699',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#00FFFF',
fillColor: '#66FFFF',
fillOpacity: 0.35,
map: map.instance,
center: new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()),
radius:50
});
radius: 50
}));
document.getElementById('undo').disabled = false;

});

Expand All @@ -109,3 +128,35 @@ Template.notiMap.onRendered(()=> {


});

Template.setupNotifications.events({
'click #undo'(event) {
if (notiCircles.length > 0) {
notiCircles.pop().setMap(null);
if (notiCircles.length == 0) {
document.getElementById('undo').disabled = true;
}

}

if (notiPoints.length > 0) {
notiPoints.pop();
}


},
'click #save'(event) {
//save the notification (notiCircles) to route with user_id
/*
notifications{
{noti:, user_id},
}
*/
console.log(notiPoints);

Meteor.call('saveNoti', JSON.stringify(notiPoints), routeID, userID);
notiPoints = null;
}

});
1 change: 1 addition & 0 deletions imports/ui/pages/addRoute/addRoute.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ <h3>Check your internet connection or turn on Location</h3>
{{> afFieldInput name="TruckNO" options=truckNo type="select" firstOption="(Select a truck)" }}
</div>
{{> afQuickField name="mapRoute" id='routeMap'}}
{{> afQuickField name="active" value=true}}
<div class="col s4">
<button id="addRoutej" type="submit" class="btn waves-effect">Save Route</button>
</div>
Expand Down
3 changes: 1 addition & 2 deletions imports/ui/pages/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ <h5 id="navTitle" style="float: left">
Admin</a></li>
<li id="navRegTruck" class="{{isActiveRoute regex='registerTruck'}}"><a href="{{pathFor 'registerTruck'}}">Register
Truck</a></li>
<li id="navRegTownsman" class="{{isActiveRoute regex='registerTownsman'}}"><a href="{{pathFor 'registerTownsman'}}">Register
Townsman</a></li>
<li id="navMyLocation" class="{{isActiveRoute regex='setupMyLocation'}}"><a href="{{pathFor 'setupMyLocation'}}">My Location</a></li>
<li>{{> atNavButton }}</li>

</ul>
Expand Down
16 changes: 0 additions & 16 deletions imports/ui/pages/setupNotifications/geolocation-marker.js

This file was deleted.

5 changes: 3 additions & 2 deletions imports/ui/pages/subscribe/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Template.routeMap.onRendered(()=> {

console.log("map map" + mapName + " is ready");

//############# draw the route on map: begin
var ren = new google.maps.DirectionsRenderer({
draggable: false,
map: map.instance,
Expand All @@ -132,9 +133,9 @@ Template.routeMap.onRendered(()=> {
}, function (res, sts) {
if (sts == 'OK')ren.setDirections(res);
})
//############# draw the route on map: end


// directionsDisplayArray.push(display);

});


Expand Down
Loading

0 comments on commit b7dc259

Please sign in to comment.