-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Blank Map loaded with call to API (Part 2 of #1934) #2044
Changes from 4 commits
facbe89
1492cf7
4b7892f
b5a1722
efbb200
13f5f38
02d3d16
927af66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,21 @@ | |
<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); | ||
var map = 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); | ||
function onMapLoad(e){ | ||
var lat = <%= lat %> ; | ||
var lon = <%= lon %> ; | ||
var s = lat+","+lon ; | ||
$.getJSON("https:"+"//publiclab.org/api/srch/locations?srchString="+s , function(data){ | ||
if (!!data.items){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this is looking super, but do you think we could do really consistent two-space indentations here so it's cleanly formatted? Sorry to ask, but it does make a big difference over the long run. Thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes @jywarren , i agree and understand the importance of indentation . Doing the changes now , thanks 😄 💯 ! |
||
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).bindPopup("<a href=" + url + ">" + title + "</a>") ; | ||
} | ||
} | ||
}); | ||
|
||
<% items.each do |item| %> | ||
L.marker([<%= item.lat %>, <%= item.lon %>]).addTo(map).bindPopup("<a href='<%= item.path %>'><%= item.title %></a>"); | ||
<% end %> | ||
} | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this aim at
/
rather than//publiclab.org/api/...
?This is looking FANTASTIC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi , thank you so much ! I think both ways are correct , what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i mean that if you run this codebase somewhere besides publiclab.org, we'd want to just aim the request at the root. Make sense?