Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mapillary viewer to record popup builder #627

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions web/app/scripts/views/map/layers-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@

new L.popup(popupOptions)
.setLatLng(e.latlng)
.setContent(ctl.buildRecordPopup(e.data, popupParams))
.setContent(ctl.buildRecordPopup(e.data, popupParams, e.latlng))
.openOn(ctl.map);

$compile($('#record-popup'))($scope);
Expand Down Expand Up @@ -708,12 +708,25 @@
* @param {Object} UTFGrid interactivity data from interaction event object
* @returns {String} HTML snippet for a Leaflet popup.
*/
ctl.buildRecordPopup = function(record, popupParams) {
ctl.buildRecordPopup = function(record, popupParams, e.latlng) {
// add header with record date constant field
/* jshint camelcase: false */
// DateTimes come back from Windshaft without tz information, but they're all UTC
var url = "https://a.mapillary.com/v3/images?lookat=" + e.latlng.lng + "," + e.latlng.lat + "&closeto=" + e.latlng.lng + "," + e.latlng.lat + "&client_id=UTZhSnNFdGpxSEFFREUwb01GYzlXZzo5ZWIxZWYxNzM1YWY2MjNm&radius=400";
var imgkey;
var mly;
$.ajax({
dataType: 'json',
url: url,
success: function (data) {
imgkey = data.images[0]["key"];
mly = '<iframe width=\"320\" height=\"200\" src=\"https://embed-v1.mapillary.com/embed?show_segmentation=true&version=1&filter=%5B%22all%22%5D&map_filter=%5B%22all%22%5D&image_key=" + imgkey + "&client_id=UTZhSnNFdGpxSEFFREUwb01GYzlXZzo5ZWIxZWYxNzM1YWY2MjNm&style=photo\" frameborder=\"0\"></iframe>';
},
async: false
});
var occurredStr = localizeRecordDateFilter(moment.utc(record.occurred_from), dateFormat, true);
var str = '<div id="record-popup" class="record-popup">';
str += mly;
str += '<div><h5>' + popupParams.label + ' ' + detailsLabel +
'</h5><h3>' + occurredStr + '</h3>';
/* jshint camelcase: true */
Expand Down