简体   繁体   English

Javascript-获取OpenLayers矢量源的url值

[英]Javascript - Get value of url of OpenLayers Vector Source

I have create a Vector source and specified a url for the source. 我已经创建了一个Vector源,并为该源指定了一个url。 What I want to do now is get the value of that url (in string) from somewhere else. 我现在想做的是从其他地方获取该URL的值(以字符串形式)。 Is that possible? 那可能吗?

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

chitwanURL is a string containing the url. chitwanURL是包含URL的字符串。 I want the url from somewhere else. 我想要其他地方的网址。 I tried sourceChitwan.getUrl() but it returns undefined . 我尝试了sourceChitwan.getUrl(),但是它返回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 . Openlayers类ol.source.Vector在API 版本3中没有获取URL的方法。 It is necessary to upload to version 4 to find it. 必须上传到版本4才能找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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