1 year ago
#369027
Carol.Kar
Spanning a squareGrid with turf over the whole map
I am using turf to create a squareGrid
:
var Karte = L.map('Karte').setView([34.724126, -92.4079673], 15);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
'attribution': 'Kartendaten © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> Mitwirkende',
'useCache': true
}).addTo(Karte);
var bbox = [-95, 30 ,-85, 40];
var cellSide = 5;
var options = {units: 'kilometers'};
var squareGrid = turf.squareGrid(bbox, cellSide, options);
L.geoJSON(squareGrid).addTo(Karte);
<script src="https://unpkg.com/@turf/turf@6.5.0/turf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.3.0/papaparse.min.js"></script>
<script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"></script>
<link href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" rel="stylesheet"/>
<div id='Karte' style='height: 800px; width: 100%;'></div>
As you can see the bbox spans only over a certain segment of the map. I would like to span it over the whole provided map. (openstreetmap)
Any suggestions how to do this?
I appreciate your replies.
javascript
leaflet
openstreetmap
turfjs
0 Answers
Your Answer