Guest User

Untitled

a guest
Sep 3rd, 2011
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <!-- http://huntersandgatherers.jobamatic.com/a/jobs/find-jobs/l-08901 -->
  4.  
  5. <!-- Loads jQuery -->
  6. <script src="http://code.jquery.com/jquery-latest.js"></script>
  7.  
  8. <!-- Bootstrapping The Map Itself -->
  9. <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&region=US"></script>
  10.  
  11. <?PHP
  12.      $scraped_page = file_get_contents("http://huntersandgatherers.jobamatic.com/a/jobs/find-jobs/l-08901");
  13.  
  14.      //scraping location, company name and job title
  15.      $regex_location= '/<td class=\"location\">(.+?)<\/td>/';
  16.       preg_match_all($regex_location,$scraped_page,$scraped_location_data);  
  17.       $regex_company= '/<td class=\"company\">(.+?)<\/td>/';
  18.       preg_match_all($regex_company,$scraped_page,$scraped_company_data);
  19.       $regex_title= "/<td class=\"title\">(.+?)<\/td>/";
  20.       preg_match_all($regex_title,$scraped_page,$scraped_title_data);
  21.      
  22.       //extracting each group of data out of their respective arrays and passing them to the map API
  23.       for($i=0;$i<5;$i++)
  24.       {
  25.        $location = $scraped_location_data[1][$i];
  26.         $url="http://maps.googleapis.com/maps/api/geocode/xml?address=$location&sensor=false";     
  27.         $company_name = $scraped_company_data[1][$i];
  28.         $job_title = $scraped_title_data[1][$i];
  29.         //put a JS function call here?
  30.       }
  31.  
  32.  
  33.      //$job_title = str_replace('','href="http://brando56894.dyndns-blog.com:1085/',$job_title);
  34. ?>
  35.  
  36. <style type="text/css">
  37.     html, body, #map_canvas {margin: 0; padding: 0; height: 100%;}
  38. </style>
  39.  
  40. </head>
  41. <body onLoad="initialize()">
  42.     <script type="text/javascript">
  43.         //Initalizes Map and Places Pins of Job Locations
  44.         function initialize()
  45.         {
  46.             var lat;
  47.             var lng;
  48.             var url = '<?php echo $url;?>';
  49.            
  50.             $.ajax
  51.             ({
  52.                 url: 'proxy2.php?url='+url, type: "GET", dataType: "text", success: function ($data)
  53.                 {
  54.                     $data = $($data);
  55.                     lat = ($data.find('geometry').find('location').find('lat').text());
  56.                     lng = ($data.find('geometry').find('location').find('lng').text());
  57.                     console.log(lat);
  58.                     console.log(lng);
  59.                    
  60.                     var myLatlng = new google.maps.LatLng(lat,lng);
  61.                     var myOptions = {zoom: 6, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP};
  62.                     var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  63.                     var contentString = '<h2><?PHP echo $company_name; ?></h2>';
  64.                     var infowindow = new google.maps.InfoWindow({content: contentString});
  65.                     var marker = new google.maps.Marker({position: myLatlng, map: map, title: 'Job Listings'});
  66.                     google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker);} );
  67.                 }
  68.             });
  69.         }
  70.     </script>
  71. <div id="map_canvas" class="box" style="width:50%; height:50%"></div>
  72. </body>
  73. </html>
RAW Paste Data