缩放滑块不会出现在我的谷歌地图上

时间:2011-06-01 08:27:35

标签: javascript google-maps slider zoom google-maps-api-2

首先,我也试过了Google Map APi zoom bar not showing,但没有成功,所以我会告诉你我的问题。好的,代码如下:     

var datos = '<%=coorNom%>';
var origen='<%=origen%>';
var vAPIKey = '<%=APIKey%>';
var vLangmap = '<%=langmap%>';
var mapcoords;
$(document).ready(function() {
    var script = document.createElement("script");      
    var gurl =   "http://www.google.com/jsapi?callback=loadMapscoord&key=" + vAPIKey + "&oe=UTF8&ie=UTF8&hl=" + vLangmap;
    script.src = gurl;                                                                          
    document.getElementsByTagName("head")[0].appendChild(script);
});

// Se utiliza esta función para no tener que cargar cada vez el api desde google maps y ya tenerlo descargado en el cliente
function loadMapscoord(){
    setTimeout("google.load('maps', '2.x', {'callback':initMapcoord});", 100);
}

function initMapcoord(){
    window.onunload=google.maps.Unload;
    mapcoords = new google.maps.Map2(document.getElementById("mapa"));
    mapcoords.enableDoubleClickZoom();
    mapcoords.enableContinuousZoom();
    mapcoords.enableScrollWheelZoom();

    var mapControl = new google.maps.MapTypeControl();
    mapcoords.addControl(mapControl);       
    var zoomControl = new google.maps.LargeMapControl();
    mapcoords.addControl(zoomControl);
    initializeCoords();

//  Tenemos que esperar a cargar el mapa para ocultar la capa y mostrar la info.
    if (origen == "info"){
        parent.cuerpo(origen, 'localizacion');
    }
}

function initializeCoords() {   
    mapcoords.clearOverlays();
    mapcoords.closeInfoWindow();
    mapcoords.setMapType(G_NORMAL_MAP);    
    mapcoords.setCenter(new google.maps.LatLng(0,0),0);
    var bounds = new google.maps.LatLngBounds();    
    var markers = new Array(); //Array de marcadores
    //Obtenemos la estructura de datos    
    var numcoords = datos.split('|');
    for (var x = 0; x < numcoords.length-1; x++){   
        var coord = numcoords[x].split('@')[0]; 
        var lat = coord.split('**')[0];
        var lon = coord.split('**')[1];
        if ((lat != undefined) && (lat != '') && (lon != undefined) && (lon != '')){
            markers.push({latlng: new google.maps.LatLng( parseFloat( lat ), parseFloat( lon ) ), name: numcoords[x].split('@')[1]} );
        }
    }
    //creamos los distintos marcadores y los asociamos al mapa
    for (var z in markers){
        marker = createMarker(markers[z]);
        mapcoords.addOverlay(marker);       
    }

    //Calculamos el centro y zoom adecuados para el mapcoords
    for (var i in markers){
        bounds.extend(markers[i].latlng);
    } 
    mapcoords.setCenter(bounds.getCenter(), mapcoords.getBoundsZoomLevel(bounds) - 7);

    if (origen == "imprimir"){
        setTimeout("parent.imprime();",300);
    }
}  

</script>

问题是我有地图,一切正常,但我没有变焦控制滑块,我需要它。您可以看到var zoomControl = new google.maps.LargeMapControl();的行,我知道它应该有效,并显示滑块,但“au contrair”,两个按钮,放大和缩小,在一起,它们之间没有滑块。 / p>

请......,有谁能告诉我如何解决它?或者我做错了什么?

提前多多感谢。

0 个答案:

没有答案