Skip to content

Commit

Permalink
keep default lat/lon zoom level by calculating precision
Browse files Browse the repository at this point in the history
  • Loading branch information
nstjean committed Dec 12, 2019
1 parent 4fa9c8d commit 342334c
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions app/views/editor/rich.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@
}
});

editor.mapModule.blurredLocation.setZoomByPrecision(getPrecisionFromNum("<%= @lat %>"));

$(function() {
var target = document.querySelector('#map_content');
var observer = new MutationObserver(function(mutations) {
Expand All @@ -417,12 +419,9 @@
});

function setLocationButtonText() {
console.log('set it!!!');
if ($('#map_content').is(':hidden')) {
console.log('hidden');
$('#location_button').html('<i class="fa fa-map-marker" aria-hidden="true"></i> Add a location');
} else {
console.log('visible');
$('#location_button').html('<i class="fa fa-minus-circle"></i> Remove location');
}
}
Expand All @@ -448,11 +447,10 @@
// write the ArrayBuffer to a blob, and you're done
var blob = new Blob([ab], {type: mimeString});
return blob;
}
<% if true || params[:datauri_main_image] %>
$('.ple-module-main_image input').fileupload('add', {'files': [ dataURItoBlob('<%= params[:datauri_main_image] %>') ]});
<% end %>

}
<% if true || params[:datauri_main_image] %>
$('.ple-module-main_image input').fileupload('add', {'files': [ dataURItoBlob('<%= params[:datauri_main_image] %>') ]});
<% end %>

})();
$('.legacy-button').click(function onLegacyClick(event) {
Expand All @@ -475,6 +473,24 @@
console.log("Draft:", editor.data.draft);
}

function getPrecisionFromNum(lat) {
let numArr = lat.toString().split('.');
let precision = 0;

if(numArr.length === 1) {
if(Math.floor(lat/100) == lat/100) {
precision = -2;
} else if (Math.floor(lat/10) == lat/10) {
precision = -1;
} else {
precision = 0;
}
} else {
precision = (numArr[1].length >= 3) ? 3 : numArr[1].length;
}

return precision;
}

</script>

0 comments on commit 342334c

Please sign in to comment.