Leaflet tile layer with dronedeploy

585 Views Asked by At

I am trying to display my dronedeploy map with leaflet.js, but the link which is generated by the Leaflet Tile Layer market app gives me an access denied error.

I am on a 30 day trial account but I have a few weeks remaining.

Also, is this the best way to display the data in leaflet? I noticed you can export the map as GeoTiff tiles, but I cannot find any examples on how to import/display these in leaflet

1

There are 1 best solutions below

1
kujosHeist On BEST ANSWER

Okay so after replacing the {z}/{x}/{y}.png in the url with valid tile numbers, I got back some results.

I used this page to calculate a valid tile number: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

However this was unnecessary to get my map displayed in leaflet. All I had to do was use the url when defining a tile layer, here's a complete example:

<!DOCTYPE html>
<html>
<head>  
    <title>Quick Start - Leaflet</title>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />

    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" crossorigin=""/>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-A7vV8IFfih/D732iSSKi20u/ooOfj/AGehOKq0f4vLT1Zr2Y+RX7C+w8A1gaSasGtRUZpF/NZgzSAu4/Gc41Lg==" crossorigin=""></script>
</head>
<body>

<div id="mapid" style="width: 600px; height: 400px;"></div>
<script>

    var mymap = L.map('mapid').setView([14.0, -8.2474], 13);

    // add base map layer
    L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
        maxZoom: 22,
        attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
            '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
            'Imagery © <a href="http://mapbox.com">Mapbox</a>',
        id: 'mapbox.streets'
    }).addTo(mymap);


    // url generated from "Leaflet / Mapbox / Fulcrum Tile Layer" market place app on dronedeploy
    // (url truncated)
    var leafletTileLayerUrl = 'https://public-tiles.dronedeploy.com/1494366194_KUJOSCARTOPENPIPELINE_ortho_vdt/{z}/{x}/{y}.png?Policy=.....'  

    // add custom map layer 
    L.tileLayer(leafletTileLayerUrl, {
        maxZoom: 22,
    }).addTo(mymap);    
</script>
</body>
</html>