ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
681 stars 230 forks source link

Need extParams for vector source #397

Closed scadergit closed 3 years ago

scadergit commented 3 years ago

Unless I'm missing the implementation, I don't see the ability to add parameters to vector-source service requests in the way that wms-source can using extParams. We have to provide an a token to certain service requests, and cannot without this feature for vector sources.

Appreciate the help.

ghettovoice commented 3 years ago

Hello @scadergit , with vector sources you can define append custom get parameters to the url string. Or generate url dynamically in runtime with url function, just replace url property with a function:

(extent, resolution, projection) => {
    // build url string
    return url
 }

Or finally provide custom loader function:

async (extent, resolution, projection) => {
   const r = await fetch('//path/to/features')
   const data = await r.text()

   // if returned features data is known gis format
   // and you set this format factory to the vl-source-vector
   // you can just return raw data here
   return data

   // or parse raw data yourself, then return GeoJSONFeature[] or ol/Feature[]
    return features
}
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.