Skip to content

Commit

Permalink
Basic map
Browse files Browse the repository at this point in the history
  • Loading branch information
strotgen committed Nov 6, 2017
1 parent f7b1885 commit 53150bf
Show file tree
Hide file tree
Showing 9 changed files with 2,740 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .idea/mexico-leaflet.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

187 changes: 187 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions README.md
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.
![screenshot](https://user-images.githubusercontent.com/14982436/32421004-1b616b72-c259-11e7-8789-b810505bf636.png)
48 changes: 48 additions & 0 deletions index.html
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>
Loading

0 comments on commit 53150bf

Please sign in to comment.