|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | +<head> |
| 4 | +<title></title> |
| 5 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 | +<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css" /> |
| 7 | +<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" /> |
| 8 | +<style type="text/css"> |
| 9 | +body { |
| 10 | + background: #eee |
| 11 | +} |
| 12 | +.leaflet-container { |
| 13 | + height:400px; |
| 14 | + border: 1px solid #ccc |
| 15 | +} |
| 16 | +#ribbon { |
| 17 | + position: absolute; |
| 18 | + top: 0; |
| 19 | + right: 0; |
| 20 | + border: 0; |
| 21 | + filter: alpha(opacity=80); |
| 22 | + -khtml-opacity: .8; |
| 23 | + -moz-opacity: .8; |
| 24 | + opacity: .8; |
| 25 | +} |
| 26 | +</style> |
| 27 | +</head> |
| 28 | +<body> |
| 29 | + |
| 30 | +<div class="container"> |
| 31 | + <h3><a href="../">Leaflet.GeoJSON.Encoded</a></h3> |
| 32 | + <h4>Roads Example</h4> |
| 33 | + <p>Comparison of the GeoJSON loading time</p> |
| 34 | + <div class="row"> |
| 35 | + <div id="map-label1" class="col-xs-5 text-nowrap">Original: <em>roads.json</em> - 934Kbytes<br></div> |
| 36 | + <div id="map-label2" class="col-xs-5 col-xs-offset-1 text-nowrap">Encoded: <em>roads_encoded.json</em> - 668Kbytes<br></div> |
| 37 | + </div> |
| 38 | + <div class="row"> |
| 39 | + <div class="col-xs-5" id="map1"></div> |
| 40 | + <div class="col-xs-5 col-xs-offset-1" id="map2"></div> |
| 41 | + </div> |
| 42 | +</div> |
| 43 | + |
| 44 | +<script src="../node_modules/jquery/dist/jquery.min.js"></script> |
| 45 | +<script src="../node_modules/leaflet/dist/leaflet-src.js"></script> |
| 46 | +<script src="../node_modules/polyline-encoded/Polyline.encoded.js"></script> |
| 47 | +<script src="../src/leaflet.geojson.encoded.js"></script> |
| 48 | +<script> |
| 49 | + |
| 50 | + var time1 = new Date().getTime(); |
| 51 | + $.getJSON('roads.json', function(data) { |
| 52 | + |
| 53 | + $('#map-label1').append('<b>Load time: ' + (new Date().getTime()-time1) + 'ms</b>'); |
| 54 | + |
| 55 | + var geoPlain = new L.GeoJSON(data, {style: { weight:1,opacity:1}}); |
| 56 | + |
| 57 | + L.map('map1', { |
| 58 | + layers: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') |
| 59 | + }) |
| 60 | + .addLayer(geoPlain).fitBounds( geoPlain.getBounds() ); |
| 61 | + }); |
| 62 | + |
| 63 | + var time2 = new Date().getTime(); |
| 64 | + $.getJSON('roads_encoded.json', function(data) { |
| 65 | + |
| 66 | + $('#map-label2').append('<b>Load time: ' + (new Date().getTime()-time2) + 'ms</b>'); |
| 67 | + |
| 68 | + var geoEncoded = new L.GeoJSON.Encoded(data, {style: { weight:1,opacity:1,color:'#a00'}}); |
| 69 | + |
| 70 | + L.map('map2', { |
| 71 | + layers: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') |
| 72 | + }) |
| 73 | + .addLayer(geoEncoded).fitBounds( geoEncoded.getBounds() ); |
| 74 | + }); |
| 75 | + |
| 76 | +</script> |
| 77 | +<a href="https://github.com/geobricks/Leaflet.GeoJSON.Encoded"><img id="ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
| 78 | +</body> |
| 79 | +</html> |
0 commit comments