Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Markers loaded from API * self.notes_map updated * API url updated * https instead of http * MORE THAN 1 MAP ON A PAGE * Url generalised * Indentation done * Indentation 2
- Loading branch information
1 parent
c091474
commit 40f6b3f
Showing
2 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
<% unique_id = rand(100) %> | ||
<style> | ||
<% 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 = L.map('map<%= unique_id %>').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); | ||
</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 %>); | ||
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>") ; | ||
} | ||
} | ||
}); | ||
} | ||
</script> | ||
|
||
<% items.each do |item| %> | ||
L.marker([<%= item.lat %>, <%= item.lon %>]).addTo(map).bindPopup("<a href='<%= item.path %>'><%= item.title %></a>"); | ||
<% end %> | ||
</script> |