Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------Arduino.php-----------------------------------------
- <?php
- class Arduino {
- private $ID;
- private $georeference;
- private $activeDate;
- public function __construct($ID, $georeference,$activeDate)
- {
- $this->ID=$ID;
- $this->georefence=$georeference;
- $this->activeDate=$activeDate;
- echo "<p> Arduino criado com sucesso!<p>";
- }
- function getID()
- {
- return $this->ID;
- }
- function getGeoreference()
- {
- return $this->georeference;
- }
- function getActiveDate()
- {
- return $this->activeDate;
- }
- function getLocation()
- {
- $script = file_get_contents('js/location.js');
- echo "<script>".$script."</script>";
- }
- }
- -------------------------------------------index.php------------------------------------------
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <script src="https://maps.googleapis.com/maps/api/js"></script>
- <script src="gmaps.js"></script>
- <link rel="stylesheet" href="map.css">
- <div id="map">
- </div>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- require_once 'Arduino.php';
- $p1= new Arduino('1','15412,124124','28-06-1991');
- $p1->getID();
- $p1->getLocation();
- ?>
- </body>
- </html>
- -----------------------------------------location.js-----------------------------------------
- var mapObj = new GMaps({
- el: '#map',
- lat: 48.857,
- lng: 2.295
- });
- var mapObj = new GMaps({
- el: '#map',
- lat: 48.857,
- lng: 2.295,
- });
- GMaps.geocode({
- address: 'Stonehenge, United Kingdom',
- callback: function(results, status) {
- if (status == 'OK') {
- latlng = results[0].geometry.location;
- mapObj.setCenter(latlng.lat(), latlng.lng());
- } else if (status == 'ZERO_RESULTS') {
- alert('Sorry, no results found');
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement