Advertisement
metalx1000

Open Street Maps Leaflet Satellite View

Jan 28th, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <title>Open Street Maps Satellite View</title>
  6.   <meta charset="utf-8">
  7.   <meta name="viewport" content="width=device-width, initial-scale=1">
  8.   <link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
  9.   <style>
  10.     @media only screen and (min-width: 600px) {
  11.       body {
  12.         margin-right: 200px;
  13.         margin-left: 200px;
  14.         margin-top: 20px;
  15.       }
  16.     }
  17.  
  18.     #map {
  19.       height: 100%;
  20.     }
  21.  
  22.     html,
  23.     body {
  24.       height: 100%;
  25.       margin: 0px;
  26.     }
  27.   </style>
  28. </head>
  29.  
  30. <body>
  31.  
  32.   <div id="map"> </div>
  33.  
  34. </body>
  35.  
  36. <script type="text/javascript" src="//cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
  37.  
  38. <script>
  39.  
  40.   var mapbox_url = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}';
  41.   var esri_url = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
  42.   var esri_attribution = '© Esri © OpenStreetMap Contributors';
  43.  
  44.   var lyr_satellite = L.tileLayer(esri_url, {id: 'MapID', maxZoom: 20, tileSize: 512, zoomOffset: -1, attribution: esri_attribution});
  45.  
  46.   var points = [
  47.     {
  48.       "latitude": 25.95618729,
  49.       "longitude": -81.51154125,
  50.     },
  51.     {
  52.       "latitude": 25.95590198,
  53.       "longitude": -81.51149629,
  54.     },
  55.     {
  56.       "latitude": 25.95558575,
  57.       "longitude": -81.51130469,
  58.     },
  59.     {
  60.       "latitude": 25.95714197,
  61.       "longitude": -81.51131631,
  62.     },
  63.     {
  64.       "latitude": 25.95745887,
  65.       "longitude": -81.51090912,
  66.     },
  67.     {
  68.       "latitude": 25.95703306,
  69.       "longitude": -81.51088921,
  70.     },
  71.     {
  72.       "latitude": 25.95711647,
  73.       "longitude": -81.51036314,
  74.     }
  75.   ];
  76.  
  77.   var markers = [];
  78.  
  79.   for (i in points) {
  80.     markers.push(L.marker([points[i].latitude, points[i].longitude], {draggable: false}).bindPopup(`<b>Point #${i}</b>`));
  81.   }
  82.  
  83.   var lg_markers = L.layerGroup(markers);
  84.   //marker = L.marker(['25.95703306', '-81.51088921']);
  85.  
  86.   var map = L.map('map', {
  87.     center: [25.95618729, -81.51154125],
  88.     zoom: 18,
  89.     layers: [lyr_satellite, lg_markers]
  90.   });
  91.  
  92.   var baseMaps = {
  93.     "Satellite": lyr_satellite
  94.   };
  95.  
  96.   var overlayMaps = {
  97.     "Markers": lg_markers,
  98.   };
  99.  
  100.   L.control.layers(baseMaps, overlayMaps).addTo(map);
  101. </script>
  102.  
  103. </html>
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement