Fóruns sobre PHP, JavaScript, HTML, MySQLi, jQuery, Banco de Dados, CSS

Moderador: web

 
Avatar do usuário
ADMIN
ADMIN
Tópico Autor
Mensagens: 17253
Nome: Kleber
Descrição do site: Onde você encontra scripts grátis para o seu site
Sexo: Masculino
Localização: RJ / RJ / Brasil
Contato:

Script GoogleMaps para buscar um endereço

25-02-2009 20:32

Abaixo segue um script do GoogleMaps, onde é possível buscar um endereço setando o nome dele, no exemplo é buscado o Maracanã, no Rio de Janeiro

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAagyx2nAGObLrnCNzIFj4KRT3C3zzxZP6upRm2g8-oS6xTo2q9BS6Ayeai1Oba1PFDMroiVnYyssBkA" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map; var geocoder; function load() { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(23, 48), 14); geocoder = new GClientGeocoder(); findLocation("Maracanã, RJ"); } // addAddressToMap() is called when the geocoder returns an // answer. It adds a marker to the map with an open info window // showing the nicely formatted version of the address and the country code. function addAddressToMap(response) { map.clearOverlays(); if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(place.address + '<br>' + '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode); } } // showLocation() is called when you click on the Search button // in the form. It geocodes the address entered into the form // and adds a marker to the map at that location. function showLocation() { var address = document.forms[0].q.value; geocoder.getLocations(address, addAddressToMap); } // findLocation() is used to enter the sample addresses into the form. function findLocation(address) { document.forms[0].q.value = address; showLocation(); } //]]> </script> </head> <body onload="load()"> <!-- Creates a simple input box where you can enter an address and a Search button that submits the form. //--> <form action="#" onsubmit="showLocation(); return false;"> <p> <b>Procure um endereço:</b> <input type="text" name="q" value="Maracanã, RJ" class="address_input" size="40" /> <input type="submit" name="find" value="Buscar" /> </p> </form> <div id="map" style="width: 500px; height: 300px"></div> </body> </html>

0
Criar site grátis Wix
Hospedagem de sites Hostgator
Tem um script legal em HTML, CSS, PHP, HTML, JavaScript, jQuery? Poste e compartilhe com os usuários do fórum
:rock:

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado