Skip to content
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

Dynamic Zooming using Leaflet mapping library #294

Closed
yosiasz opened this issue Mar 25, 2024 · 2 comments
Closed

Dynamic Zooming using Leaflet mapping library #294

yosiasz opened this issue Mar 25, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@yosiasz
Copy link

yosiasz commented Mar 25, 2024

Dashboard variable countries

select 'China' as __text, '104.1954,35.8617' as __value union
select 'Ethiopia', '40.4897,9.1450' union
select 'Sardina', '9.283447, 40.078072'

external js

https://unpkg.com/leaflet@1.9.4/dist/leaflet.js

external css

https://unpkg.com/leaflet@1.9.4/dist/leaflet.css

Content

<div id="weathermap"></div>

After Content javascript

function mapit(lat, lon) {
  document.getElementById('weathermap').innerHTML = ""
  document.getElementById('weathermap').innerHTML = "<div id='map'></div>";
  var map = new L.Map('map');
  map.setView(new L.LatLng(lat, lon), 4);
  L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
    attribution:
      'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
    maxZoom: 18,
  }).addTo(map);
}

var countries= context.grafana.replaceVariables("${countries:value}")
var lon = Number(countries.split(",")[0])
var lat = Number(countries.split(",")[1])

mapit(lat, lon)

css

#map {
  height: 480px;
  display: flex;
  flex-direction: row;
}
@mikhail-vl mikhail-vl self-assigned this Mar 25, 2024
@mikhail-vl mikhail-vl added the question Further information is requested label Mar 25, 2024
@yosiasz yosiasz changed the title Dynamic Zooming using Leaflef mapping library Dynamic Zooming using Leaflet mapping library Mar 25, 2024
@mikhail-vl mikhail-vl assigned vitPinchuk and unassigned mikhail-vl Jun 5, 2024
@mikhail-vl
Copy link
Member

@vitPinchuk Could you please review and update Leaflet.js section in documentation.

@mikhail-vl
Copy link
Member

Resolved in VolkovLabs/volkovlabs.io#684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

3 participants