Commit 43e9fbe5cab186175d302b772ee3964ca881b310

  • avatar
  • arvind
  • Tue Jan 29 20:59:40 IST 2013
Added UI improvments
			- Markers have been added into a layer group and they can be hidden and shown.
			- Introduces a bug of labels not showing again when the layer is shown after being hidden.
index.html
(3 / 2)
  
1515 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
1616</head>
1717<body>
18 <div id="map" style="width: 1024px; height: 800px; margin-top:30px;"></div>
18 <b>Reload to reset</b>
19 <div id="map" style="width: 800x; height: 600px; margin-top:30px;"></div>
1920 <script type="text/template" id="image-item-template">
2021 <div id="image-wrapper">
21 <em><%= cnt %></em>
22 <div><em><%= cnt %></em></div>
2223 <img src="<%= src %>" style="height:200px;width:200px;">
2324 </div>
2425 </script>
main.js
(36 / 8)
  
11var count = 0;
22var map;
3var markers = new L.LayerGroup();
4var photos = new L.LayerGroup();
35function init(){
4 map = L.map('map').setView([14.31336, 76.64973], 13);
6 var tileLayer = L.tileLayer('http://{s}.tile.cloudmade.com/157f9082094e402f89d242e9b9144483/997/256/{z}/{x}/{y}.png', {
7 maxZoom: 18,
8 attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ©<a href="http://cloudmade.com">CloudMade</a>'
9 });
10 var overlays = {
11 "Places" : markers,
12 "Photos": photos
13 };
14 var baseLayer = {
15 "Base Map": tileLayer
16 };
17 map = L.map('map', {layers:[tileLayer, markers, photos]}).setView([14.31336, 76.64973], 13);
518 map.minZoom = 13;
619 map.maxZoom = 13;
720 map.zoomControl = false;
8 L.tileLayer('http://{s}.tile.cloudmade.com/157f9082094e402f89d242e9b9144483/997/256/{z}/{x}/{y}.png', {
9 maxZoom: 18,
10 attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ©<a href="http://cloudmade.com">CloudMade</a>'
11 }).addTo(map);
21 L.control.scale({position: 'bottomleft'}).addTo(map);
22 L.control.layers(baseLayer, overlays).addTo(map);
1223 loadWayPoints();
1324 loadTrackPoints();
25
1426}
1527function loadWayPoints(){
1628 var wayPointList = ['drdoway.json', 'iiscway.json', 'iiscway2.json'];
3131 L.geoJson(keys, {
3232 pointToLayer: function(feature, latlng) {
3333 if(feature.properties.name != "Picture") {
34 var m = L.marker(latlng).bindLabel(feature.properties.name, {noHide: true}).addTo(map).showLabel();
34 var m = L.marker(latlng).bindLabel(feature.properties.name, {noHide: true}).addTo(markers);
35 if(i == wayPointList.length){
36 this.appendLabels(markers);
37 }
3538 return m;
3639 }
3740 else {
3841 count++;
39 var m = L.marker(latlng).bindLabel(count.toString(), {noHide: true}).addTo(map).showLabel();
42 var m = L.marker(latlng).bindLabel(count.toString(), {noHide: true}).addTo(photos);
4043 var template = _.template($('#image-item-template').html());
4144 x = $('body').append(template({cnt: count, src: feature.properties.link1_href}));
42 console.log(x);
45 m.on('click',function(e){
46 e.target.bindPopup("<img src='"+feature.properties.link1_href+"' style='height:200px;width:200px;'>").openPopup();
47 });
48 if(i == wayPointList.length-1){
49 this.appendLabels(photos);
50 }
4351 return m;
4452 }
4553 }
5555 },'json');
5656 }
5757}
58function appendLabels(x){
59 console.log("test");
60 x.eachLayer(function(layer){
61 layer.showLabel();
62 });
63}
64
65
5866function loadTrackPoints() {
5967 var trackPointList = ['drdo.json', 'iisctrack.json', 'kaaval.json'];
6068 for(var i=0; i<trackPointList.length;i++) {