26/07/2012, 16:49
|
| | | Fecha de Ingreso: mayo-2012
Mensajes: 21
Antigüedad: 12 años, 5 meses Puntos: 0 | |
Respuesta: Geocoder google maps api v3 - result types en ingles haber una pregnta ya tengo un mapa con un market pintado mi pregunta es la siguiente
como colocar en la pantalla la latitud y longuitud abajo del mapa al darle click
si este es mi codigo
<html >
<head>
<title>Experimento uno de JavaScript de Google Maps: autocompletado de lugares</title>
<script src="https://maps.google.com/maps/api/js?sensor=false&libraries=places"
type="text/javascript"></script>
<style type="text/css">
body {
font-family: sans-serif;
font-size: 14px;
}
#map {
height: 400px;
width: 600px;
margin-top: 0.6em;
}
input:focus {
outline: none;
}
</style>
<script>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(19.8793216666667, -98.969705),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map
});
google.maps.event.addListener(autocomplete, 'place_changed', function () {
infowindow.close();
var place = autocomplete.getPlace();
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17); // Why 17? Because it looks good.
}
var image = new google.maps.MarkerImage(
place.icon, new google.maps.Size(71, 71),
new google.maps.Point(0, 0), new google.maps.Point(17, 34),
new google.maps.Size(35, 35));
marker.setIcon(image);
marker.setPosition(place.geometry.location);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] &&
place.address_components[0].short_name || ''),
(place.address_components[1] &&
place.address_components[1].short_name || ''),
(place.address_components[2] &&
place.address_components[2].short_name || '')].join(' ');
}
infowindow.setContent('<div><b>' + place.name + '</b><br>' + address);
infowindow.open(map, marker);
});
// Sets a listener on a radio button to change the filter type on Places
// Autocomplete.
var setupClickListener = function (id, types) {
var radioButton = document.getElementById(id);
google.maps.event.addDomListener(radioButton, 'click', function () {
autocomplete.setTypes(types);
});
}
setupClickListener('changetype-all', []);
setupClickListener('changetype-establishment', ['establishment']);
setupClickListener('changetype-geocode', ['geocode']);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div>
<input id="searchTextField" type="text" size="50">
<input type="radio" name="type" id="changetype-all" checked> Todo
<input type="radio" name="type" id="changetype-establishment"> Establecimientos
<input type="radio" name="type" id="changetype-geocode"> Códigos geográficos
</div>
<div id="map"></div>
</body>
</html> |