Skip to content

Instantly share code, notes, and snippets.

@Franck1333
Last active December 10, 2018 23:58
Show Gist options
  • Select an option

  • Save Franck1333/278bc1dad060d2df4f51bf91ccf5c891 to your computer and use it in GitHub Desktop.

Select an option

Save Franck1333/278bc1dad060d2df4f51bf91ccf5c891 to your computer and use it in GitHub Desktop.
Get A Static MAP by Longitude/Latitude with YANDEX and Tkinter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Aides : https://stackoverflow.com/questions/43009527/how-to-insert-an-image-in-a-canvas-item
#Aides : http://apprendre-python.com/page-tkinter-interface-graphique-python-tutoriel
#---Service---#
import urllib #Blibliotheque permetant de recuperer une ou plusieurs ressources sur Internet via HTTP/HTTPS
print('Telechargement de la Carte/Map .jpg') #Message dans la Console
url = 'https://static-maps.yandex.ru/1.x/?lang=en-US&ll=-0.72984,47.2227&z=16&l=skl,map,trf&size=600,300&pt=-0.72984,47.2227,flag' #URL utilise pour obtenir la carte
#Ce service de MAP STATIC ce nomme YANDEX
#Nous l'utilisons de cette facon : https://static-maps.yandex.ru/1.x/?lang=en-US&ll=LONGITUDE,LATITUDE&z=13&l=skl,map,trf&size=600,300&pt=LONGITUDE,LATITUDE,flag
urllib.urlretrieve(url, '/home/pi/Downloads/map.jpg') #Telechargement de l'image resultant de la requete
#---Service---#
#---Interface---#
from Tkinter import *
print('Affichage de la Carte/Map .jpg Telechargee') #Message dans la Console
fenetre = Tk()
canvas = Canvas(fenetre,width=600, height=300, bg='black') #Creer le CANVAS (Parent,Largeur,Hauteur,couleur de font)
canvas.pack(expand=NO, fill=None) #Placement du CANVAS de l'espace
MAPjpg = PhotoImage(file="/home/pi/Downloads/map.jpg") #Chargement de la MAP
canvas.create_image(0,0,image=MAPjpg,anchor=NW) #Integration de la MAP
Button(fenetre, text="Fermer", command=fenetre.destroy).pack() #Bouton de Fermeture du Programme
fenetre.mainloop() #Lancement du Programme Principal
#---interface---#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment