def getVT(json_url): sln = safeName(json_url) try: key = json_url.split("?")[1] except Exception: key = "" json = TileJSON(json_url) json.load() tile_url = json.tiles()[0].split("?")[0] key_url = "%s?%s" % (tile_url, key) layerCode = """ var lyr_%s = new ol.layer.VectorTile({ source: new ol.source.VectorTile({ format: new ol.format.MVT(), url: '%s', tileGrid: new ol.tilegrid.createXYZ({ tileSize: 512, maxZoom: 14 }), tilePixelRatio: 8 }), style: style_%s, interarctive: %s }); """ % (sln, key_url, sln, str(interactive).lower()) return layerCode
def VTLayer(json_url): sln = safeName(json_url) key = json_url.split("?")[1] json = TileJSON(json_url) json.load() tile_url = json.tiles()[0].split("?")[0] key_url = "%s?%s" % (tile_url, key) styleSuffix = safeName(json_url) vtJS = """ var layer_%s = L.vectorGrid.protobuf("%s", { rendererFactory: L.svg.tile, //onEachFeature: label_%s, vectorTileLayerStyles: style_%s });""" % (sln, key_url, sln, styleSuffix) return vtJS
def getVT(json_url): print json_url sln = safeName(json_url) key = json_url.split("?")[1] json = TileJSON(json_url) json.load() tile_url = json.tiles()[0].split("?")[0] key_url = "%s?%s" % (tile_url, key) layerCode = """ var lyr_%s = new ol.layer.VectorTile({ source: new ol.source.VectorTile({ format: new ol.format.MVT(), url: '%s', tileGrid: new ol.tilegrid.createXYZ({ tileSize: 512, maxZoom: 14 }), tilePixelRatio: 8 }), style: style_%s }); """ % (sln, key_url, sln) return layerCode
def getVT(json_url): sln = safeName(json_url) try: key = json_url.split("?")[1] except: key = "" json = TileJSON(json_url) json.load() tile_url = json.tiles()[0].split("?")[0] key_url = "%s?%s" % (tile_url, key) layerCode = """ var lyr_%s = new ol.layer.VectorTile({ source: new ol.source.VectorTile({ format: new ol.format.MVT(), url: '%s', tileGrid: new ol.tilegrid.createXYZ({ tileSize: 512, maxZoom: 14 }), tilePixelRatio: 8 }), style: style_%s }); """ % (sln, key_url, sln) return layerCode