Skip navigation

Category Archives: Google

[google-translator]

Siga os seguintes passos:

1 – inclua a tag meta: meta name=”viewport” content=”initial-scale=1.0, user-scalable=no”

2 – inclua a tag style se desejar: html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% }

3 – inclua o script: http://maps.googleapis.com/maps/api/js?sensor=true&&language=BR

4 – inclua o script seguinte mas altere latitude -23.608326 e longitude -46.697366 para a localização desejada:

var geocoder; var map; var infowindow = new google.maps.InfoWindow(); var marker; function initialize() { var lat = parseFloat(-23.608326); var lng = parseFloat(-46.697366); var latlng = new google.maps.LatLng(lat, lng); var mapOptions = { zoom: 15, center: latlng, mapMarker: true, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById(“map_canvas”), mapOptions); geocoder = new google.maps.Geocoder(); geocoder.geocode({‘latLng’: latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0].formatted_address) { map.setZoom(15); marker = new google.maps.Marker({ position: latlng, map: map }); infowindow.setContent(results[0].formatted_address); infowindow.open(map, marker); } } else { alert(“Geocoder failed due to: ” + status); } }); }

5 – inclua o onload da tag body: onload=”initialize()”

6 – inclua a div: div id=”map_canvas” style=”width:100%; height:100%”