Skip to content

Commit

Permalink
Update Mapbox API to fix map base layers (publiclab#8887)
Browse files Browse the repository at this point in the history
* Update Mapbox API to fix map base layers

* Update tools_places.html.erb

* Update nearby.html.erb

* Update tools_places.html.erb

* Update nearby.html.erb

* Update map.html.erb

* Update profile.html.erb
  • Loading branch information
jywarren authored and reginaalyssa committed Oct 16, 2021
1 parent 91bc419 commit 6ef0eee
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
7 changes: 6 additions & 1 deletion app/views/home/nearby.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

<script>
var map = L.map('map').setView([<%= current_user.lat %>,<%= current_user.lon %>], 8);
L.tileLayer("https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png").addTo(map)
L.tileLayer('https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://apps.mapbox.com/feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);


<% if @users %>
<% @users.each do |user| %>
Expand Down
6 changes: 4 additions & 2 deletions app/views/map/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
maxBounds: bounds ,
maxBoundsViscosity: 0.75
}).setView([15,0], 2);
var baselayer = L.tileLayer('https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
var baselayer = L.tileLayer('https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://apps.mapbox.com/feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map) ;
map.options.minZoom = 1.5 ;

Expand Down
8 changes: 5 additions & 3 deletions app/views/notes/tools_places.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

<script>
var map = L.map('map').setView([22,0], 2);
L.tileLayer("https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png",{
attribution: "<a href='https://openstreetmap.org'>OSM</a> tiles by <a href='http://mapbox.com'>MapBox</a>",
}).addTo(map)
L.tileLayer('https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://apps.mapbox.com/feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);

<% @notes.each do |place| %>
<% if place.lat && place.lon %>L.marker([<%= place.lat %>, <%= place.lon %>]).addTo(map).bindPopup("<a href='<%= place.path %>'><%= place.latest.title %></a>");<% end %>
Expand Down
16 changes: 10 additions & 6 deletions app/views/users/map.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
$("#users_map").html("<div id='map' class='col-lg-12' style='height:500px;'></div>");

var user_map = L.map('map').setView([15,0], 2);
L.tileLayer("https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png",{
attribution: "<a href='https://openstreetmap.org'>OSM</a> tiles by <a href='https://mapbox.com'>MapBox</a>"
}).addTo(user_map);
L.tileLayer('https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://apps.mapbox.com/feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(user_map);

<% @location_tags.each do |location_tag, user_tag| %>

Expand All @@ -75,9 +77,11 @@
var user_map = L.map('map').setView([15,0], 2);
<% end %>

L.tileLayer("https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png",{
attribution: "<a href='https://openstreetmap.org'>OSM</a> tiles by <a href='https://mapbox.com'>MapBox</a>"
}).addTo(user_map);
L.tileLayer('https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://apps.mapbox.com/feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(user_map);

<% @users.each do |user| %>
<% location_privacy = user.user.location_privacy %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<%= render :partial => "map/leaflet" , locals: { lat: @map_lat, lon: @map_lon, zoom: @map_zoom, blurred: @map_blurred, topmap: true, user: @profile_user } %>
<% elsif !current_user.nil? && current_user.id == @profile_user.id %>
<div id="map_template" style="position: relative; width: 100%; display: inline-block;">
<img src="https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/0/0/0.png" style="height:300px; width: 100%; margin: 0; position: relative; margin-right: -10px;">
<img src="https://api.mapbox.com/styles/v1/jywarren/ckj06ujnc1nmi19nuelh46pr9/tiles/0/0/0?access_token=pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig" style="height:300px; width: 100%; margin: 0; position: relative; margin-right: -10px;">
<button type='button' class='blurred-location-input btn btn-default btn-lg' style="position:absolute;position:absolute;top:41%;left:15%;"> <strong> Share your Location </strong> </button>
<p><i><small>Learn about <a href='https://publiclab.org/wiki/location-privacy'>privacy</a> </small></i></p>
<p><i><small>Learn about <a href='https://publiclab.org/location-privacy'>privacy</a> </small></i></p>
</div>
<% end %>

Expand Down

0 comments on commit 6ef0eee

Please sign in to comment.