Google maps api 3 自定义控件';没有显示

Google maps api 3 自定义控件';没有显示,google-maps-api-3,Google Maps Api 3,我正在移植一个v2到v3的应用程序映射,有一件事我无法开始工作。 我有一个自定义控件,没有显示任何内容。 我不确定问题出在哪里,所以我会发布所有我认为相关的东西,如果需要的话,再问一些 以下是构造函数: 注意,仍然有来自v2的注释 function Semaforo(){} //Semaforo.prototype = new GControl(); Semaforo.prototype.semaforo = document.cr

我正在移植一个v2到v3的应用程序映射,有一件事我无法开始工作。 我有一个自定义控件,没有显示任何内容。 我不确定问题出在哪里,所以我会发布所有我认为相关的东西,如果需要的话,再问一些 以下是构造函数:

注意,仍然有来自v2的注释

function Semaforo(){}
//Semaforo.prototype = new GControl();                                
Semaforo.prototype.semaforo = document.createElement("img");
Semaforo.prototype.initialize = function(map) {
    var container = document.createElement("div");
    var semaforoDiv = document.createElement("img");

    semaforoDiv.setAttribute("class", "semaforo");
    this.setButtonStyle_(semaforoDiv);
    this.semaforo = semaforoDiv;
    container.appendChild(semaforoDiv);
    semaforoDiv.setAttribute("src", "img/semaforo_rojo.png");
    map.getContainer().appendChild(container);      
    return container;
}
以及一些方法:

Semaforo.prototype.setColor = function(color, mapa) {
  this.semaforo.setAttribute("src", "img/semaforo_" + color + ".png");
  if(color == "rojo")
  {
    this.semaforo.setAttribute("alt", "Tr�fico dif�cil");
        this.semaforo.setAttribute("title", "Tr�fico dif�cil");
  }
  else if(color == "ambar")
  {
    this.semaforo.setAttribute("alt", "Tr�fico irregular");
        this.semaforo.setAttribute("title", "Tr�fico irregular");
  }
  else
  {
    this.semaforo.setAttribute("alt", "Tr�fico fluido");
        this.semaforo.setAttribute("title", "Tr�fico fluido");
  }
}
Semaforo.prototype.getDefaultPosition = function() {
    return new google.maps.ControlPosition.TOP_RIGHT;
    //return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0));             //TO DO
}
Semaforo.prototype.setButtonStyle_ = function(button) {
    button.style.width = "19px";
    button.style.height = "53px";
    button.style.cursor = "default";
}

function getIconoSemaforo(color, mapa){
    var semaforo = new Semaforo();
    semaforo.setColor(color, mapa);
    return semaforo;
}
这里是我调用构造函数并尝试生成/显示控件的地方

function incluirDatosXML()
{
    for (var i=0; i<ciudadDato.length; i++)
    {           
        if (i==0)
        {
            if (semaforoDato[i]!="no")
            {
                var semaforo = new Semaforo(this.semaforo, map[1]);

                map[1].controls[google.maps.ControlPosition.TOP_RIGHT].push(this.semaforo);
                //map[1].addControl(semaforo);
                semaforo.setColor(semaforoDato[i], map[1]); 

                /*google.maps.event.addListener(map[1], 'idle', function() {
                    map[1].controls[google.maps.ControlPosition.TOP_RIGHT].push(this.semaforo);
                  });*/
            }           
        }           
        if (i==1)
        {
            if (semaforoDato[i]!="no")
            {
                var semaforo = new Semaforo(this.semaforo, map[2]);
                //map[2].addControl(semaforo);
                semaforo.setColor(semaforoDato[i], map[2]);
                //map[2].controls[google.maps.ControlPoistion.TOP_RIGHT].push(this.semaforo);
            }
        }           
        if (i==2)
        {
            if (semaforoDato[i]!="no")
            {
                var semaforo = new Semaforo(this.semaforo, map[3]);
                //map[3].addControl(semaforo);
                semaforo.setColor(semaforoDato[i], map[3]);
                //map[3].controls[google.maps.ControlPoistion.TOP_RIGHT].push(this.semaforo);
            }
        }               
        $("#clima"+(i+1)).attr("class",climaDato[i]+"_mini");           
        $("#temp"+(i+1)).html(temperaturadDato[i]+"&deg;");
    }
}
函数includerDatasXML()
{

对于(var i=0;iMaybe),您应该为变量使用英文名称,这样代码更容易理解。