From 29ab62a2188d347937681913c88ae44d701afe22 Mon Sep 17 00:00:00 2001 From: Lena Namiki Date: Wed, 9 Jun 2021 18:45:05 +0900 Subject: [PATCH] Fixed map so that when routing on the destination marker shows --- app/controllers/parkings_controller.rb | 5 +++++ app/javascript/plugins/init_mapbox.js | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/parkings_controller.rb b/app/controllers/parkings_controller.rb index ec9a36f..3ae1bf4 100644 --- a/app/controllers/parkings_controller.rb +++ b/app/controllers/parkings_controller.rb @@ -16,6 +16,11 @@ def index if params[:to_parking].present? @parking = Parking.find(params[:to_parking]) @destination = [@parking.longitude, @parking.latitude] + @markers = [{ + lat: @parking.latitude, + lng: @parking.longitude, + marker: render_to_string(partial: "marker", locals: { parking: @parking }) + }] end @favorite_parkings = current_user.favorited_by_type('Parking') end diff --git a/app/javascript/plugins/init_mapbox.js b/app/javascript/plugins/init_mapbox.js index 4db0723..1a79366 100644 --- a/app/javascript/plugins/init_mapbox.js +++ b/app/javascript/plugins/init_mapbox.js @@ -38,11 +38,10 @@ const initMapbox = () => { }, trackUserLocation: true, fitBoundsOptions: { - maxZoom: 13 + maxZoom: 15 } }); - // Add geolocate control button to the map. map.addControl(geolocate, 'bottom-right'); if (mapElement.dataset.destination) {