Advertisement
demetriusPop

fyndyrdsl

Dec 15th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  
  5. Template Name: findyardsale-showmap
  6. */
  7.  
  8.  
  9. get_header();
  10.  
  11.  
  12.  
  13.  
  14. /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>> Read and Get From Table */
  15. if(isset($_POST['address']) && $_POST['address'] != '' && (isset($_POST['city'])) && $_POST['city'] != '') {
  16. $user_search = esc_attr($_POST['city']);
  17.  
  18.  
  19. function get_address() {
  20. global $wpdb;
  21. global $user_search;
  22.  
  23. $address_table = $wpdb->prefix . "address_table";
  24. $query = $wpdb->get_results('SELECT * FROM ' . $address_table );
  25.  
  26. foreach($query as $single_query)
  27.  
  28. //Put the lat , lng results into array, return array and assign to var. Then use array keys where necessary
  29. $data = json_decode($single_query->json);
  30. $result = array();
  31. $result['lat'] = $data->results[0]->geometry->location->lat;
  32. $result['long'] = $data->results[0]->geometry->location->lng;
  33. $result['city'] = $single_query->city;
  34. return $result;
  35. }
  36. $latlong = get_address();
  37. ?><li><?php
  38. var_dump ($latlong);
  39. ?></li><?php
  40. }
  41.  
  42. ?>
  43.  
  44. <div id="map" style="width:300px; height:300px;"></div>
  45.  
  46. <!--Have to get lat and lng from database-->
  47. <script>
  48. var geocoder;
  49. var map;
  50. function initialize() {
  51. var mapOptions = {
  52. center: new google.maps.LatLng(<?php echo $latlong['lat'] ?>, <?php echo $latlong['long'] ?>),
  53. zoom: 8,
  54. mapTypeId: google.maps.MapTypeId.ROADMAP
  55. };
  56. var map = new google.maps.Map(document.getElementById("map"),
  57. mapOptions);
  58. }
  59. google.maps.event.addDomListener(window, 'load', initialize);
  60. </script>
  61.  
  62. <form method="post" action="" id="insertForm" name="insertForm">
  63. <input type="text" value="" placeholder="enter city" id="city" name="city">
  64. <input type="text" value="" placeholder="enter full address" id="address" name="address">
  65.  
  66. <input type="submit" value="search">
  67. </form>
  68.  
  69.  
  70.  
  71.  
  72. <?php
  73. get_footer();
  74.  
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement