Skip to content

Commit

Permalink
LEL Integration (#3213)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarpreet-chadha authored and jywarren committed Aug 7, 2018
1 parent a0e957e commit c779723
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions app/views/map/_leaflet.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
<%= 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') %>
<%= javascript_include_tag('/lib/leaflet-environmental-layers/dist/windRoseLayer.js') %>
<%= javascript_include_tag('/lib/leaflet-hash/leaflet-hash.js') %>

<%= javascript_include_tag('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js') %>
<%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css" %>


<% unique_id = rand(100) %>
<style>
#map<%= unique_id %> { width:100%; height:300px; margin: 0; position: relative;}
</style>
<div class="leaflet-map" id="map<%= unique_id %>"></div>
<% if defined? people %><p><i><small>Share your own location on <a href='/profile'>your profile</a>.</small></i></p><% end %>
<script>
var map<%= unique_id %> = L.map('map<%= unique_id %>').on('load', onMapLoad).setView([<%= lat %>,<%= lon %>], <%= lat.to_s.length.to_i %> + 6);
L.tileLayer("//a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png").addTo(map<%= unique_id %>);

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
}).on('load', onMapLoad).setView([<%= lat %>,<%= lon %>], <%= lat.to_s.length.to_i %> + 6);

var map_lat = <%= lat %> ;
var map_lon = <%= lon %> ;

setupFullScreen(map<%= unique_id %> , map_lat , map_lon) ;
setupLEL(map<%= unique_id %> ) ;
var hash = new L.Hash(map<%= unique_id %> );

function onMapLoad(e){
var lat = <%= lat %> ;
var lon = <%= lon %> ;
var s = lat+","+lon ;
$.getJSON("/api/srch/locations?srchString="+s , function(data){
if (!!data.items){
for (i = 0; i < data.items.length ; i++) {
var url = data.items[i].docUrl ;
var title = data.items[i].docTitle ;
L.marker([data.items[i].latitude , data.items[i].longitude]).addTo(map<%= unique_id %>).bindPopup("<a href=" + url + ">" + title + "</a>") ;
var url = data.items[i].docUrl ;
var title = data.items[i].docTitle ;
var default_url = PLmarker_default() ;
L.marker([data.items[i].latitude , data.items[i].longitude] , {icon: default_url}).addTo(map<%= unique_id %>).bindPopup("<a href=" + url + ">" + title + "</a>") ;
}
}
});
Expand Down

0 comments on commit c779723

Please sign in to comment.