当前位置: 首页 > news >正文

做百度快照要先有网站吗手机网站一键开发

做百度快照要先有网站吗,手机网站一键开发,公司网站发展规划书,国家职业技能培训官网本文以同层渲染为例,介绍如何集成高德地图 完整代码见 Flutter 鸿蒙版 Demo 概述 Dart 侧 核心代码如下,通过 OhosView 来承载原生视图 OhosView(viewType: com.shaohushuo.app/customView,onPlatformViewCreated: _onPlatformViewCreated,creation…

本文以同层渲染为例,介绍如何集成高德地图

完整代码见 Flutter 鸿蒙版 Demo

概述

Dart 侧

核心代码如下,通过 OhosView 来承载原生视图

OhosView(viewType: 'com.shaohushuo.app/customView',onPlatformViewCreated: _onPlatformViewCreated,creationParams: const <String, dynamic>{'initParams': 'hello world'},creationParamsCodec: const StandardMessageCodec(),)

其中 viewType 为自定义的 ohosView 的名称,onPlatformViewCreated 为创建完成回调,creationParams 为创建时传入的参数,creationParamsCodec 为参数编码格式。

ArkTS 侧

这里面我们按照《如何使用PlatformView》中的示例操作,首先需要创建一个显示高德地图的视图,其核心代码如下:

完整文件 AmapWidgetFactory.ets


MapsInitializer.setApiKey("e4147e927a1f63a0acff45cecf9419b5");
MapViewManager.getInstance().registerMapViewCreatedCallback((mapview?: MapView, mapViewName?: string) => {if (!mapview) {return;}let mapView = mapview;mapView.onCreate();mapView.getMapAsync((map) => {let aMap: AMap = map;})
})
struct ButtonComponent { params: ParamscustomView: AmapWidgetView = this.params.platformView as AmapWidgetViewbuild() {Row() {MapViewComponent().width('100%').height('100%')}}
}

接下来创建一个 AmapWidgetFactory.ets

export class AmapWidgetFactory extends PlatformViewFactory {message: BinaryMessenger;constructor(message: BinaryMessenger, createArgsCodes: MessageCodec<Object>) {super(createArgsCodes);this.message = message;}public create(context: common.Context, viewId: number, args: Object): PlatformView {return new AmapWidgetView(context, viewId, args, this.message);}
}

最终需要创建一个 AmapWidgetPlugin.ets

export class AmapWidgetPlugin implements FlutterPlugin {getUniqueClassName(): string {return 'AmapWidgetPlugin';}onAttachedToEngine(binding: FlutterPluginBinding): void {binding.getPlatformViewRegistry()?.registerViewFactory('com.shaohushuo.app/customView', new AmapWidgetFactory(binding.getBinaryMessenger(), StandardMessageCodec.INSTANCE));}onDetachedFromEngine(binding: FlutterPluginBinding): void {}
}

插件创建好之后,记得在 EntryAbility 中注册插件

 this.addPlugin(new AmapWidgetPlugin())

需要注意的是,视图ID一定要两侧保持一致,如这里名为 ‘com.shaohushuo.app/customView’,否则无法正常显示

截图

参考资料

  • 如何使用PlatformView
  • PlatformView同层渲染新方案
http://www.dtcms.com/a/615190.html

相关文章:

  • 能源产品网站建设多少钱网站关键词下降
  • 华容道布局(1):40种经典布局及解法图解合集
  • 网站建设常用模板下载网站推广方法有哪些
  • 没电脑可以建网站吗泰国网站的域名
  • 编译型语言 | 解析编译型语言的特点与应用
  • html5网站后台制作北京南站在哪个街道
  • 企业网站cms 开源广东新闻联播
  • SAP FICO BU损益表
  • 中山中小型网站网站关键词格式
  • 网站不能访问如何做冗余安徽省建设工程信息网安徽省政务
  • 13.vector(下)
  • wamp搭建多个网站电子商务网站建设 教学大纲
  • Rust中的for循环与迭代器
  • 食品网站建设方案wordpress 源码出售
  • 深度学习:深入理解 Softmax 激活函数
  • 【持续更新】2025华为OD机试2025双机位A卷机考真题库清单含考点说明(Java/Python/JS/C++/Go)
  • 珠海做网站设计WordPress完全删除
  • 手表网站登录页背景图建设网站推广广告图
  • 小区百货店网怎么做网站开封公司网站如何制作
  • 保研贴 | 2025年(22级)四非计算机大类专业保研历程记录
  • java基础-14 : stream流
  • 巨鹿网站建设公司怎样做网络推广挣钱
  • 网站开发管理方案合肥网站建设合肥做网站
  • Linux宝塔面板安装脚本(正式版:11.2.0)
  • 设计师网站推荐免费的自助建站
  • C Primer Plus 13.10 复习题
  • 营销网站建设网站设计sem竞价
  • 58同城网站官网网站首页设置伪静态
  • 基于springboot框架的网上商城系统的设计与实现
  • 免费做网站方法北京木马工业设计