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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

LBLD integrated to /plots2 . #5358

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to鈥
Jump to file or symbol
Failed to load files and symbols.
+57 鈭101
Diff settings

Always

Just for now

@@ -1,3 +1,7 @@

<%= javascript_include_tag('/lib/leaflet-blurred-location/dist/Leaflet.BlurredLocation.js') %>
<%= javascript_include_tag('/lib/leaflet-blurred-location-display/dist/Leaflet.BlurredLocationDisplay.js') %>

<%= stylesheet_link_tag "/lib/leaflet/dist/leaflet.css" %>
<%= stylesheet_link_tag "/lib/leaflet-environmental-layers/dist/LeafletEnvironmentalLayers.css" %>
<%= javascript_include_tag('/lib/leaflet-environmental-layers/dist/LeafletEnvironmentalLayers.js') %>
@@ -12,3 +16,4 @@

<%= javascript_include_tag('/lib/leaflet-spin/example/spin/dist/spin.min.js') %>
<%= javascript_include_tag('/lib/leaflet-spin/example/leaflet.spin.min.js') %>

@@ -1,4 +1,5 @@
<%= render :partial => "map/mapDependencies" %>

<% unique_id = rand(1000) %>

<style>
@@ -21,115 +22,64 @@

<script>
var bounds = new L.LatLngBounds(new L.LatLng(84.67351257 , -172.96875) , new L.LatLng(-54.36775852 , 178.59375)) ;
var map<%= unique_id %> = L.map('map<%= unique_id %>', {
maxBounds: bounds ,
maxBoundsViscosity: 0.75
}).setView([<%= lat %>,<%= lon %>], 2);
var map<%= unique_id %> = L.map('map<%= unique_id %>').setView([<%= lat %>,<%= lon %>], 3) ;
map<%= unique_id %>.options.minZoom = 2 ;
var markers_hash<%= unique_id %> = new Map() ;
map<%= unique_id %>.spin(true) ;
window.setTimeout(function(){
<% if !@map_lat.nil? && !@map_lon.nil? %>
var map_lat = <%= @map_lat %> ;
var map_lon = <%= @map_lon %> ;
var user_latlng = L.latLng(map_lat, map_lon) ;
map<%= unique_id %>.setView(user_latlng , 3) ;
<% else %>
map<%= unique_id %>.setZoom(2) ;
<% end %>
}, 3500);
<% if defined? tag_name != nil and tag_name == false %>
<% @tagname_param = nil %>
<% end %>
map<%= unique_id %>.on('zoomend' , function () {
var NWlat = map<%= unique_id %>.getBounds().getNorthWest().lat ;
var NWlng = map<%= unique_id %>.getBounds().getNorthWest().lng ;
var SElat = map<%= unique_id %>.getBounds().getSouthEast().lat ;
var SElng = map<%= unique_id %>.getBounds().getSouthEast().lng ;
map<%= unique_id %>.spin(true) ;
<% if @tagname_param.nil? %>
people_url = "/api/srch/nearbyPeople?nwlat=" + NWlat + "&selat=" + SElat + "&nwlng=" + NWlng + "&selng=" + SElng ;
<% else %>
people_url = "/api/srch/nearbyPeople?nwlat=" + NWlat + "&selat=" + SElat + "&nwlng=" + NWlng + "&selng=" + SElng + "&tag=<%= @tagname_param %>" ;
<% end %>
$.getJSON(people_url , function (data) {
var layerGroup = L.layerGroup();
if (!!data.items) {
for (i = 0; i < data.items.length; i++) {
var default_markers = PLmarker_default();
var mid = data.items[i].doc_id ;
var url = data.items[i].doc_url;
var title = data.items[i].doc_title;
var m = L.marker([data.items[i].latitude, data.items[i].longitude], {
title: title,
icon: default_markers
}) ;
if(markers_hash<%= unique_id %>.has(mid) === false){
m.addTo(map<%= unique_id %>).bindPopup("<a href=" + url + ">" + title + "</a>") ;
markers_hash<%= unique_id %>.set(mid , m) ;
}
}
}
map<%= unique_id %>.spin(false) ;
});
}) ;
map<%= unique_id %>.on('moveend' , function () {
var NWlat = map<%= unique_id %>.getBounds().getNorthWest().lat ;
var NWlng = map<%= unique_id %>.getBounds().getNorthWest().lng ;
var SElat = map<%= unique_id %>.getBounds().getSouthEast().lat ;
var SElng = map<%= unique_id %>.getBounds().getSouthEast().lng ;
map<%= unique_id %>.spin(true) ;
<% if @tagname_param.nil? %>
people_url = "/api/srch/nearbyPeople?nwlat=" + NWlat + "&selat=" + SElat + "&nwlng=" + NWlng + "&selng=" + SElng ;
<% else %>
people_url = "/api/srch/nearbyPeople?nwlat=" + NWlat + "&selat=" + SElat + "&nwlng=" + NWlng + "&selng=" + SElng + "&tag=<%= @tagname_param %>" ;
<% end %>
$.getJSON(people_url , function (data) {
var layerGroup = L.layerGroup();
if (!!data.items) {
for (i = 0; i < data.items.length; i++) {
var default_markers = PLmarker_default();
var mid = data.items[i].doc_id ;
var url = data.items[i].doc_url;
var title = data.items[i].doc_title;
var m = L.marker([data.items[i].latitude, data.items[i].longitude], {
title: title,
icon: default_markers
}) ;
if(markers_hash<%= unique_id %>.has(mid) === false){
m.addTo(map<%= unique_id %>).bindPopup("<a href=" + url + ">" + title + "</a>") ;
markers_hash<%= unique_id %>.set(mid , m) ;
}
}
}
map<%= unique_id %>.spin(false) ;
});
}) ;
<% if defined? url_hash != nil and url_hash == 0 %>
map<%= unique_id %>.spin(false) ;
}, 3500) ;
// LBLD configuration
var options = {
mapID: 'map<%= unique_id %>',
map: map<%= unique_id %>,
InterfaceOptions: {
latId: 'lat',
lngId: 'lng'
}
}
var BlurredLocation = new BlurredLocation(options);
function JSONparser(data)
{
parsed_data = [] ;
if (!!data.items) {
for (i = 0 ; i < data.items.length ; i++) {
let obj = {} ;
obj["id"] = data.items[i].doc_id ;
obj["url"] = data.items[i].doc_url;
obj["latitude"] = parseFloat(data.items[i].latitude) ;
obj["longitude"] = parseFloat(data.items[i].longitude) ;
obj["title"] = data.items[i].doc_title ;
parsed_data[parsed_data.length] = obj ;
}
}
return parsed_data ;
}
zoom_filter = [[0,5,0] , [5,6,2] , [8,10,4] , [11,18,5]] ;
var options_display = {
blurredLocation: BlurredLocation,
source_url: "https://publiclab.org/api/srch/nearbyPeople",
JSONparser: JSONparser,
zoom_filter: zoom_filter
}
var blurredLocationDisplay = new BlurredLocationDisplay(options_display);
// LEL configuration
<% if defined? url_hash != nil and url_hash == 0 %>
setupLEL(map<%= unique_id %> , 0) ;
<% else %>
<% else %>
setupLEL(map<%= unique_id %> , 1) ;
<% end %>
<% end %>
</script>
@@ -40,9 +40,10 @@
"jsdiff": "components/jsdiff#~1.2.2",
"junction": "theleagueof/junction#*",
"leaflet": "^0.7.3",
"leaflet-blurred-location": "^1.2.7",
"leaflet-blurred-location": "git://github.com/publiclab/leaflet-blurred-location#main",
"leaflet-environmental-layers": "^1.2.4",
"leaflet-fullhash": "github:sagarpreet-chadha/leaflet-fullHash",
"leaflet-blurred-location-display": "github:publiclab/leaflet-blurred-location-display",
"leaflet-spin": "1.1.0",
"marked": "^0.3.2",
"megamark": "~3.3.0",
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.