调整地图样式
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||
|
||||
@@ -10,23 +11,21 @@ class MapPage extends GetView<MapController> {
|
||||
return Stack(
|
||||
children: [
|
||||
InAppWebView(
|
||||
// 确保 pubspec.yaml 中声明了 assets/html/map.html
|
||||
initialFile: 'assets/html/map.html',
|
||||
initialSettings: InAppWebViewSettings(
|
||||
isInspectable: true,
|
||||
geolocationEnabled: true,
|
||||
// 允许 JS 弹窗 (Alert) 用于调试
|
||||
javaScriptCanOpenWindowsAutomatically: true,
|
||||
// 既然完全依赖 Flutter 定位,建议把 WebView 的定位彻底关掉,防止 JS 意外触发
|
||||
geolocationEnabled: false,
|
||||
javaScriptEnabled: true,
|
||||
// Android 混合开发推荐配置
|
||||
useHybridComposition: true, // 提升地图渲染性能(重要)
|
||||
allowFileAccessFromFileURLs: true, // 允许本地 html 访问本地资源
|
||||
allowUniversalAccessFromFileURLs: true,
|
||||
),
|
||||
onWebViewCreated: (c) {
|
||||
controller.webViewController = c;
|
||||
},
|
||||
onLoadStop: (c, url) {
|
||||
// 通知 Controller 页面加载完毕
|
||||
controller.onWebViewLoadStop();
|
||||
},
|
||||
// 当 WebView 创建完成后,将 controller 实例传递给我们的 MapController
|
||||
onWebViewCreated: controller.onWebViewCreated,
|
||||
onConsoleMessage: (controller, consoleMessage) {
|
||||
// 方便在 Flutter 控制台看 JS 日志
|
||||
// 方便在 Flutter 控制台查看来自 JS 的日志
|
||||
print("JS Log: ${consoleMessage.message}");
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user