首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >{N} 6中断iOS上的谷歌地图信息窗口

{N} 6中断iOS上的谷歌地图信息窗口
EN

Stack Overflow用户
提问于 2019-09-06 04:44:37
回答 1查看 138关注 0票数 0

升级到NativeScript 6后,在iOS上点击谷歌地图上的一个标记来显示相关的信息窗口,会使应用程序崩溃。这是由于_layoutRootView被删除了-参见https://github.com/dapriett/nativescript-google-maps-sdk/issues/354上的nativescript-google-maps-sdk Issue354

问题是没有提供替代方案,而且google-maps sdk插件最近没有任何活动。

我把这篇文章贴到SO上,是为了通知更大的NativeScript社区,并了解是否有其他选择。

显示的错误消息是

代码语言:javascript
复制
JavaScript error:
file:///node_modules/nativescript-google-maps-sdk/map-view.js:164:30: JS ERROR TypeError: __webpack_require__("../node_modules/tns-core-modules/ui/utils.js").ios._layoutRootView is not a function. (In '__webpack_require__("../node_modules/tns-core-modules/ui/utils.js").ios._layoutRootView(content, CGRectMake(0, 0, width, height))', '__webpack_require__("../node_modules/tns-core-modules/ui/utils.js").ios._layoutRootView' is undefined)

编辑

按照@manoj的指示,我使用{N} 5.3从另一个项目中手动复制了tns- _layoutRootView -modules/ui/utils.d.ts和tns-core-modules/ui/utils.ios.js中的核心代码。iOs上的信息窗口现在可以工作了!!

我完全明白在node-module中编辑代码不是一个好主意,但是我永远不能使用Manoj的方法来避免webpack的错误。有没有更好的方法从我自己的javascript项目中向NativeScript模块添加函数?

EN

回答 1

Stack Overflow用户

发布于 2019-09-12 03:44:57

尝尝这个,

代码语言:javascript
复制
import * as utils from 'tns-core-modules/utils/utils';

if (utils.ios) {
    (<any>utils.ios)._layoutRootView = function(rootView, parentBounds) {
        if (!rootView || !parentBounds) {
            return;
        }

        const size = parentBounds.size;
        const width = utils.layout.toDevicePixels(size.width);
        const height = utils.layout.toDevicePixels(size.height);

        const widthSpec = utils.layout.makeMeasureSpec(width, utils.layout.EXACTLY);
        const heightSpec = utils.layout.makeMeasureSpec(height, utils.layout.EXACTLY);

        rootView.measure(widthSpec, heightSpec);

        const origin = parentBounds.origin;
        const left = origin.x;
        const top = origin.y;

        rootView.layout(left, top, width, height);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57812762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档