TransWikia.com

How to add a raster layer in openlayer 6 and its wmts in Mapproxy

Geographic Information Systems Asked on January 1, 2021

I want to add a raster layer to my map. I added a TMS layer map using ol6, now I want to add a raster layer to it. How could I implement it. My TMS layer is generated using Mapproxy & mapnik.
My javascript is :

proj4.defs("EPSG:32643","+proj=utm +zone=43 +datum=wgs84 +units=m +no_defs");
register(proj4);

var extent = [291627,904686,958569,1571628];
var projection = new Projection({
  code: 'EPSG:32643',
  extent: extent,
});
var map = new Map({
  target: 'map',
  layers: [
    new TileLayer({
        title: 'District',
        type: 'base',
        source: new XYZ({
           url: "http://127.0.0.1:8080/tms/1.0.0/district/distgrid" + "/{z}/{x}/{-y}.png",
           projection:projection,
           tileGrid: createXYZ({ 
                  extent: extent,
                  maxResolution: 2605.2421875,
                  tileSize: [256, 256],
                  maxZoom: 13,
                }),
        }),
    }) ],

  view: new View({
    projection: projection,
    units:"metric",
    extent: extent,
    zoom:0,
    maxZoom:13,
    minZoom:0,
    maxResolution:2605.2421875,
    center:[654496.136597752,1155181.26900064],
    numZoomLevels:13,
    constrainOnlyCenter: true,
    constrainResolution: true,
  })
});

My mapnik.yaml is:

services:
  tms:
    use_grid_names: true
    origin: 'sw'
  wmts:
    kvp: false
    restful: true
layers:
  - name: district
    title: District Layer
    sources: [dist_cache] 
    
caches:
  dist_cache:
    grids: [distgrid] 
    sources: [dist_tms]   
    meta_size: [4, 4]
    
sources:
  dist_tms:
    type: mapnik
    mapfile: /var/www/Mapfiles/district.xml 
    transparent: true
    
grids:
    distgrid:   
        srs:  'EPSG:32643'
        bbox: [291627,904686,958569,1426831]  
        bbox_srs: 'EPSG:32643'
        origin: 'sw'    
        
globals:

Can I combine TMS & WMTS in ol6? I want to add as in this example https://openlayers.org/en/latest/examples/shaded-relief.html. How to add wmts layer in mapproxy?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP