Foros del Web » Programando para Internet » Javascript »

Añadir marca de posicion a google maps

Estas en el tema de Añadir marca de posicion a google maps en el foro de Javascript en Foros del Web. Hola. tengo este código pero quiero que me ponga un globito de esos de marcadores de posición en la coordenada que yo quiera al cargar ...
  #1 (permalink)  
Antiguo 28/12/2010, 09:07
 
Fecha de Ingreso: mayo-2010
Mensajes: 53
Antigüedad: 13 años, 11 meses
Puntos: 6
Pregunta Añadir marca de posicion a google maps

Hola. tengo este código pero quiero que me ponga un globito de esos de marcadores de posición en la coordenada que yo quiera al cargar el mapa. Estoy pegado de javascript, ¿alguien por favor me puede decir cómo lo hago?. Muchas gracias.

<script src="MI API KEY" type="text/javascript"></script>

<script type="text/javascript">
//<![CDATA[

// Inicialización de variables.
var map = null;
var geocoder = null;

function load() { // Abre LLAVE 1.
if (GBrowserIsCompatible()) { // Abre LLAVE 2.
map = new GMap2(document.getElementById("map"));

map.setCenter(new GLatLng(<? if ($longitud == "" || $latitud == "") { echo '36.40102052817638,-5.870819091796875 ), 9'; } else { echo $longitud.','.$latitud; ?> ), 15 <? } ?>);
// map.setCenter(new GLatLng(<? echo $longitud.','.$latitud; ?>), 15);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());


geocoder = new GClientGeocoder();

//---------------------------------//
// MARCADOR AL HACER CLICK
//---------------------------------//
GEvent.addListener(map, "click",
function(marker, point) {
if (marker) {
null;
} else {
map.clearOverlays();
var marcador = new GMarker(point);
map.addOverlay(marcador);
//marcador.openInfoWindowHtml("<b><br>Coordenadas:<b r></b>Latitud : "+point.y+"<br>Longitud : "+point.x+"<a href=http://www.mundivideo.com/fotos_pano.htm?lat="+point.y+"&lon="+point.x+"&map a=3 TARGET=fijo><br><br>Fotografias</a>");
//marcador.openInfoWindowHtml("<b>Coordenadas:</b> "+point.y+","+point.x);
document.form_mapa.coordenadas.value = point.y+","+point.x;
}
}
);
//---------------------------------//
// FIN MARCADOR AL HACER CLICK
//---------------------------------//

} // Cierra LLAVE 1.
} // Cierra LLAVE 2.

//---------------------------------//
// GEOCODER
//---------------------------------//
function showAddress(address, zoom, valor) {
if (geocoder) {
geocoder.getLatLng(address,
function(point) {
if (!point) {
alert(address + " No se encuentra. Introduzca una dirección válida");
} else {
map.setCenter(point, zoom);
var marker = new GMarker(point);
map.addOverlay(marker);
//marker.openInfoWindowHtml("<b>"+address+"</b><br>Coordenadas:<br>Latitud : "+point.y+"<br>Longitud : "+point.x+"<a href=http://www.mundivideo.com/fotos_pano.htm?lat="+point.y+"&lon="+point.x+"&map a=3 TARGET=fijo><br><br>Fotografias</a>");
// marker.openInfoWindowHtml("<b>Coordenadas:</b> "+point.y+","+point.x);
document.form_mapa.coordenadas.value = point.y+","+point.x;
}
}
);
}}
//---------------------------------//
// FIN DE GEOCODER
//---------------------------------//
//]]>
</script>
<!-- -->
<script type="text/javascript">
function showAdd() {
try{
var address = document.getElementById("address").value;
var zoom = document.getElementById("zoom").value;
showAddress(address, zoom=parseFloat(zoom));
} catch(error) {
alert(error);//esto te dirá si algo no salió bien
}
}
</script>

Etiquetas: geolocalización, google, maps, marca
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:57.