geojson.html 2.9 KB
<html>
<head>
    <title>Basic</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <link rel="stylesheet" href="../libs/leaflet/dist/leaflet.css"/>
    <style>
        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div id="map"></div>
<script src="../libs/jquery/dist/jquery.min.js"></script>
<script src="../libs/leaflet/dist/leaflet.js"></script>

<script src="../node_modules/pbf/dist/pbf.js"></script>
<script src="../src/point-geometry.js"></script>

<script src="../src/geojson-vt.js"></script>
<script src="../src/encode.js"></script>
<script src="../src/decode.js"></script>

<script src="../src/vectorTileFeature.js"></script>
<script src="../src/vectorTileLayer.js"></script>
<script src="../src/vector-tile.js"></script>

<script src="../src/geojson_wrapper.js"></script>
<script src="../src/vector-tile-pb.js"></script>
<script src="../src/vt-pbf.js"></script>



<script src="../src/MVTUtil.js"></script>
<script src="../src/StaticLabel.js"></script>
<script src="../src/MVTFeature.js"></script>
<script src="../src/MVTLayer.js"></script>
<script src="../src/MVTSlice.js"></script>
<script>

var map = L.map('map').setView([0, 0], 1); // africa

L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  maxZoom: 18,
  id: 'examples.map-i86knfo3'
}).addTo(map);

   $.getJSON("bou2_4p.json", function (data){
   
			// build an initial index of tiles
var tileIndex = geojsonvt(data, {
    maxZoom: 14,  // max zoom to preserve detail on
    tolerance: 3, // simplification tolerance (higher means simpler)
    extent: 4096, // tile extent (both width and height)
    buffer: 64,   // tile buffer on each side
    debug: 2,      // logging level (0 to disable, 1 or 2)

    indexMaxZoom: 5,        // max zoom in the initial tile index
    indexMaxPoints: 10000, // max number of points per tile in the index
    solidChildren: false    // whether to include solid tile children in the index
});

var z= 14 - 6 ;
// request a particular tile
var features = tileIndex.getTile(6 + z, 48 * (1<<z), 24 * (1<<z)).features;

           var mvtSource = new L.TileLayer.MVTSlice(data, {
                debug: false,

                getIDForLayerFeature: function(feature) {
                    return feature.properties.gid;
                }
            });
            //Add layer
           map.addLayer(mvtSource);
             
        });
     //$.ajax({
      //   url:"http://spatialserver.spatialdev.com/services/vector-tiles/GAUL_FSP/5/18/16.pbf",

       //  type:"GET",
      //   success: function(data) {

             
             //var aa = new Pbf(new Uint8Array(data));
            //var geojson = decode(aa);
            //var ss = JSON.stringify(geojson);
        // }
         
     //});
</script>
</body>
</html>