![sin imagen de perfil sin imagen de perfil](/img/anonymouse.png)
hola no logro hacer que mi marcador se arrastre y que se agrupen como hago
Publicado por Jean Paul (3 intervenciones) el 22/03/2017 00:41:58
Valora esta pregunta
![Me gusta: Está pregunta es útil y esta clara Me gusta: Está pregunta es útil y esta clara](/img/img.png?11.51)
![NO me gusta: Está pregunta no esta clara o no es útil No me gusta: Está pregunta no esta clara o no es útil](/img/img.png?11.51)
0
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<style type="text/css">
#mapa { height: 500px; }
</style>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBcBM1MEathfs-EYh-HLbAxxFMc-86u6xc&callback=initMap">
</script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
<script>
function writeAddressName(latLng) {//funcion para extarer ubicacion con la ip
var geocoder = new google.maps.Geocoder();
geocoder.geocode
({
"location": latLng
},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
document.getElementById("latLng").innerHTML='Latitud: '+marker.getPosition().lat();
else
document.getElementById("error").innerHTML += "Unable to retrieve your address" + "<br />";
});
}
function geolocationSuccess(position)
{
var marcadores = [
['mi ubicacion',position.coords.latitude, position.coords.longitude],
['resultados de db', 10.2695266,-84.4864645],
['resultados de db2',10.2702022,-84.4770231]
];
var userLatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var map = new google.maps.Map(document.getElementById('mapa'), //muestra el mapa en el div mapa
{
zoom: 13,//distancia a la que se ve el marcadro
center: userLatLng,//centra la vista del mapa en nuestra ubicacion
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;//arreglo para mostrar varios marcadores
for (i = 1; i < marcadores.length; i++)
{
if(i <= 1)
{
marker = new google.maps.Marker(//agarra la ubicacion de uno y mueve el marcador
{
position: new google.maps.LatLng(marcadores[0][1], marcadores[0][2]),
draggable: true,
map: map
});
}
marker = new google.maps.Marker(//agarra la ubicacion de los locales y no se mueve el marcador
{
position: new google.maps.LatLng(marcadores[i][1], marcadores[i][2]),
map: map
});
/*nombre al click del puntero*/
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function()
{
infowindow.setContent(marcadores[i][0]);
infowindow.open(map,marker);
}
})(marker, i));
}
}
function geolocationError(positionError) {
document.getElementById("error").innerHTML += "Error: " + positionError.message + "<br />";
}
function geolocateUser() {
// If the browser supports the Geolocation API
if (navigator.geolocation)
{
var positionOptions = {
enableHighAccuracy: true,
timeout: 10 * 1000 // 10 seconds
};
navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError, positionOptions);
}
else
document.getElementById("error").innerHTML += "Your browser doesn't support the Geolocation API";
}
window.onload = geolocateUser;
</script>
</head>
<body>
<div id="mapa"></div>
<p><b>Address</b>: <span id="latLng"></span></p>
</body>
</html>