Advertisement
Bedhoel

Basic_Map

Sep 21st, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2. $lat  = $_REQUEST['lat'];
  3. $long = $_REQUEST['long'];
  4. $zoom = (empty($_REQUEST['zoom']) ? '17' : $_REQUEST['zoom']);  // 1 to 22
  5. ?>
  6. <!DOCTYPE html>
  7. <html>
  8.   <head>
  9.     <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  10.     <meta charset="utf-8">
  11.     <title>Markers</title>
  12.     <style>
  13.       /* Always set the map height explicitly to define the size of the div
  14.        * element that contains the map. */
  15.       #map {
  16.         height: 100%;
  17.       }
  18.       /* Optional: Makes the sample page fill the window. */
  19.       html, body {
  20.         height: 100%;
  21.         margin: 0;
  22.         padding: 0;
  23.       }
  24.     </style>
  25.   </head>
  26.   <body>
  27.     <div id="map"></div>
  28.     <script>
  29.  
  30.       function initMap() {
  31.         var myLatLng = {lat: <?php echo $lat ?>, lng: <?php echo $long ?>};
  32.  
  33.         var map = new google.maps.Map(document.getElementById('map'), {
  34.           zoom: <?php echo $zoom ?>,
  35.           center: myLatLng
  36.         });
  37.  
  38.         var marker = new google.maps.Marker({
  39.           position: myLatLng,
  40.           map: map,
  41.           title: 'Hello World!'
  42.         });
  43.       }
  44.     </script>
  45.     <script async defer
  46.     src="https://maps.googleapis.com/maps/api/js?key=KEY&callback=initMap">
  47.     </script>
  48.   </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement