jueves, 6 de enero de 2011

Application that displays the coordinates of cell phone in Desktop with google maps

In this post I use 2 previous articles about create web browser and howto capture cell phone location.

The idea is capture the information of GPS from cell phone and display location in application with gtk, webkit and python with Google Maps.

The glade interface shown below.

It's actually the same application web browser but, I remove the text entry and button "go ".

Below the code:

#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
Descripción: Program that capture the location of cell phone
     shown in google maps on the Linux desktop.
Author: Ernesto Crespo
Email: ecrespo@gmail.com
#Import gtk and webkit

import gtk
import webkit
#Import android and time
import android
from time import sleep

#class App
class App:
    def __init__(self):
        #init function
        #Binding glade file with Builder
        self.glade_file = "geolocalizcion.glade"
        self.glade = gtk.Builder()
        #Bind window geo
        self.window = self.glade.get_object('geo')
        #Bind button exit
        self.exit = self.glade.get_object('salir')
        #Bind scrolledwindow
        self.scrolledwindow1 = self.glade.get_object('scrolledwindow1')
        #Linking destroy event with function
        #Linking clicked event with function
        self.exit.connect('clicked', self.on_salir_clicked)
        #Open google maps site
        #create Object webview
        self.webview = webkit.WebView()
        #Add webview in scrolledwindow
        #Capture location
        tupla = localizacion()
        #Open  google maps URL win  longitude and latitude
        self.__go("http://maps.google.com/maps?q=%s,%s" %tupla)
        #Show window
    def __go(self,url):
        #Open URL
    def on_geo_destroy(self,*args):
        #close application
    def on_exit_clicked(self,*args):
     #close application
    def main(self):
        #Start application
def localizacion():
        #create android object
        droid = android.Android()
        #start location
        #wait 15 seconds
        #capture latitude and longitude
        latitude = droid.readLocation().result["network"]["latitude"]
        longitude = droid.readLocation().result["network"]["longitude"]
        #Stop location
        #return latitude and longitude
        return (latitude,longitude)

if __name__ == '__main__':
    app = App()

The figure showing the app running with google maps site.

No hay comentarios:

Publicar un comentario