Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <script type="text/javascript">
  2. var geocoder;
  3. var map;
  4. // create map objects
  5. function initialize(address)
  6. {
  7. geocoder = new google.maps.Geocoder();
  8. var latlng = new google.maps.LatLng(
  9. 56.9349327,-4.245415299999991);
  10. var myOptions =
  11. {
  12. zoom: 5,
  13. center: latlng,
  14. mapTypeId: google.maps.MapTypeId.ROADMAP
  15. }
  16. map = new google.maps.Map(document.getElementById("map_canvas"),
  17. myOptions);
  18. <?php
  19. require('connection.php');
  20. $result = mysqli_query($con,"SELECT * FROM `customers`") or
  21. die ("Error: ".mysqli_error($con));
  22. $yourArray = array();
  23. $index = 0;
  24. ?>
  25. <?php
  26. //Starts while loop so all addresses for the given information
  27. //will
  28. //be populated.
  29. while($row = mysqli_fetch_assoc($result))
  30. //instantiates array
  31. {
  32.  
  33. ?>
  34.  
  35. var address = "<?php echo $row['CustomerAddress'] ?>";
  36. geocoder.geocode( { 'address': address}, function(results,
  37. status)
  38. {
  39. if (status == google.maps.GeocoderStatus.OK)
  40. {
  41. map.setCenter(results[0].geometry.location);
  42. var marker = new google.maps.Marker({
  43. map: map,
  44. position: results[0].geometry.location
  45. });
  46. var contentString = '<div id="content">'+
  47. '<div id="siteNotice">'+
  48. '</div>'+
  49. '<b>Customer Name :<?php echo $row['CustomerName']?>
  50. </b>'
  51. +'<br>'+
  52. '<b> Customer Address : <?php echo $address ?> </b>'+'<br>'+
  53. '<b> Customer ID : <?php echo $row['ID'] ?> </b> '
  54. '</div>';
  55.  
  56. var infowindow = new google.maps.InfoWindow({
  57. content: contentString
  58. });
  59. google.maps.event.addListener(marker, 'click', function() {
  60. infowindow.open(map,marker);
  61. });
  62. }
  63. });
  64. <?php
  65. $address++;
  66. } //ends while
  67. ?>
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement