 var map;
      var posicao;
      var gicons = [];
      var directionsPanel;
      var directions;
    function load() {
          map = new GMap(document.getElementById("map"));
          var zoomHTML = "<center>";
          GDownloadUrl("data.xml", mostraMapa);
      }
              function zoomCtl(lvl)
              {
                    map.zoomTo(lvl);
                    /*
                    for(var i=0; i < 18; i++){
                      document.images['z'+i].src = "images/"+images_folder+"/ctlZoomNotch."+images_extension;
                    }
                    document.images['z'+lvl].src = "images/"+images_folder+"/ctlZoomSel."+images_extension;
                  */
              }
        function validar_localidade(end1,end2)
        {
          var validade
            if (end1== "") {
              alert("Preencher os endereços!");
              return;
            }
            else if(end2=="")
              {
                 alert("Preencher os endereços !");
                 return;
              }
            else
              {
                      if (geocoder)
                          {
                            geocoder.getLatLng(end1,function(point) {
                                  if (!point) 
                                    {
                                      validade="false";
                                    }
                                    
                                  }
                              );
                            geocoder.getLatLng(end2,function(point) {
                            if (!point) 
                              {
                                validade="false";
                              }    
                              }
                              );
                          }    
                  
                          if(validade=="false")
                            {
                              alert("Endereço não encontrado");
                            }
                            else
                            {
                                                  alert("a validade é"+ validade)
                                rotear(end1,end2);
                            }
            }
            }
function rotear(end1, end2) {
	map.clearOverlays();
	directionsPanel = document.getElementById("my_textual_div");
  directions = new GDirections(map, directionsPanel);
	var s = "from: " + end1 + " to: " + end2;
	directions.load(s, {locale:"pt"});

}      
      
       //função que define a direção e manda os pontos da nova posição
              function pan(dir)
                {
                    var bounds = map.getBoundsLatLng();
                    var xCenter = bounds.minX + (bounds.maxX - bounds.minX) / 2;
                    var yCenter = bounds.minY + (bounds.maxY - bounds.minY) / 2;
                    if(dir=="north") map.recenterOrPanToLatLng(new GPoint(xCenter, bounds.maxY));
                    if(dir=="east")  map.recenterOrPanToLatLng(new GPoint(bounds.maxX, yCenter));
                    if(dir=="south") map.recenterOrPanToLatLng(new GPoint(xCenter, bounds.minY));
                    if(dir=="west")  map.recenterOrPanToLatLng(new GPoint(bounds.minX, yCenter));
                }

      function mostraMapa(data, responseCode) {
          var xml = GXml.parse(data);
          var ponto = xml.documentElement.getElementsByTagName("logradouro");
          for(var i=0;i<ponto.length;i++) {
            lat=ponto[i].getAttribute("lat");
            lng=ponto[i].getAttribute("lng");
            endereco=ponto[i].getAttribute("endereco");
            empresa=ponto[i].getAttribute("empresa");
            adicional=ponto[i].getAttribute("adicional");
            tel=ponto[i].getAttribute("tel");
            cel=ponto[i].getAttribute("cel");
            icone=ponto[i].getAttribute("img");
            extensao=ponto[i].getAttribute("img_tipo")
			img_adicional=ponto[i].getAttribute("img_add")
            img_adicional_tipo=ponto[i].getAttribute("img_add_tipo")
            msg="<table class='body'><tr><td align='center'><img src="+img_adicional+img_adicional_tipo+" style='filter:alpha(opacity=90);-moz-opacity:.90;opacity:.90; '></img></center></td><tr><td><b>" + empresa + "</b></td></tr><tr><td>" + adicional + "</td></tr><tr><td>" + endereco + "</td></tr><tr><td>" + "tel: " + tel + "    -    " + "cel: " + cel + "</td></tr></table>"; //memsagem q será emitida no evento on-click                    
            var point = new GLatLng(lat,lng);
            if (i==0) {
              map.setCenter(point, 14, G_MAP_TYPE);  //centralizando e definindo o tipo de visualização
            }
            mostraPonto(lat, lng, msg, icone, i);  
          }
          lerReferencia(xml)
      }
    function lerReferencia(dados)
      {
       var ponto = dados.documentElement.getElementsByTagName("referencia");
       for(var i=0;i<ponto.length;i++)
        {
          lat=ponto[i].getAttribute("lat");
          lng=ponto[i].getAttribute("lng");
          descricao=ponto[i].getAttribute("descricao");
          icone=ponto[i].getAttribute("img");
          extensao=ponto[i].getAttribute("img_tipo")
          msg="<br><label class='body' align='left'><center><b>"+descricao+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></center></label>"
          mostraReferencia(lat,lng,msg,icone)
        }
      }
        
    function mostraReferencia(lat,lng,msg,icone)
      {
        seleciona_icone()
        var point= new GLatLng(lat,lng);
         var marker = new GMarker(point,{icon: gicons[icone]});
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(msg);
        } );
         
        map.addOverlay(marker);
      }
        function mostraPonto(lat, lng, msg, icone, indice) {
      //criando marcador
      seleciona_icone();
      var point = new GLatLng(lat,lng);
      var marker = new GMarker(point,{icon: gicons[icone]});
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(msg);
      } );
      map.addOverlay(marker);
      if (indice==0) {
        marker.openInfoWindowHtml(msg);
      }      
        }
    
    function seleciona_icone() {
      // adicionando o icone
      gicons[icone] = new GIcon();
      gicons[icone].image = "icones/"+icone+extensao;
      gicons[icone].shadow = "icones/shadow.PNG";
      //gicons[icone].iconSize = new GSize(16, 24);
      gicons[icone].shadowSize = new GSize(24, 24);
      gicons[icone].iconAnchor = new GPoint(8, 24);
      gicons[icone].infoWindowAnchor = new GPoint(8, 24);
    }
          /*  função responsavel por editar e definir um novo controle de zoom */ 
          

            function TextualZoomControl() { 
              }
            TextualZoomControl.prototype = new GControl();
            TextualZoomControl.prototype.initialize = function(map) {
            var container = document.createElement("div");
            var zoomInDiv = document.createElement("div");
            this.setButtonStyle_(zoomInDiv);
            container.appendChild(zoomInDiv);
            zoomInDiv.appendChild(document.createTextNode("Aproximar"));
            GEvent.addDomListener(zoomInDiv, "click", function() {
              map.zoomIn();
            });
            var zoomOutDiv = document.createElement("div");
            this.setButtonStyle_(zoomOutDiv);
            container.appendChild(zoomOutDiv);
            zoomOutDiv.appendChild(document.createTextNode("Afastar"));
            GEvent.addDomListener(zoomOutDiv, "click", function() {
              map.zoomOut();
            });
            map.getContainer().appendChild(container);
            return container;
          }
          TextualZoomControl.prototype.getDefaultPosition = function() {
            return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
          }
          function verificar_zoom()
            {
              
               var zoom = map.getZoom(); 
               if(zoom<18)
                {
                  zoomCtl(map.getZoomLevel() - 1)
                }
            }
          function mapa_center()
            {
                   GDownloadUrl("data.xml",centralizar_mapa);
            }
            function centralizar_mapa(data,responseCode)
              {
                 //centraliza o mapa na posiçãio inicial
              xml = GXml.parse(data);
              var tipo_mapa=document.getElementById("mapa_tipo").value;
              var ponto = xml.documentElement.getElementsByTagName("logradouro");
               for(var i=0;i<ponto.length;i++) 
                {
                  lat=ponto[i].getAttribute("lat");
                  lng=ponto[i].getAttribute("lng");
                   if (i==0)
                   {
                       var point = new GLatLng(lat,lng);
                    }
                }
                      if(tipo_mapa=="G_NORMAL_MAP")
                          {
                            map.setCenter(point, 14,G_NORMAL_MAP);
                          }
                      if(tipo_mapa=="G_SATELLITE_MAP")
                          {
                            map.setCenter(point, 14,G_SATELLITE_MAP);
                          }      
                     if(tipo_mapa=="G_HYBRID_MAP")
                          {
                            map.setCenter(point, 14,G_HYBRID_MAP);
                          }                     
                     if(tipo_mapa=="")
                          {
                            map.setCenter(point, 14,G_NORMAL_MAP);
                          }        
              }
          //propriedade css dos botoes
          TextualZoomControl.prototype.setButtonStyle_ = function(button) {
            button.style.textDecoration = "";
            button.style.color = "336699";
            button.style.backgroundColor = "white";
            button.style.font = "small verdana";
            button.style.border = "1px solid black";
            button.style.padding = "1px";
            button.style.marginBottom = "3px";
            button.style.textAlign = "center";
            button.style.width = "6em";
            button.style.cursor = "pointer";
          }
     /*   fim da função de definição de controle de zoom */
     <!--    -->
     function display_ativo()
      {
            //alterando a posição da barra de acordo com o div do mapa
            var mapa_left=parseInt(document.getElementById("map").style.left);
            var mapa_tam=parseInt(document.getElementById("map").style.width);
            var map_top=parseInt(document.getElementById("map").style.top);
            var opc_tam=parseInt(document.getElementById("opc").style.width);
            //posicionando
            posicao_opc=(mapa_tam+mapa_left);
            posicao_opc=posicao_opc-opc_tam;
            document.getElementById("opc").style.left=posicao_opc;
            document.getElementById("img_tipo").style.left=posicao_opc;
            document.getElementById("movimentacao").style.left=posicao_opc + 10; 
            document.getElementById("zoom").style.left=posicao_opc+12;
            //alinhando o top
            document.getElementById("opc").style.top=map_top;
      }
      function display_desativado()
      {
            var mapa_left=parseInt(document.getElementById("map").style.left);
            var mapa_tam=parseInt(document.getElementById("map").style.width);
            var opc_tam=parseInt(document.getElementById("opc").style.width);
            posicao_opc=(mapa_left+mapa_tam);
            posicao_opc=posicao_opc-10;
            document.getElementById("opc").style.left=posicao_opc;
            document.getElementById("mostrar").style.left=posicao_opc-73;

      }

       function estado_ativo()
        {
      
          //alterando o tamanho do div
            document.getElementById("opc").style.width="120px";
             display_ativo(); 
            //document.getElementById("opc").style.left=posicao_opc
            //alterando o display do zoom
            document.getElementById("tbl_zoom").style.display='block';
          //alterando o display das imagens
            document.getElementById("tbl_movimentacao").style.display='block'
            //alterando o display dos tipos
            document.getElementById("tbl_tipo").style.display='block';
                   //alterando o display da seta
            document.getElementById("tbl_mostrar").style.display='none';
             
            //---
        }
           function estado_inativo()
        {
          //alterando o tamanho do div
            document.getElementById("opc").style.width="10px";
             display_desativado();
          //alterando o display do zoom
            document.getElementById("tbl_zoom").style.display='none';
          //alterando o display das imagens
          document.getElementById("tbl_movimentacao").style.display='none'
            //alterando o display dos tipos
            document.getElementById("tbl_tipo").style.display='none';
             //alterando o display da seta
            document.getElementById("tbl_mostrar").style.display='block';
        }
        function seleciona_tipo(img)
          {
            if(img=="ruas")
              {
                document.getElementById("img_rua").src="img_botoes/ruas_sel.png";
                document.getElementById("img_satelite").src="img_botoes/satelite.png";
                document.getElementById("img_ambos").src="img_botoes/ambos.png";
                document.getElementById("mapa_tipo").value="G_NORMAL_MAP"
              }
             if(img=="satelite")
              {
                document.getElementById("img_satelite").src="img_botoes/satelite_sel.png";
                document.getElementById("img_rua").src="img_botoes/ruas.png";
                document.getElementById("img_ambos").src="img_botoes/ambos.png";
                document.getElementById("mapa_tipo").value="G_SATELLITE_MAP"
              }
                 if(img=="ambos")
              {
                document.getElementById("img_ambos").src="img_botoes/ambos_sel.png";
                document.getElementById("img_rua").src="img_botoes/ruas.png";
                document.getElementById("img_satelite").src="img_botoes/satelite.png";
                document.getElementById("mapa_tipo").value="G_HYBRID_MAP"
              }
            
          
          }
        function imagem_over(img)
          {
            if(img=="ruas")
              {
              document.getElementById("img_rua").src="img_botoes/ruas_sel.png";
              }
            if(img=="satelite")
              {
              document.getElementById("img_satelite").src="img_botoes/satelite_sel.png";
              }  
             if(img=="ambos")
              {
              document.getElementById("img_ambos").src="img_botoes/ambos_sel.png";
              }
          }              
        function imagem_out(img)
          {
             if(img=="ruas")
              {
              document.getElementById("img_rua").src="img_botoes/ruas.png";
              }
            if(img=="satelite")
              {
              document.getElementById("img_satelite").src="img_botoes/satelite.png";
              }  
             if(img=="ambos")
              {
              document.getElementById("img_ambos").src="img_botoes/ambos.png";
              }      
          
          }