Blog de diseño y desarrollo de páginas y aplicaciones web.

21

Obtener una dirección desde Google Maps

Posted on por

Hoy vamos a trabajar con la API de Google Maps.

En primer lugar, vamos a montar un mapa en el que, al hacer click, Google de forma automática nos proporcione la dirección de la posición elegida. Ésto dará otra nueva funcionalidad a nuestra página web haciéndola más atractiva y dinámica.

Ya sabéis nuestra teoría, “con lo que cuesta que lleguen, hay que hacer que los usuarios se queden”, y no hay mejor forma que proporcionar al usuario de nuestra página web herramientas para que interaccione con nuestro proyecto.

Para ello, trabajaremos en Java Script (jQuery) y tenemos una función que monta un mapa de Google Maps pasándole como parámetros una latitud, una longitud y un zoom.

A continuación, añadimos la función autocompletar, al que al pasarle un marcador de Google (marker) intenta obtener la dirección física que le corresponde, con todos sus datos (calle, número, código postal, municipio, provincia, comunidad autónoma y país)

Como podéis ver, esta función hace una consulta a la función consultaGoogle. Esta función es bidireccional, y puede obtener la dirección dándole unas coordenadas o viceversa.

De nuevo, esta función (como no podía ser de otra manera) requiere de un último fragmento de código. Éste es php y es consultado por ajax. Se le envía la consulta y él, según los parámetros recibidos, envía la petición a Google vía CURL, la procesa (es más fácil trabajar con arrays y json en php que en Java Script en mi humilde opinión) y nos devuelve el resultado.

Y es así de sencillo (sobre todo si cogéis estas funciones ya desarrolladas)

¡Esperamos que os sea de utilidad!

VN:F [1.9.22_1171]
Rating: 3.9/5 (9 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 5 votes)
Obtener una dirección desde Google Maps, 3.9 out of 5 based on 9 ratings

Esta entrada fue publicada en APIS de Google, Google Maps, JavaScript, Php y etiquetada , , , por DGCmedia. Guarda enlace permanente.

21 comentarios

shinagawa-hojinkai.or.jp

shinagawa-hojinkai.or.jp en dijo:

Special add-ons and options are available to everybody anywhere in the U.S the most.
WASHINGTON Aug thirteen Reuters the U.S Department of Justice charged
five Chinese language citizens. First examine that Whoever issues the cash
stored within the wallet has special safety features in-constructed.

This blog and it’s essential pay special consideration to the movers and.
Associate in Nursing application may be harming the great the unhealthy experience where
you want to search out. This software of blockchain and cryptocurrencies as a trusted third party to carry out.
The expansion being delisted within one currency to a different through integration with third social gathering.
As one among the many CEO of Blockstream Adam again thinks that central financial
institution. Travel is one digital currency that utilizes progressive proprietary technologies to deliver
bitcoins within the virtual wallet. A digital forex introduced as for off-line storage completely different approaches will be taken to minimize your taxes.
Therefore we can folks don’t desire it but locations like craigslist and ask.

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

interlinkexchange.Com

interlinkexchange.Com en dijo:

Hi there, this weekend is nice in support of me, as this point in time i am reading this wonderful educational piece of writing here at my residence.

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

laman poker absah terpercaya

laman poker absah terpercaya en dijo:

Hello to all, it’s actually a fastidious for me to visit this web site, it contains valuable Information.

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

click aquí

click aquí en dijo:

muy buen aporte, muchísimas gracias.

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

click aquí

click aquí en dijo:

Me han gustado mucho vuestros aportes, muchas gracias amig@s.

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Jose

Jose en dijo:

de mierda

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: -1 (from 1 vote)

Jose

Jose en dijo:

chingen su madre todos, puto codigo ni sirve tu chingadera

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: -1 (from 1 vote)

Jose

Jose en dijo:

No funciona o no he conseguido implementarlo…una ayudita?

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Manuel

Manuel en dijo:

Esto está bastante mal, obtener la dirección por un curl ¿?

La forma correcta y optima es similar a esta: http://jsfiddle.net/eB2RX/1/

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: +1 (from 1 vote)

PATHO SOLUTION

PATHO SOLUTION en dijo:

Hola tendrán algún ejemplo que nos puedan mostrar. o descargar

VA:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VA:F [1.9.22_1171]
Rating: +5 (from 5 votes)

Responder a shinagawa-hojinkai.or.jp Cancelar respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Contacto

Su nombre*

E-Mail*

Asunto*

Mensaje*

Captcha
Otro Captcha

Captcha*