Advertisement
iamdangavin

New Markers

Aug 25th, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. /* I am running this in the body of the template right after my
  3.  * $result = = $wpdb->get_results();
  4.  */
  5. ?>
  6.  
  7. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  8. <script type="text/javascript">
  9.       (function() {
  10.         window.onload = function(){
  11.             // Creating a LatLng object containing the coordinate for the center of the map  
  12.           var latlng = new google.maps.LatLng(31.353636941500987, -85.1220703125);  
  13.           // Creating an object literal containing the properties we want to pass to the map  
  14.           var options = {  
  15.             zoom: 6,
  16.             center: latlng,
  17.             mapTypeId: google.maps.MapTypeId.ROADMAP
  18.           };  
  19.           // Calling the constructor, thereby initializing the map  
  20.           var map = new google.maps.Map(document.getElementById('map'), options);  
  21.          
  22. <?php
  23. foreach($result as $row) {
  24.     // These are my rows I am looking for right now.
  25.     $lng = $row['Latitude'];
  26.     $lat = $row['Longitude'];
  27.     $name = $row['CUName'];
  28.     $address = $row['Address'];
  29.     ?>
  30.     // Creating a marker and positioning it on the map  
  31.     new google.maps.Marker({  
  32.         position: new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>),  
  33.         map: map,
  34.         title: <?php echo $name; ?>,
  35.         address: <?php echo $address; ?>,
  36.         clickable: true
  37.     });
  38.     <?php
  39. }
  40. ?>     
  41. }
  42.       })();
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement