Ir al contenido
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Inicia sesión
  • Nederlands English (US) Español (AR)
  • Contáctanos
  • Inicio
  • Blog
  • Empleos
  • Contáctanos
Cafayate.Net
  • 0
  • 0
    • Inicio
    • Blog
    • Empleos
    • Contáctanos
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Inicia sesión
  • Contáctanos

How to get Latitude and Longitude of address in Odoo using Google Api in Python

  • Todos los blogs
  • Tech Blog
  • How to get Latitude and Longitude of address in Odoo using Google Api in Python
  • 5 de marzo de 2021 por
    Administrator

    You may require to get Latitude and Longitude between of an address in Odoo ( Openerp ) for many reasons . Here are steps to follow –

    1. First install pygeocoder Python Package

    Simply you can install using –

    apt-get install python-pip

    pip install pygeocoder
    or from python packages site.

    1. Now import Geocoder class from pygeocoder in your py file

    from pygeocoder import Geocoder
    import urllib

    import json

     

    Now you use get_latitude_longitude (Global )function given below , pass address as argument and you will get a list of latitude and longitude returned from Google Api – ex [19.1605798,72.8380889]
    def get_latitude_longitude(addr):

    url =’https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=’

    url += urllib.quote(addr.encode(‘utf8’))

    res = []

    try:

    gcoder = Geocoder()

    results = gcoder.geocode(addr)

    res.append(results[0].latitude)

    res.append(results[0].longitude)

    except Exception, e:

    pass

    return res

    en Tech Blog
    LXC Getting Started Guide Part II

    Diseñado para empresas

    Somos un equipo de personas apasionadas cuyo objetivo es mejorar la vida de todos a través de productos revolucionarios. Creamos grandes productos para resolver sus problemas empresariales. Nuestros productos están diseñados para pequeñas y medianas empresas dispuestas a optimizar su rendimiento.

    Contáctenos

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Síganos
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)