Guest User

Untitled

a guest
Dec 30th, 2011
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.47 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5.     <head>
  6.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7.         <title>Frum London Directory Map</title>
  8.         <link rel="stylesheet" type="text/css" href="style.css" />
  9.         <link rel="stylesheet" type="text/css" href="menu/menu_style.css" />
  10.  
  11.         <!--[if IE]>
  12.         <link rel="stylesheet" type="text/css" href="menu/ie.css" />
  13.         <![endif]-->
  14.  
  15.         <style type="text/css">#map_canvas {
  16.             width:  100%;
  17.             height: 500px;
  18.         }</style>
  19.     </head>
  20.  
  21.     <body bgcolor="#006" onload="initialize()">
  22.         <!-- Title Logo -->
  23.  
  24.         <div align="center">
  25.             <img src="logo.png" width="984" height="76" />
  26.         </div>
  27.  
  28.         <div class="nav">
  29.             <div class="table">
  30.                 <ul class="select">
  31.                     <li><a href="" target="_self"><b>Kosher</b></a>
  32.                         <div class="select_sub">
  33.                             <ul class="sub">
  34.                                 <li><a href="" target="_self">Bakeries</a></li>
  35.                                 <li><a href="" target="_self">Cafes</a></li>
  36.                                 <li><a href="" target="_self">Restaurants</a></li>
  37.                                 <li><a href="" target="_self">Groceries</a></li>
  38.                                 <li><a href="" target="_self">Confectionary</a></li>
  39.                             </ul>
  40.                         </div>
  41.                     </li>
  42.                 </ul>
  43.  
  44.                 <ul class="select">
  45.                     <li><a href="" target="_self"><b>Religious</b></a>
  46.                         <div class="select_sub">
  47.                             <ul class="sub">
  48.                                 <li><a href="" target="_self">Shuls & Synagogues</a></li>
  49.                                 <li><a href="" target="_self">Tefillos</a></li>
  50.                                 <li><a href="" target="_self">Mincha</a></li>
  51.                             </ul>
  52.                         </div>
  53.                     </li>
  54.                 </ul>
  55.  
  56.                 <ul class="select">
  57.                     <li><a href="" target="_self"><b>Travel</b></a>
  58.                         <div class="select_sub">
  59.                             <ul class="sub">
  60.                                 <li><a href="" target="_self">Hotels</a></li>
  61.                                 <li><a href="" target="_self">Inns</a></li>
  62.                                 <li><a href="" target="_self">Tours</a></li>
  63.                                 <li><a href="" target="_self">Flights</a></li>
  64.                                 <li><a href="" target="_self">Taxis</a></li>
  65.                             </ul>
  66.                         </div>
  67.                     </li>
  68.                 </ul>
  69.  
  70.                 <ul class="select">
  71.                     <li><a href="" target="_self"><b>Business</b></a>
  72.                         <div class="select_sub">
  73.                             <ul class="sub">
  74.                                 <li><a href="" target="_self">Financial Services</a></li>
  75.                                 <li><a href="" target="_self">Property & Accomodation</a></li>
  76.                                 <li><a href="" target="_self">Precious Stones & Metals</a></li>
  77.                                 <li><a href="" target="_self">Information Technology</a></li>
  78.                                 <li><a href="" target="_self">Insurance</a></li>
  79.                             </ul>
  80.                         </div>
  81.                     </li>
  82.                 </ul>
  83.             </div>
  84.         </div>
  85.  
  86.         <div align="center">
  87.             <table width="100%" height="35" align="center" bgcolor="#000">
  88.                 <tr>
  89.                     <td>
  90.                         <div class="menu">
  91.                             <?php
  92.                             // display below statement for informational purposes only, will later integrate conditions.
  93.                             print "....Coordinates Loaded....";
  94.                             ?>
  95.                         </div>
  96.                     </td>
  97.                 </tr>
  98.             </table>
  99.         </div>
  100.  
  101.         <!-- map start -->
  102.  
  103.         <div class="menu2">
  104.             <?php
  105.             // kosher_london_bakeries.php code
  106.             ini_set('display_errors', 1);
  107.             error_reporting(E_ALL);
  108.  
  109.             $username = "***";
  110.             $password = "***";
  111.             $hostname = "***";
  112.             $connect = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
  113.  
  114.             $selected = mysql_select_db("datanalystcouk_434850_db1", $connect) or die("Could not select datanalystcouk_434850_db1");
  115.        
  116.             // run query on listings table returning matching category and areagroup
  117.             $result1 = mysql_query("
  118.                 SELECT CategoryID1, Company, Latitude, Longitude, AreaGroup, Streetno, Address, Locality, City, PostalCode, PhoneNumber
  119.                 FROM DirectoryListings
  120.                 WHERE CategoryID1 ='420' AND AreaGroup = 'London' AND Latitude <> 0
  121.                 ORDER BY Company ASC
  122.             ");
  123.  
  124.             /*
  125.              * Changes by Werelds:
  126.              * - Got rid of most variables; wasting time copying values when you can just use them straight up
  127.              * - Got rid of the "counters" - just start from index 0 to keep things consistent
  128.              * - PHP doesn't require an index when setting array values; you can push to an array by using []
  129.              * - Refactored variable names into full names for clarity :P
  130.              */
  131.             $companies = array();
  132.  
  133.             // Simply store each row in an array
  134.             while ($row = mysql_fetch_array($result1)) {
  135.                 $companies[] = $row;
  136.             }
  137.  
  138.             /*
  139.              * At this point $companies looks like this:
  140.              * array(
  141.              *   array(
  142.              *     'Latitude' => xx.xxxxxx,
  143.              *     'Longitude' => xx.xxxxxx,
  144.              *     'Company' => 'Company 1',
  145.              *   ),
  146.              *   array(
  147.              *     'Latitude' => xx.xxxxxx,
  148.              *     'Longitude' => xx.xxxxxx,
  149.              *     'Company' => 'Company 2',
  150.              *   ),
  151.              * )
  152.              *
  153.              * And so on. Note that AreaGroup and all the other fields are also in these arrays of course.
  154.              */
  155.             ?>
  156.         </div>
  157.  
  158.         <div id="map_canvas"></div>
  159.  
  160.         <!-- Footer -->
  161.  
  162.         <div align="center" class="footer">
  163.             Copyright Data Analyst Limited
  164.         </div>
  165.  
  166.         <!--
  167.             Fixed by Werelds: Moved this to the very bottom, as that's customary :)
  168.             Keep JS at the very bottom of document body so that it always loads last.
  169.         -->
  170.         <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  171.         <script type="text/javascript">
  172.             /*
  173.              * Now the awesome part: json_encode will turn the array above into an array of objects
  174.              * An associative array in PHP (like the ones for each row above) becomes an object.
  175.              *
  176.              * This now allows you to actually do all of the JS work in JS.
  177.              * The example array above will now be encoded to the following JSON:
  178.              * [
  179.              *   { "Latitude" => xx.xxxxxx, "Longitude" => xx.xxxxxx, "Company" => "Company 1" },
  180.              *   { "Latitude" => xx.xxxxxx, "Longitude" => xx.xxxxxx, "Company" => "Company 2" },
  181.              * ]
  182.              *
  183.              * This way you can avoid mixing PHP and JS, which is rarely a good idea.
  184.              */
  185.             var companies = <?php echo json_encode($companies); ?>;
  186.             var markers = new Array();
  187.             var map;
  188.  
  189.             var markerClick = function (event) {
  190.                 // Nasty, but we have to do it like this :(
  191.                 for (var i = 0; i < companies.length; i++) {
  192.                     var company = companies[i];
  193.                     var marker_coordinates = new google.maps.LatLng(company.Latitude, company.Longitude);
  194.  
  195.                     // Compare to the clicked LatLng
  196.                     if (marker_coordinates.equals(event.latLng)) {
  197.                         map.setCenter(marker_coordinates);
  198.                         map.setZoom(16);
  199.                        
  200.                         var infowindow = new google.maps.InfoWindow({
  201.       content: '<b>' + company.Company + '</b> <br>' + company.Steetno + '<br>' + company.Address + '<br>' + company.Locality + '<br>' + company.City + '<br>' + company.PostalCode + '<br>' + company.PhoneNumber  + '<br>' + '</b><br>'
  202.       });
  203.                        
  204.                         infowindow.open(map, markers[i]);
  205.                     }
  206.                 }
  207.             };
  208.  
  209.             function initialize() {
  210.                 var myOptions = {
  211.                     zoom: 10,
  212.                     center: new google.maps.LatLng(51.5, -0.18),
  213.                     mapTypeId: google.maps.MapTypeId.ROADMAP
  214.                 };
  215.  
  216.                 map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  217.  
  218.                 // Add each marker
  219.                 for (var i = 0; i < companies.length; i++) {
  220.                     var company = companies[i];
  221.  
  222.                     markers[i] = new google.maps.Marker({
  223.                         position: new google.maps.LatLng(company.Latitude, company.Longitude),
  224.                         title: company.Company,
  225.                         map: map
  226.                     });
  227.  
  228.                     // Don't forget to attach markerClick() to each of them
  229.                     google.maps.event.addListener(markers[i], 'click', markerClick);
  230.                 }
  231.             }
  232.         </script>
  233.     </body>
  234. </html>
Advertisement
Add Comment
Please, Sign In to add comment