Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Geolocation</title>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
- <meta charset="utf-8">
- <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <style>
- .button1 {
- background-color: #4CAF50;
- border: 2px;
- color: white;
- padding: 15px 32px;
- text-align: center;
- text-decoration: none;
- /*display: inline-block;*/
- font-size: 16px;
- margin: 10px 2px;
- cursor: pointer
- }
- .button2 {
- background-color: #d62e20;
- border: none;
- color: white;
- padding: 15px 32px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 4px 2px;
- cursor: pointer;
- /*position: absolute;
- right: auto;*/
- }
- .button3 {
- background-color: #3520d6;
- border: 2px;
- color: white;
- padding: 15px 32px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 4px 2px;
- cursor: pointer;
- /*position: absolute;
- right: auto;*/
- }
- /* Always set the map height explicitly to define the size of the div
- * element that contains the map. */
- #map {
- height: 100%;
- }
- /* Optional: Makes the sample page fill the window. */
- html, body {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- </style>
- </head>
- <body>
- <div class="user_logged_in">
- <?php
- include "login_klient/config.php";
- // Create connection
- $con = new mysqli($host, $user, $password, $dbname);
- // Check connection
- if ($con->connect_error) {
- die("Connection failed: " . $con->connect_error);
- }
- // Check user login or not
- if(!isset($_SESSION['uname'])){
- header('Location: login_klient/login.php');
- }
- $login=$_SESSION['uname'];
- echo "Aktualnie zalogowany jako: ".$login;
- ?>
- <form class="wyloguj_container" method='post' action="">
- <input class="wyloguj" type="submit" value="Wyloguj" name="but_logout">
- </form>
- </div>
- <?php
- // logout
- if(isset($_POST['but_logout'])){
- session_destroy();
- header('Location: home_klient.php');
- }
- ?>
- <div class="w3-bar w3-white w3-large">
- <a href="index.html" class="w3-bar-item w3-button w3-red w3-mobile"><i class="fa fa-home w3-margin-right"></i>Strona główna</a>
- </div>
- <div id="map" style="width:100%;height:400px"></div>
- <form action="dodaj/dodaj1.php" method="get">
- <input type=text id="lng" name="lng" style="visibility: hidden; width:5%">
- <input type=text id="lat" name="lat" style="visibility: hidden; width:5%">
- <table>
- <tr>
- <td><a href="index.html" class="button2" >Anuluj</a></td>
- <td><input type="submit" value="Zapisz" class="button1"></td>
- </tr>
- </table>
- </form>
- <script>
- // Note: This example requires that you consent to location sharing when
- // prompted by your browser. If you see the error "The Geolocation service
- // failed.", it means you probably did not give permission for the browser to
- // locate you.
- var map, infoWindow;
- function initMap() {
- map = new google.maps.Map(document.getElementById("map"), {
- center: {lat: -34.397, lng: 150.644},
- zoom: 17
- });
- infoWindow = new google.maps.InfoWindow;
- // Try HTML5 geolocation.
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- var pos = {
- lat: position.coords.latitude,
- lng: position.coords.longitude
- };
- var lat=position.coords.latitude;
- var lng= position.coords.longitude;
- document.getElementById("lng").value = lng;
- document.getElementById("lat").value = lat;
- infoWindow.setPosition(pos);
- infoWindow.setContent('Location found.');
- infoWindow.open(map);
- map.setCenter(pos);
- }, function() {
- handleLocationError(true, infoWindow, map.getCenter());
- });
- } else {
- // Browser doesn't support Geolocation
- handleLocationError(false, infoWindow, map.getCenter());
- }
- }
- function handleLocationError(browserHasGeolocation, infoWindow, pos) {
- infoWindow.setPosition(pos);
- infoWindow.setContent(browserHasGeolocation ?
- 'Error: The Geolocation service failed.' :
- 'Error: Your browser doesn\'t support geolocation.');
- infoWindow.open(map);
- }
- </script>
- <script async defer
- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDur8LxYqPiH6qTgVYZ_PC583tgAV9JJ04&callback=initMap">
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment