elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web (Moderador: #!drvy)
| | |-+  Ayuda con markers en Google Maps V2
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con markers en Google Maps V2  (Leído 2,351 veces)
ayon.g

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Ayuda con markers en Google Maps V2
« en: 10 Abril 2012, 06:32 am »

Hola, estoy usando un mapa de google V2 para poner los markers desde una base de datos este es el código que ocupo:
Código:
 //<![CDATA[

    var iconBlue = new GIcon();
    iconBlue.image = 'mm_20_blue.png';
    iconBlue.shadow = 'mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon();
    iconRed.image = 'mm_20_red.png';
    iconRed.shadow = 'mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["restaurant"] = iconBlue;
    customIcons["bar"] = iconRed;

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(-27.366667, -70.333333), 5);

        // Change this depending on the name of your PHP file
        GDownloadUrl("phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, type);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, name, address, type) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>Volcan " + name + "</b> <br/>" + "<p>Dispone de la siguiente infomacion:</p>" + address + "<li><a>Informacion General</a></li><li>Informacion Eruptiva Moderna</li><li>Vulcanologia Fisica</li><li>Geoquimica de Rocas</li><li>Geoquimica de Fluidos</li><li>Edades</li><li>Mapa geoligico</li><br><br/>";
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    //]]>
El problema es que necesito que el nombre se vea en todo momento, y la única solución que encontré es este código que genera un popup dentro del mapa, pero no sé cómo unirlos, este es el código del mapa con popup:
Código:
    <script type="text/javascript">
    document.write('<script type="text/javascript" src="../src/popupmarker'+(document.location.search.indexOf('packed')>-1?'_packed':'')+'.js"><'+'/script>');
  </script>
    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(35.681382, 139.766084), 1);
        
        var opts = {
          text : "Hello! I'm a PopupMarker."
        };
        
        var marker = new PopupMarker(new GLatLng(35.681382, 139.766084), opts);
        map.addOverlay(marker);
      }
    }

    </script>
Lo saque desde:
http://gmaps-utility-library-dev.googlecode.com/svn/tags/popupmarker/1.1/examples/simple.html
http://gmaps-utility-library-dev.googlecode.com/svn/tags/popupmarker/

No tengo mucho conocimiento pero lo necesito o si tienen otra alternativa para ponerle el nombre como salen los marcadores en el google earth, muchas gracias de antemano.
Ayôn


« Última modificación: 10 Abril 2012, 06:36 am por ayon.g » En línea

Shell Root
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.723


<3


Ver Perfil WWW
Re: Ayuda con markers en Google Maps V2
« Respuesta #1 en: 11 Abril 2012, 00:30 am »

Pero si ya tienes el ejemplo, sólo necesitas mirar el código fuente, no te parece?


En línea

Por eso no duermo, por si tras mi ventana hay un cuervo. Cuelgo de hilos sueltos sabiendo que hay veneno en el aire.
ayon.g

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: Ayuda con markers en Google Maps V2
« Respuesta #2 en: 11 Abril 2012, 07:01 am »

Hola, gracias por responder, uní el código y me quedo esto:
Código:
               <script type="text/javascript">
    document.write('<script type="text/javascript" src="popupmarker'+(document.location.search.indexOf('packed')>-1?'_packed':'')+'.js"><'+'/script>');
  </script>

<script type="text/javascript">

    //<![CDATA[

    var iconBlue = new GIcon();
    iconBlue.image = 'mm_20_blue.png';
    iconBlue.shadow = 'mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon();
    iconRed.image = 'mm_20_red.png';
    iconRed.shadow = 'mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["restaurant"] = iconBlue;
    customIcons["bar"] = iconRed;

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(-27.366667, -70.333333), 5);

        // Change this depending on the name of your PHP file
        GDownloadUrl("phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
 var opts = {
          text : "Volcan " + name
        };
       
        var marker = new PopupMarker(new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))), opts);
        map.addOverlay(marker);
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");

            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));

            var marker = createMarker(point, name, address, type);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, name, address, type) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>Volcan " + name + "</b> <br/>" + "<p>Dispone de la siguiente infomacion:</p>" + address + "<li><a>Informacion General</a></li><li>Informacion Eruptiva Moderna</li><li>Vulcanologia Fisica</li><li>Geoquimica de Rocas</li><li>Geoquimica de Fluidos</li><li>Edades</li><li>Mapa geoligico</li><br><br/>";
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    //]]>
  </script>



El problema que tengo ahora es q el marcador que se genera cuando hago el popupmarker no deja que se despliegue la ventana de infowindows (intente poniéndolo antes de que se generara el otro marcador pero solo aparece atrás el rojo (como se ve en la imagen), pero de todas maneras no abre el infowindows) como podría eliminar el icono del otro marcador pero manteniendo el globo con el nombre. Muchas gracias
Ayôn
« Última modificación: 11 Abril 2012, 07:29 am por ayon.g » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Google Maps en 3D
Noticias
wolfbcn 0 2,050 Último mensaje 27 Abril 2010, 21:28 pm
por wolfbcn
google maps, rutas y php.. AYUDA!!!!
Desarrollo Web
Zeroql 0 2,847 Último mensaje 4 Mayo 2011, 00:56 am
por Zeroql
Google cierra el grifo gratuito al acceso intensivo a la API de Google Maps
Noticias
wolfbcn 2 3,537 Último mensaje 28 Octubre 2011, 13:53 pm
por [u]nsigned
[AYUDA] Enviar captura de google maps por email desde PHP « 1 2 »
PHP
Graphixx 13 6,123 Último mensaje 24 Septiembre 2014, 05:23 am
por Graphixx
Pintar Markers con una base de datos existente en SQL
Desarrollo Web
Sandala 2 1,909 Último mensaje 11 Abril 2016, 06:17 am
por gathosdeath
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines