Skip to content

Commit

Permalink
Fix CUTR-at-USF#375 - Add start and from links to plan a trip to laye…
Browse files Browse the repository at this point in the history
…rs markers
  • Loading branch information
jmfield2 committed Dec 29, 2016
1 parent 603c982 commit b694a65
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/client/js/otp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function sendfeedback() {
return content;
}

layers_plan_html = "<p>Plan a Trip: <a href='javascript:void(0)' onclick='javascript:webapp.modules[0].layerWidget.setPlannerMarker(\"start\", this)' data-lat=\"{{pos.lat}}\" data-lng=\"{{pos.lng}}\">Start Here</a> | <a href='javascript:void(0)' onclick='javascript:webapp.modules[0].layerWidget.setPlannerMarker(\"end\", this)' data-lat='{{pos.lat}}' data-lng='{{pos.lng}}'>End Here</a></p>";

/* Define layers icons */
L.layersIcon = L.DivIcon.extend({
options: {
Expand Down Expand Up @@ -237,9 +239,9 @@ otp.config = {
],

layersWidget: [
{ name: 'blue_phones', target: '#bluephone', icon: new L.layersIcon({icon: 'mdi mdi-phone', color: 'blue'}), type: 'static', title: 'Blue Light <br/> Emergency Phones', popup: "<b>Use Blue Light Phones to contact Police</b><br><a target='_blank' href='http://www.usf.edu/administrative-services/emergency-management/resources/campus-safety.aspx'>More about campus safety</a>", locations: [[28.0614434,-82.4078041], [28.0555655,-82.4084315], [28.0641975,-82.4185115], [28.0651509,-82.4183224], [28.0652518,-82.4124851], [28.0582386,-82.4225447], [28.0618976,-82.4141717], [28.0615615,-82.4137318], [28.0599592,-82.4069672], [28.0610142,-82.4149218], [28.0591974,-82.4130281], [28.0599166,-82.4078553], [28.0611144,-82.4187288], [28.0630924,-82.4229122], [28.0688995,-82.4130541], [28.0631877,-82.4136464], [28.0632019,-82.4118091], [28.0662717,-82.4191208], [28.0655687,-82.4105538], [28.0641913,-82.4141936], [28.0658575,-82.4130831], [28.0641581,-82.4127264], [28.0652658,-82.4099050], [28.0675588,-82.4256194], [28.0661246,-82.4206762], [28.0660985,-82.4245251], [28.0590405,-82.4201638], [28.0591163,-82.4192972], [28.0582144,-82.4185594], [28.0626681,-82.4144783], [28.0598752,-82.4193438], [28.0628149,-82.4173562], [28.0599651,-82.4176474], [28.0651523,-82.4234651], [28.0603440,-82.4142791], [28.0679737,-82.4155233], [28.0680589,-82.4133400], [28.0663549,-82.4050145], [28.0680589,-82.4053470], [28.0655857,-82.4073694], [28.0666507,-82.4073238], [28.0658389,-82.4087159], [28.0654484,-82.4090968], [28.0665276,-82.4081660], [28.0649845,-82.4113340], [28.0649951,-82.4105895], [28.0669113,-82.4190557], [28.0666677,-82.4197853], [28.0618552,-82.4209247], [28.0678908,-82.4223870], [28.0584771,-82.4084789], [28.0652073,-82.4086336], [28.0661801,-82.4114123], [28.0683646,-82.4098433], [28.0665417,-82.4087582], [28.0665890,-82.4107541], [28.0619428,-82.4029260], [28.0598972,-82.4029098], [28.0668664,-82.4089528], [28.0661730,-82.4098889], [28.0676942,-82.4114296], [28.0685342,-82.4117649], [28.0675338,-82.4091030], [28.0684183,-82.4072753], [28.0600344,-82.4089220], [28.0600490,-82.4100958], [28.0582358,-82.4121799], [28.0591210,-82.4116568], [28.0662335,-82.4029024], [28.0589559,-82.4179827], [28.0596162,-82.4209013], [28.0594457,-82.4185302], [28.0601510,-82.4184505], [28.0630128,-82.4097381], [28.0629156,-82.4104837], [28.0605726,-82.4120424], [28.0610623,-82.4100948], [28.0620187,-82.4113286], [28.0628495,-82.4252844], [28.0567379,-82.4088338], [28.0611240,-82.4071658], [28.0582317,-82.4201016], [28.0617204,-82.4174919], [28.0678858,-82.4176509], [28.0581327,-82.4066318], [28.0626081,-82.4180444], [28.0580570,-82.4029953], [28.0581694,-82.4106393], [28.0583376,-82.4052632], [28.0590952,-82.4174743], [28.0582401,-82.4171404], [28.0591035,-82.4167762]], color: '#10abe9' },
{ name: 'blue_phones', target: '#bluephone', icon: new L.layersIcon({icon: 'mdi mdi-phone', color: 'blue'}), type: 'static', title: 'Blue Light <br/> Emergency Phones', popup: "<b>Use Blue Light Phones to contact Police</b><br><a target='_blank' href='http://www.usf.edu/administrative-services/emergency-management/resources/campus-safety.aspx'>More about campus safety</a> " + layers_plan_html, locations: [[28.0614434,-82.4078041], [28.0555655,-82.4084315], [28.0641975,-82.4185115], [28.0651509,-82.4183224], [28.0652518,-82.4124851], [28.0582386,-82.4225447], [28.0618976,-82.4141717], [28.0615615,-82.4137318], [28.0599592,-82.4069672], [28.0610142,-82.4149218], [28.0591974,-82.4130281], [28.0599166,-82.4078553], [28.0611144,-82.4187288], [28.0630924,-82.4229122], [28.0688995,-82.4130541], [28.0631877,-82.4136464], [28.0632019,-82.4118091], [28.0662717,-82.4191208], [28.0655687,-82.4105538], [28.0641913,-82.4141936], [28.0658575,-82.4130831], [28.0641581,-82.4127264], [28.0652658,-82.4099050], [28.0675588,-82.4256194], [28.0661246,-82.4206762], [28.0660985,-82.4245251], [28.0590405,-82.4201638], [28.0591163,-82.4192972], [28.0582144,-82.4185594], [28.0626681,-82.4144783], [28.0598752,-82.4193438], [28.0628149,-82.4173562], [28.0599651,-82.4176474], [28.0651523,-82.4234651], [28.0603440,-82.4142791], [28.0679737,-82.4155233], [28.0680589,-82.4133400], [28.0663549,-82.4050145], [28.0680589,-82.4053470], [28.0655857,-82.4073694], [28.0666507,-82.4073238], [28.0658389,-82.4087159], [28.0654484,-82.4090968], [28.0665276,-82.4081660], [28.0649845,-82.4113340], [28.0649951,-82.4105895], [28.0669113,-82.4190557], [28.0666677,-82.4197853], [28.0618552,-82.4209247], [28.0678908,-82.4223870], [28.0584771,-82.4084789], [28.0652073,-82.4086336], [28.0661801,-82.4114123], [28.0683646,-82.4098433], [28.0665417,-82.4087582], [28.0665890,-82.4107541], [28.0619428,-82.4029260], [28.0598972,-82.4029098], [28.0668664,-82.4089528], [28.0661730,-82.4098889], [28.0676942,-82.4114296], [28.0685342,-82.4117649], [28.0675338,-82.4091030], [28.0684183,-82.4072753], [28.0600344,-82.4089220], [28.0600490,-82.4100958], [28.0582358,-82.4121799], [28.0591210,-82.4116568], [28.0662335,-82.4029024], [28.0589559,-82.4179827], [28.0596162,-82.4209013], [28.0594457,-82.4185302], [28.0601510,-82.4184505], [28.0630128,-82.4097381], [28.0629156,-82.4104837], [28.0605726,-82.4120424], [28.0610623,-82.4100948], [28.0620187,-82.4113286], [28.0628495,-82.4252844], [28.0567379,-82.4088338], [28.0611240,-82.4071658], [28.0582317,-82.4201016], [28.0617204,-82.4174919], [28.0678858,-82.4176509], [28.0581327,-82.4066318], [28.0626081,-82.4180444], [28.0580570,-82.4029953], [28.0581694,-82.4106393], [28.0583376,-82.4052632], [28.0590952,-82.4174743], [28.0582401,-82.4171404], [28.0591035,-82.4167762]], color: '#10abe9' },

{ name: 'car_share', target: '#carshare', icon: new L.layersIcon({icon: 'mdi mdi-car', color: 'green'}), type: 'static', title: 'Enterprise CarShare', popup: "<a target='_blank' href='https://www.enterprisecarshare.com/us/en/programs/university/usf.html'>Reserve a car</a>", locations: [[28.059951, -82.417575], [28.064287, -82.412130]], color: '#006747' },
{ name: 'car_share', target: '#carshare', icon: new L.layersIcon({icon: 'mdi mdi-car', color: 'green'}), type: 'static', title: 'Enterprise CarShare', popup: "<a target='_blank' href='https://www.enterprisecarshare.com/us/en/programs/university/usf.html'>Reserve a car</a> " + layers_plan_html, locations: [[28.059951, -82.417575], [28.064287, -82.412130]], color: '#006747' },

{ name: 'bike_repair', target: '#bikerepair', icon: new L.layersIcon({icon: 'mdi mdi-wrench', color: 'green'}), type: 'poi', search: 'bicycle_repair_station', popupTemplate: 'bikeRepair-template', color: '#006747', clusterColor: 'green', cluster: true },

Expand Down
3 changes: 2 additions & 1 deletion src/client/js/otp/core/Webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ otp.core.Webapp = otp.Class({
defaultModule = module;
}

this[id] = module;
this.addModule(module);
}
if(!defaultModule) defaultModule = this.modules[0];
Expand Down Expand Up @@ -260,7 +261,7 @@ otp.core.Webapp = otp.Class({
wrapDiv: true,
divId: 'otp-spinner'
}));

// retrieve a saved trip, if applicable
//if(window.location.hash !== "")
// otp.util.DataStorage.retrieve(window.location.hash.replace("#", ""), this.activeModule);
Expand Down
1 change: 1 addition & 0 deletions src/client/js/otp/layers/BikeStationsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ otp.layers.BikeStationsLayer =

name = this_.stations[v].name || this_.stations[v].id;
context = {'name': name, 'station': this_.stations[v], 'reserve_link': link};
context['pos'] = coord;

if (is_hub)
var bikePopup = ich['otp-bikesLayer-hub-popup'](context).get(0);
Expand Down
23 changes: 23 additions & 0 deletions src/client/js/otp/layers/layers-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<p><b>Smart Kiosk</b></p>

<p>An interactive digital display with various helpful functions like wayfinding.</p>

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -42,6 +45,8 @@
Capacity: {{capacity}}<br>
{{/capacity}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand Down Expand Up @@ -298,6 +303,8 @@ <h3><span>Help</span></h3>
<a target="_blank" href="{{reserve_link}}">Reserve this bike</a>
</div>

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -318,6 +325,8 @@ <h3><span>Help</span></h3>
<div class="cell width_7">{{station.bikesAvailable}}</div>
</div>

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand Down Expand Up @@ -352,6 +361,8 @@ <h3 class=no_margin>{{name}}</h3>
Operated by: {{operator}}<br>
{{/operator}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -375,6 +386,8 @@ <h3>Electric Vehicle Charging Station</h3>
<a href="http://www.usf.edu/administrative-services/parking/parking/ev-charging-stations.aspx" target="_blank">More information</a>
{{/inTampaCampus}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand Down Expand Up @@ -407,6 +420,8 @@ <h3>Parking Lot</h3>
<b>Note</b>: {{note}}<br>
{{/note}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -419,6 +434,8 @@ <h3>Parking Lot</h3>

<p>For more information see <a href="http://www.usf.edu/it/class-prep/free-printing-locations.aspx" target="_blank">here</a>.</p>

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -429,6 +446,8 @@ <h3>Parking Lot</h3>

Type: {{sport}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand Down Expand Up @@ -458,6 +477,8 @@ <h3>Parking Lot</h3>
Hours: {{opening_hours}}<br>
{{/opening_hours}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand All @@ -469,6 +490,8 @@ <h3>Parking Lot</h3>

{{#note}}Note: {{note}}<br>{{/note}}

<p>Plan a Trip: <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('start', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">Start Here</a> | <a href="javascript:void(0)" onclick="javascript:webapp.modules[0].layerWidget.setPlannerMarker('end', this)" data-lat="{{pos.lat}}" data-lng="{{pos.lng}}">End Here</a></p>

</div>
</script>

Expand Down
20 changes: 18 additions & 2 deletions src/client/js/otp/widgets/tripoptions/LayersWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ otp.widgets.LayersWidget =
module : null,
minimumZoom : 15,
layersUsed : [],

setPlannerMarker : function(marker, this_) {
pos = L.latLng( $(this_).data("lat"), $(this_).data("lng") );
console.log(pos);

if (marker == 'start')
webapp.planner.setStartPoint(pos, true);
else
webapp.planner.setEndPoint(pos, true);

webapp.planner.optionsWidget.updateURL();

},

toggle_bus_layer : function(rte) {

Expand Down Expand Up @@ -360,11 +373,14 @@ otp.widgets.LayersWidget =
vals = {};
}

marker = L.marker(L.latLng(latlng[0], latlng[1]), {icon: opts['icon']} );
pos = L.latLng(latlng[0], latlng[1]);
marker = L.marker(pos, {icon: opts['icon']} );
marker._leaflet_id = L.stamp(marker);

vals['pos'] = pos;

var html = false;
if ('popup' in opts) html = opts['popup'];
if ('popup' in opts) html = Mustache.to_html( opts['popup'], vals );
else if ('popupTemplate' in opts) {
html = ich[ opts['popupTemplate'] ]( vals ).html();
}
Expand Down

0 comments on commit b694a65

Please sign in to comment.