python openstreetmap multiple latitude

Solutions on MaxInterview for python openstreetmap multiple latitude by the best coders in the world

showing results for - "python openstreetmap multiple latitude"
Stefania
22 Oct 2016
1# ...
2coordinates = []
3for result in results:
4    coordinates.append((result[5], result[6]))
5
6lat_center = sum([coordinate[0] for coordinate in coordinates]) / len(
7    coordinates
8)
9lng_center = sum([coordinate[1] for coordinate in coordinates]) / len(
10    coordinates
11)
12
13html = r"""
14<!DOCTYPE html>
15    <html>
16        <head>
17        <style type="text/css">
18                html { height: 100%; }
19                body { height: 100%; margin: 0; padding: 0 }
20                #mapid { height: 100% }
21        </style>
22        <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
23        <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
24        </head>
25    <body>
26        <div id="mapDiv" style="width:100%; height:100%"></div>
27        <script>
28"""
29html += "var map = L.map('mapDiv').setView([{lat}, {lng}], 10);".format(
30    lat=lat_center, lng=lng_center
31)
32html += """
33    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
34        attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
35    }).addTo(map);
36"""
37
38for latitude, longitude in coordinates:
39    html += "L.marker([{lat}, {lng}]).addTo(map);\n".format(
40        lat=latitude, lng=longitude
41    )
42
43html += "</script> </body> </html>"
44self.view.setHtml(html)
45
similar questions
queries leading to this page
python openstreetmap multiple latitude