Last active
January 4, 2024 19:54
-
-
Save ThomasG77/c38e6b0ecfd014342aad to your computer and use it in GitHub Desktop.
Sample Leaflet with GeoJSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>A Leaflet map!</title> | |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" /> | |
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script> | |
<style> | |
#map{ height: 100% } | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
// initialize the map | |
var map = L.map('map').setView([42.35, -71.08], 3); | |
// load a tile layer | |
L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png', | |
{ | |
attribution: 'Tiles by <a href="http://mapc.org">MAPC</a>, Data by <a href="http://mass.gov/mgis">MassGIS</a>', | |
maxZoom: 17, | |
minZoom: 9 | |
}).addTo(map); | |
// load GeoJSON from an external file | |
fetch("countries.geojson").then(res => res.json()).then(data => { | |
// add GeoJSON layer to the map once the file is loaded | |
L.geoJson(data).addTo(map); | |
}); | |
</script> | |
</body> | |
</html> |
from where do u get these geojson data any link you could share
@jivthesh For the current sample, https://gist.githubusercontent.com/ThomasG77/c38e6b0ecfd014342aad/raw/ecaa086688859566f108b9630047a7110ad6eb94/countries.geojson
You may also look at http://geojson.xyz for other GeoJSON samples
Thanks a lot.
…On Mon, 16 Aug 2021 at 01:14, Thomas Gratier ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@jivthesh <https://github.com/jivthesh> For the current sample,
https://gist.githubusercontent.com/ThomasG77/c38e6b0ecfd014342aad/raw/ecaa086688859566f108b9630047a7110ad6eb94/countries.geojson
You may also look at http://geojson.xyz for other GeoJSON samples
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/c38e6b0ecfd014342aad#gistcomment-3861976>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE5ANDAYDCNUJX5TZXX3OGDT5AKIJANCNFSM424VJP4A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
Thanks!
Excellent
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
✨💎