Adicionar Marcador em Mapa (Google ou Bing) - Richfaces

1 resposta
G

Boas pessoal,

Estou a desenvolver uma aplicação em que uma das funcionalidade é enviar as coordenadas e ela mostra um mapa. Neste momento estou a usar o richfaces para fazer isso, com virtualEarth, mas se alguém souber como fazer o que eu quero com Google maps também dá.

O meu problema está em adicionar o marcador ao Mapa, ou seja, eu queria que ele pusesse um marcados no mapa.

O meu código está assim:

<f:view contentType="text/html"></f:view> <rich:virtualEarth id="gm" style=" width:500px; display:block;" lat="#{arruamentoBean.arruamentoSelecionado.coordenadas.latitude_convertida}" lng="#{arruamentoBean.arruamentoSelecionado.coordenadas.longitude_convertida}" dashboardSize="Normal" zoom="18" mapStyle="Hybrid" var="map"/>

Já estive a ver este site, http://msdn.microsoft.com/pt-pt/library/bb877865.aspx , mas não faço a minima ideia como usar aquilo com o meu código. Alguém me pode ajudar?

Cumprimentos,

1 Resposta

G

Já consegui fazer alguma coisa. Agora eu pretendo mandar as coordenadas que estão no meu BEAN para o javascript. Neste momento ele está com coordenadas por defeito, como posso alterar o meu código para fazer isso?

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>

      <script type="text/javascript">
         var map = null;

         var LA = new VELatLong(41.3579067, -8.4435283);

         var pinPoint = null;
         var pinPixel = null;
                  
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap(LA, 14, VEMapStyle.Hybrid, false, VEMapMode.Mode2D, true, 1);

            AddPin();
         }

         function getInfo()
         {
            var info;

            if (map.IsBirdseyeAvailable())
            {
                var be = map.GetBirdseyeScene();

                info  = "ID: "          + be.GetID() + "\n";
                info += "orientation: " + be.GetOrientation()+ "\n";
                info += "height: "      + be.GetHeight() + "\n";
                info += "width: "       + be.GetWidth() + "\n";

                var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

                info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

                // Check to see if the current birdseye view contains the pushpin pixel point.
                info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " + 
                        be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";
                
                // Check to see if the current view contains the pushpin LatLong.
                info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";
                
                // This method may return null, depending on the selected view and map style.
                info += "latlong: " + map.PixelToLatLong(pixel);

                alert(info);
            }
            else
            {
                var center = map.GetCenter();

                info  = "Zoom level:\t" + map.GetZoomLevel() + "\n";
                info += "Latitude:\t"   + center.Latitude    + "\n";
                info += "Longitude:\t"  + center.Longitude;

                alert(info);
            }
         }
         
         function AddPin()
         {
            // Add a new pushpin to the center of the map.
            pinPoint = map.GetCenter();
            pinPixel = map.LatLongToPixel(pinPoint);
            map.AddPushpin(pinPoint);
         }
      </script>
      
  <f:view contentType="text/html"></f:view>
  <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
       <input id="btnGetInfo" type="button" value="Get Scene Information" name="getinfo" onclick="getInfo();"/>
       <a4j:commandButton value="mapa" onclick="GetMap();" />
Criado 12 de abril de 2013
Ultima resposta 12 de abr. de 2013
Respostas 1
Participantes 1