Advertisement
rogerin

Untitled

Sep 9th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (navigator.geolocation) {
  2.         navigator.geolocation.getCurrentPosition(showPosition);
  3.     }
  4.     function showPosition(position) {
  5.         var  lat = position.coords.latitude;
  6.         var lon = position.coords.longitude;
  7.  
  8.         jQuery(function(){
  9.        
  10.         <?php if ( have_posts() ) : ?>
  11.  
  12.         <?php while ( have_posts() ) : the_post(); ?>
  13.  
  14.             <?php
  15.             if ( mb_strlen( get_the_title() ) >= 75 ) $ttitulo =  mb_substr( get_the_title(), 0, 75 ) . '...'; else $ttitulo = get_the_title();
  16.             $tID = get_the_ID();
  17.             ?>
  18.             var conteudo<?php echo $tID; ?> = '<div id="balao">'+
  19.          '<img src="/thumbs.php?arquivo=guia_anuncios/1584/_201020140843300.jpg&altura=90&largura=90" />'+
  20.                                 '<p><strong>$ttitulo</strong></p><br/>'+
  21.                                 '<p>Fone: (88) 3111-1014</p>'+
  22.                                 ''+
  23.                                 '</div>';
  24.  
  25.         <?php endwhile; ?>
  26.  
  27.         <?php endif; ?>
  28.        
  29.                                    
  30. // inicializa plugin gmap3           
  31. jQuery("#mapa").gmap3({
  32.     map:
  33.     {
  34.       // local padrão onde o mapa irá aparecer quando carregado
  35.       address:[lat, lon],
  36.       options:
  37.       {
  38.         // zoom inicial (aproximação)  
  39.         zoom:6,
  40.         // opções de controle do tipo do mapa (ruas, satélite, etc).
  41.         // mapTypeControl como FALSE não mostra opções
  42.         mapTypeControl: true,
  43.         mapTypeControlOptions:
  44.         {
  45.           // define controles no formato dropdown
  46.           style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
  47.         },
  48.         // permite navegar com o botão scroll do mouse
  49.         scrollwheel: true,
  50.         // mostra bonequinho para habilitar modo streetview
  51.         streetViewControl: true
  52.       }
  53.     },
  54.     // marcadores
  55.     marker:{
  56.     // valores (localização dos marcadores)  
  57.     values:[
  58.     // pode ser uma latitude/longitude
  59.       //{latLng:[-20.488773,-54.619217], data:conteudoCampoGrande, options:{icon:"imagens/marcador.png", shadow:"imagens/marcador_sombra.png"}},
  60.     // podem ser palavras-chave ou endereços
  61.     <?php if ( have_posts() ) : ?>
  62.  
  63.         <?php while ( have_posts() ) : the_post(); ?>
  64.  
  65.             <?php
  66.             if ( mb_strlen( get_the_title() ) >= 75 ) $ttitulo =  mb_substr( get_the_title(), 0, 75 ) . '...'; else $ttitulo = get_the_title();
  67.             $tID = $post->ID;
  68.             $tLatitude = get_post_meta($post->ID, 'cp_latitude', true);
  69.             $tLongitude = get_post_meta($post->ID, 'cp_longitude', true);
  70.             ?>
  71.              {latLng:[<?php echo $tLatitude; ?>,<?php echo $tLongitude; ?>], data:conteudo<?php echo $tID; ?>, options:{icon:"<?php echo get_stylesheet_directory_uri(); ?>/images/marcador.png", shadow:"<?php echo get_stylesheet_directory_uri(); ?>/imagens/marcador_sombra.png"}},
  72.         <?php endwhile; ?>
  73.  
  74.         <?php endif; ?>
  75.      
  76.     ],
  77.     // evita reposicionar marcadores
  78.     options:{
  79.       draggable: false
  80.     },
  81.     // listener de eventos
  82.     events:{
  83.       // evento de clique      
  84.       click: function(marker, event, context)
  85.       {
  86.         // cria a infowindow
  87.         var map = jQuery(this).gmap3("get"),
  88.           infowindow = jQuery(this).gmap3({get:{name:"infowindow"}});
  89.        
  90.        //
  91.         if (infowindow)
  92.         {
  93.           infowindow.open(map, marker);
  94.           infowindow.setContent(context.data);
  95.         } else {
  96.           jQuery(this).gmap3({
  97.             infowindow:
  98.             {
  99.               anchor:marker,
  100.               options:{content: context.data}
  101.             }
  102.           });
  103.         }
  104.       }
  105.     }
  106.   }
  107.   });
  108. });
  109.  
  110.  
  111.  
  112.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement