简体   繁体   中英

Javascript - Get value of url of OpenLayers Vector Source

I have create a Vector source and specified a url for the source. What I want to do now is get the value of that url (in string) from somewhere else. Is that possible?

var sourceChitwan = new ol.source.Vector({
url: chitwanURL,
format: new ol.format.GeoJSON()
});

chitwanURL is a string containing the url. I want the url from somewhere else. I tried sourceChitwan.getUrl() but it returns undefined .

The problem is solved but I will leave here the solution so anyone with a similar problem in the future can find it easily without reading all the comments:

Openlayers class ol.source.Vector does not have a method to get the URL in the API version 3 . It is necessary to upload to version 4 to find it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM