-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,740 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# mexico-leaflet | ||
A map of Mexico with Leaflet and Geojson | ||
# Map of Mexico with Leaflet and Geojson | ||
A map of Mexico divided by states and municipalities. Made with Leaflet and 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<html> | ||
<head> | ||
<title>México - Mapa</title> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css"/> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js"></script> | ||
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | ||
<style> | ||
#map{ height: 100% } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<div id="map"></div> | ||
|
||
<script> | ||
var map = new L.Map("map", {center: [19.4326, -99.13], zoom: 5}) | ||
.addLayer(new L.TileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")); | ||
|
||
$.getJSON("states.geojson",function(data){ | ||
L.geoJson(data).addTo(map); | ||
}); | ||
|
||
var munjson; | ||
$.getJSON("municipalities.geojson", setgeoJson); | ||
|
||
function setgeoJson(data) | ||
{ | ||
var geoJsonLayer = L.geoJson(data, { | ||
style: function(feature){ | ||
var fillColor; | ||
colors = ["#85C1E9", "#A9CCE3", "#3498DB", "#2E86C1", "#2874A6"]; | ||
fillColor = colors[Math.floor(Math.random() * colors.length)]; | ||
return { color: "#fff", weight: 0.2, fillColor: fillColor, fillOpacity: .5 }; | ||
}, | ||
onEachFeature: function(feature, layer){ | ||
layer.bindPopup( "<strong>" + feature.properties.mun_name + "</strong><br/> Código de municipio: " + feature.properties.mun_code + "<br/> Código de estado: " + feature.properties.state_code ) | ||
} | ||
} | ||
).addTo(map); | ||
geoJsonLayer.eachLayer(function (layer) { | ||
layer._path.id = 'estado' + layer.feature.properties.state_code+'-mun'+layer.feature.properties.mun_code; | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.