TransWikia.com

Generate a JSON instead of an image for the legend with OpenLayers

Geographic Information Systems Asked on December 15, 2020

I’m not clear on how I can pass the params to getLegendUrl. My aim is to obtain the JSON and for this scope I use the code below:

  var graphicUrl = wmsSource.getLegendUrl(
    resolution,
    'params': 'application/json',
  );
  console.log(graphicUrl);

In the console I see only the error below concerned to 'params': 'application/json',:

Uncaught SyntaxError: missing ) after argument list

One Answer

The parameters should be an object, it should look like something like this :

var graphicUrl = wmsSource.getLegendUrl( resolution,
     {'REQUEST': '...',
      'LAYER': '...'
     }
);

The exact syntax of the parameters depends on your WMS server. For instance :

Correct answer by Léo M on December 15, 2020

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