Commit 4cbbe6ce authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

leaflet plugin testing only

parent 42259844
Loading
Loading
Loading
Loading

js/map.css

0 → 100644
+26 −0
Original line number Diff line number Diff line
body {
    padding: 0;
    margin: 0;
}
html, body, #leaflet_map {
    height: 100vh;
    width: 100vw;
}

.measurementtooltip{
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  padding: 0px 3px;
  margin:14px 0px 0px 5px;
  font-weight: normal;
  border-radius: 1px;
}

.leaflet-tooltip-left.measurementtooltip::before {
  border: 0px;
  border-left-color: cyan;
}

.leaflet-tooltip-right.measurementtooltip::before {
  border: 0px;
  border-right-color: cyan;
}
 No newline at end of file

js/map.js

0 → 100644
+103 −0
Original line number Diff line number Diff line
/* 
 * TODO:
 *    * 
 * 
 */

// http://stackoverflow.com/questions/9394190/leaflet-map-api-with-google-satellite-layer

// http://leafletjs.com/examples/extending/extending-1-classes.html
// - extend or include

$(function(){
  light_init();
});

function light_init(){
  
  $.ajax({
    url: "kml/test.kml",
    success: function(data){

      var marker = [
        parseFloat($(data).find("Camera").find("latitude").text()),
        parseFloat($(data).find("Camera").find("longitude").text())
      ];
      
      var heading = parseFloat($(data).find("Camera").find("longitude").text());
      
      init_maps(marker);

    },
  });
  
  
}

var map;
var markers = Array();

function init_maps(center){

  var elphelinc = center;//[40.7233861, -111.9328843];
  
  // https: also suppported.
  var Esri_WorldImagery = L.tileLayer(
    'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', 
    {
      maxZoom: 21,
      attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
    }
  );

  var googleSat = L.tileLayer(
    'https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',
    {
      maxZoom: 21,
      attribution: 'Many thanks to Google for our happy childhood',
      subdomains:['mt0','mt1','mt2','mt3'],
    }
  );
  
  var OSMTiles = L.tileLayer('http://a.tile.openstreetmap.org/{z}/{x}/{y}.png', 
    {
      maxZoom: 21,
      attribution: 'Map data and images &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
    }
  );
  
  map = L.map('leaflet_map',{
    layers:[googleSat]
  }).setView(elphelinc, 17);

  var baseMaps = {
    "Esri world imagery": Esri_WorldImagery,
    "Google": googleSat,
    "Open Street Map": OSMTiles
  };
  
  //Esri_WorldImagery.addTo(map);
  //googleSat.addTo(map);
  
  //custom control:
  //http://www.coffeegnome.net/control-button-leaflet/
  
  L.control.layers(baseMaps).addTo(map);
 
  drawCamera(elphelinc);
  
}

function drawCamera(basepoint){
  
  var circle = L.cameraViewMarker(basepoint, {
      color: '#191',
      fillColor: '#0f3',
      fillOpacity: 0.5,
      radius: 10,
      heading: 45,
      fov: 45*Math.PI/180,
      id: "basecircle"
  }).addTo(map);

}

map.html

0 → 100644
+18 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html lang="en">
<head>
  <title>Ze Map</title>
  <meta charset="utf-8"/>
  <script type='text/javascript' src='js/jquery-3.1.1.js'></script>
  <script type='text/javascript' src='js/leaflet/leaflet-src.js'></script>
  <script type='text/javascript' src='js/leaflet/leaflet.camera-view-marker.js'></script>
  <script type='text/javascript' src='js/leaflet/leaflet.camera-view-marker.measure.js'></script>
  <script type='text/javascript' src='js/map.js'></script>
  <link rel='stylesheet' type='text/css' href='js/leaflet/leaflet.css'></link>
  <link rel='stylesheet' type='text/css' href='js/index.css'></link>
  <link rel='stylesheet' type='text/css' href='js/map.css'></link>
</head>
<body>
  <div id="leaflet_map"></div>
</body>
</html>
 No newline at end of file