Advertisement
Guest User

Untitled

a guest
May 8th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1.  
  2. --------------------------------------------------Arduino.php-----------------------------------------
  3. <?php
  4.  
  5. class Arduino {
  6.  
  7. private $ID;
  8. private $georeference;
  9. private $activeDate;
  10.  
  11. public function __construct($ID, $georeference,$activeDate)
  12. {
  13. $this->ID=$ID;
  14. $this->georefence=$georeference;
  15. $this->activeDate=$activeDate;
  16. echo "<p> Arduino criado com sucesso!<p>";
  17. }
  18. function getID()
  19. {
  20. return $this->ID;
  21. }
  22. function getGeoreference()
  23. {
  24. return $this->georeference;
  25. }
  26. function getActiveDate()
  27. {
  28. return $this->activeDate;
  29. }
  30. function getLocation()
  31. {
  32. $script = file_get_contents('js/location.js');
  33. echo "<script>".$script."</script>";
  34.  
  35. }
  36. }
  37.  
  38. -------------------------------------------index.php------------------------------------------
  39. <html>
  40. <head>
  41. <meta charset="UTF-8">
  42. <title></title>
  43.  
  44. </head>
  45. <body>
  46. <script src="https://maps.googleapis.com/maps/api/js"></script>
  47. <script src="gmaps.js"></script>
  48. <link rel="stylesheet" href="map.css">
  49. <div id="map">
  50. </div>
  51.  
  52.  
  53. <?php
  54.  
  55. $servername = "localhost";
  56. $username = "root";
  57. $password = "";
  58.  
  59. // Create connection
  60. $conn = new mysqli($servername, $username, $password);
  61.  
  62. // Check connection
  63. if ($conn->connect_error) {
  64. die("Connection failed: " . $conn->connect_error);
  65. }
  66. echo "Connected successfully";
  67.  
  68.  
  69.  
  70. require_once 'Arduino.php';
  71. $p1= new Arduino('1','15412,124124','28-06-1991');
  72. $p1->getID();
  73. $p1->getLocation();
  74. ?>
  75. </body>
  76. </html>
  77.  
  78. -----------------------------------------location.js-----------------------------------------
  79. var mapObj = new GMaps({
  80. el: '#map',
  81. lat: 48.857,
  82. lng: 2.295
  83. });
  84. var mapObj = new GMaps({
  85. el: '#map',
  86. lat: 48.857,
  87. lng: 2.295,
  88. });
  89.  
  90. GMaps.geocode({
  91. address: 'Stonehenge, United Kingdom',
  92. callback: function(results, status) {
  93. if (status == 'OK') {
  94. latlng = results[0].geometry.location;
  95. mapObj.setCenter(latlng.lat(), latlng.lng());
  96. } else if (status == 'ZERO_RESULTS') {
  97. alert('Sorry, no results found');
  98. }
  99. }
  100. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement