Permalink
Find file Copy path
6e2f83a Sep 29, 2013
Calvin Metcalf update leaflet
0 contributors

Users who have contributed to this file

72 lines (56 sloc) 2.04 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=1024, user-scalable=no">
<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0;}
#map{ height: 100% }
</style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script type="text/javascript" src="../dist/leaflet.ajax.js"></script>
<title>Leaflet AJAX</title>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">var m= L.map('map').setView([42.2, -71], 8);
var mapQuestAttr = 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ';
var osmDataAttr = 'Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var mopt = {
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpeg',
options: {attribution:mapQuestAttr + osmDataAttr, subdomains:'1234'}
};
var osm = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:osmDataAttr});
var mq=L.tileLayer(mopt.url,mopt.options);
mq.addTo(m);
var baseMaps = {
"Map Quest": mq,
"Open Street Map":osm
};
function popUp(f,l){
var out = [];
if (f.properties){
for(key in f.properties){
out.push(key+": "+f.properties[key]);
}
l.bindPopup(out.join("<br />"));
}
}
var jsonTest = new L.GeoJSON.AJAX("test.geojson",{onEachFeature:popUp});
var jsonpTest = L.geoJson.ajax("http://kublai.ro.lt/test.geojson",{onEachFeature:popUp,dataType:"jsonp"});
jsonTest.addTo(m);
var overlays={
"json":jsonTest,
"jsonp":jsonpTest
}
var lc=L.control.layers(baseMaps,overlays);
lc.addTo(m);
</script>
</body>
</html>