Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python openstreetmap multiple latitude

# ...
coordinates = []
for result in results:
    coordinates.append((result[5], result[6]))

lat_center = sum([coordinate[0] for coordinate in coordinates]) / len(
    coordinates
)
lng_center = sum([coordinate[1] for coordinate in coordinates]) / len(
    coordinates
)

html = r"""
<!DOCTYPE html>
    <html>
        <head>
        <style type="text/css">
                html { height: 100%; }
                body { height: 100%; margin: 0; padding: 0 }
                #mapid { height: 100% }
        </style>
        <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
        <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
        </head>
    <body>
        <div id="mapDiv" style="width:100%; height:100%"></div>
        <script>
"""
html += "var map = L.map('mapDiv').setView([{lat}, {lng}], 10);".format(
    lat=lat_center, lng=lng_center
)
html += """
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);
"""

for latitude, longitude in coordinates:
    html += "L.marker([{lat}, {lng}]).addTo(map);
".format(
        lat=latitude, lng=longitude
    )

html += "</script> </body> </html>"
self.view.setHtml(html)
Comment

PREVIOUS NEXT
Code Example
Python :: projects for beginners in python to complete 
Python :: selenium text value is empty in flask returns 
Python :: roll dice python 
Python :: derivative of multivariable function pytorch 
Python :: holding a function to the code in python 
Python :: notebook python static website generator 
Shell :: error: cannot install "code": classic confinement requires snaps under /snap or 
Shell :: how to check laptop serial number in ubuntu 
Shell :: ubuntu audio restart 
Shell :: git store credential 
Shell :: install sklearn 
Shell :: npm list global packages 
Shell :: how to remove node_modules from git 
Shell :: apache2.service is not active cannot reload. ubuntu 
Shell :: ps not found 
Shell :: flask_wtf install 
Shell :: centos stop apache 
Shell :: how to check my ip address on wsl 
Shell :: clearing dns cache 
Shell :: powershell zip 
Shell :: git install on alpine 
Shell :: ultimate power plan windows 10 
Shell :: install gem ubuntu 
Shell :: zoom repository ubuntu 
Shell :: free port in linux 
Shell :: git delete all tags local and remote 
Shell :: @mui/lab install 
Shell :: Xcode is not installed or not configured properly. Download, install, set it up and run this script again 
Shell :: adb port reverse 
Shell :: how to install typescript on ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =