将ol3

编程入门 行业动态 更新时间:2024-10-06 08:31:03
将ol3-google-maps 0.4升级到0.13导致this.setMap不是函数错误(Upgrading ol3-google-maps 0.4 to 0.13 resulting in this.setMap is not a function error)

我一直在使用ol3-google-maps 0.4很长一段时间但现在不得不将其升级到0.10(或更高)。 所以我将我的ol3gm.js(0.4)的内容替换为最新的(0.13)。 使用0.4我的应用程序工作正常,但一旦我切换到0.13得到“this.setMap不是一个函数错误”。

使用Openlayers 3.18.1

有人能告诉我两者之间的区别以及如何解决这个问题。

I have been using ol3-google-maps 0.4 for quite some time but now had to upgrade it to 0.10 (or higher). So I am replacing the content of my ol3gm.js (0.4) to latest (0.13). With 0.4 my application works fine, but as soon as I switch to 0.13 get "this.setMap is not a function error".

Using Openlayers 3.18.1

Could someone let me know the difference between the two and How to resolve this issue.

最满意答案

从v0.6开始,ol3-google-maps随着OpenLayers编译而发布。 您不需要单独加载OpenLayers库。

另外,请注意,对于每个版本,使用的OpenLayers版本可能会有所不同。 如果您想使用OpenLayers 3.18.1,那么您应该使用ol3-google-maps v0.11.0 。

As explained by Alexandre that from v0.6 onwards ol3-google-maps gets released with OpenLayers compiled within.

Since I was using ol3gm v0.4 which didn't included Openlayers in it I was loading the ol.js and Google APIs at the initialization of the application and once the base layer change event was fired was loading ol3gm.js at runtime, hence the issue. Made that library loading sequence correct and the problem was resolved. If anyone facing similar issue can use the below code to wait until olgm is available to use.

var googleInterval = setInterval(function(){ initmapController() }, 1000); function initmapController() { $("#loadingOverLay").removeClass('hide') if (google.maps !== undefined){ if(typeof olgm !== "undefined") { $("#loadingOverLay").addClass('hide') clearInterval(googleInterval); init(); } } }

更多推荐

本文发布于:2023-07-27 08:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287730.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!