@Acidham Try this
import location
from math import radians, sin, cos, asin, sqrt, atan2, degrees, pi, pow
import ui
def calculate_distance(pointA, pointB):
"""
:Parameters:
- `pointA: The tuple representing the latitude/longitude for the
first point. Latitude and longitude must be in decimal degrees
- `pointB: The tuple representing the latitude/longitude for the
second point. Latitude and longitude must be in decimal degrees
:Returns:
The distance in km
"""
# convert decimal degrees to radians
#print(pointA, pointB)
lat1 = radians(pointA[0])
lat2 = radians(pointB[0])
lon1 = radians(pointA[1])
lon2 = radians(pointB[1])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 6371 # Radius of earth in kilometers. Use 3956 for miles
dist = c * r
#print(dist)
return dist
lat_cen = 48.8582 # Tour Eiffel
lon_cen = 2.2945
w_m = 1000
h_m = 1000
img = location.render_map_snapshot(lat_cen, lon_cen, width=w_m, height=h_m, map_type='standard', show_poi=True, img_width=512, img_height=512, img_scale=0)
lat_pin = 48.8560793 # Bassins du Champ de Mars
lon_pin = 2.2979048
x = calculate_distance((lat_cen,lon_cen),(lat_cen,lon_pin))
y = calculate_distance((lat_cen,lon_cen),(lat_pin,lon_cen))
#print(x,y)
x = img.size.w/2 + x*img.size.w/(w_m/1000)
y = img.size.h/2 + y*img.size.h/(h_m/1000)
with ui.ImageContext(img.size.w, img.size.h) as ctx:
img.draw()
d = 8
path = ui.Path.oval(x-d,y-d,2*d,2*d)
ui.set_color('red')
path.move_to(x-d,y)
path.line_to(x+d,y)
path.move_to(x,y-d)
path.line_to(x,y+d)
path.stroke()
result = ctx.get_image()
result.show()
