templates/trip.html

changeset 116
5b6652cd4954
parent 115
9452b9ac69e6
child 117
e7174afc6121
equal deleted inserted replaced
115:9452b9ac69e6 116:5b6652cd4954
124 </tr> 124 </tr>
125 {% endfor %} 125 {% endfor %}
126 </tbody> 126 </tbody>
127 </table> 127 </table>
128 <script> 128 <script>
129 function openBusStop(event) { 129 var osm = L.tileLayer(
130 window.open(this.options._my_bus_stop_url); 130 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
131 {
132 attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
133 maxZoom: 19,
134 }
135 );
136 var tiles = {
137 "OpenStreetMap (Carto)": osm,
138 "MML Peruskartta": L.tileLayer(
139 'http://tiles.kartat.kapsi.fi/peruskartta/{z}/{x}/{y}.jpg',
140 {
141 attribution: 'Map data &copy; Maanmittauslaitos',
142 maxZoom: 19,
143 }
144 ),
145 "MML Taustakartta": L.tileLayer(
146 'http://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg',
147 {
148 attribution: 'Map data &copy; Maanmittauslaitos',
149 maxZoom: 19,
150 }
151 ),
152 "MML Ortokuva": L.tileLayer(
153 'http://tiles.kartat.kapsi.fi/ortokuva/{z}/{x}/{y}.jpg',
154 {
155 attribution: 'Map data &copy; Maanmittauslaitos',
156 maxZoom: 19,
157 }
158 ),
159 "OpenTopoMap": L.tileLayer(
160 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
161 {
162 attribution: 'Map data &copy; Maanmittauslaitos',
163 maxZoom: 18,
164 }
165 ),
131 } 166 }
167
132 var route = [{{shape}}]; 168 var route = [{{shape}}];
133 var mymap = L.map('mapid').setView([60.45175, 22.26705], 13); 169 var mymap = L.map('mapid', {layers: [osm]}).setView([60.45175, 22.26705], 13);
134 var myIcon = L.icon({ 170 var myIcon = L.icon({
135 iconUrl: '/static/favicon.png', 171 iconUrl: '/static/favicon.png',
136 iconSize: [16, 16], 172 iconSize: [16, 16],
137 iconAnchor: [8, 8], 173 iconAnchor: [8, 8],
138 popupAnchor: [-3, -76], 174 popupAnchor: [-3, -76],
139 }); 175 });
140 L.tileLayer( 176
141 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 177 L.control.layers(tiles).addTo(mymap);
142 //'http://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg',
143 {
144 attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
145 maxZoom: 18,
146 }
147 ).addTo(mymap);
148 var polyline = L.polyline(route, { 178 var polyline = L.polyline(route, {
149 color: 'black', 179 color: 'black',
150 dashArray: [3, 5], 180 dashArray: [3, 5],
151 }).addTo(mymap); 181 }).addTo(mymap);
152 // zoom the map to the polyline 182 // zoom the map to the polyline
153 mymap.fitBounds(polyline.getBounds()); 183 mymap.fitBounds(polyline.getBounds());
154 184
155 {% for entry in schedule %} 185 {% for entry in schedule %}
156 {% for halt in entry['stops'] %} 186 {% for halt in entry['stops'] %}
157 marker = L.circleMarker([{{halt["location"]}}], { 187 marker = L.circleMarker([{{halt["location"]}}], {
158 radius: 6, 188 radius: 12,
159 color: 'black', 189 color: 'black',
160 fillColor: 'yellow', 190 fillColor: 'yellow',
161 fillOpacity: 1, 191 fillOpacity: 1,
162 title: "{{halt['ref']}} {{halt['name']}}", 192 title: "{{halt['ref']}} {{halt['name']}}",
163 _my_bus_stop_url: "/stop/{{halt['ref']}}", 193 _my_bus_stop_url: "/stop/{{halt['ref']}}",

mercurial