Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* I am running this in the body of the template right after my
- * $result = = $wpdb->get_results();
- */
- ?>
- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
- <script type="text/javascript">
- (function() {
- window.onload = function(){
- // Creating a LatLng object containing the coordinate for the center of the map
- var latlng = new google.maps.LatLng(31.353636941500987, -85.1220703125);
- // Creating an object literal containing the properties we want to pass to the map
- var options = {
- zoom: 6,
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- // Calling the constructor, thereby initializing the map
- var map = new google.maps.Map(document.getElementById('map'), options);
- <?php
- foreach($result as $row) {
- // These are my rows I am looking for right now.
- $lng = $row['Latitude'];
- $lat = $row['Longitude'];
- $name = $row['CUName'];
- $address = $row['Address'];
- ?>
- // Creating a marker and positioning it on the map
- new google.maps.Marker({
- position: new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>),
- map: map,
- title: <?php echo $name; ?>,
- address: <?php echo $address; ?>,
- clickable: true
- });
- <?php
- }
- ?>
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement