fix: fix map marker click and handle null values
- Comment out marker click listener to fix a bug - Update _map.html.erb to handle null values in the city - Improve error handling This commit addresses a bug where clicking the map marker caused unexpected behavior. The changes involve commenting out the click listener to fix the issue, and updating the view template to handle potential null values in the city object to prevent unexpected behavior.
This commit is contained in:
parent
daa0ceac3e
commit
b6635e5a51
@ -43,9 +43,9 @@ export default class extends Controller {
|
||||
const marker = new mapboxgl.Marker()
|
||||
.setLngLat([this.longitudeValue, this.latitudeValue])
|
||||
.addTo(this.map);
|
||||
marker.getElement().addEventListener('click', () => {
|
||||
this.showPopup();
|
||||
});
|
||||
// marker.getElement().addEventListener('click', () => {
|
||||
// this.showPopup();
|
||||
// });
|
||||
|
||||
// 默认弹出窗口
|
||||
// this.showPopup();
|
||||
|
@ -8,7 +8,7 @@
|
||||
data-map-longitude-value="<%= @city.longitude %>"
|
||||
data-map-token-value="<%= Rails.application.credentials.dig(:mapbox, :token) %>"
|
||||
data-map-weather-art-value="<%= @city.latest_weather_art.to_json %>"
|
||||
data-map-weather-art-url-value="<%= rails_blob_url(@city.latest_weather_art.webp_image.processed ) %>"
|
||||
data-map-weather-art-url-value="<%= rails_blob_url(@city&.latest_weather_art&.webp_image&.processed ) if @city&.latest_weather_art&.image&.attached %>"
|
||||
class="h-[500px] w-full rounded-b-2xl z-10"
|
||||
style="touch-action: none"
|
||||
></div>
|
||||
|
Loading…
Reference in New Issue
Block a user