google-maps - Flutter map_view 中的样式 poi
问题描述
相当于什么MapStyleOptions
boolean success = googleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.style_json));
在飞镖/颤振中?
如何使用我从https://mapstyle.withgoogle.com/获得的以下样式设置 map_view 的样式
[
{
"featureType": "poi.government",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.medical",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.place_of_worship",
"stylers": [
{
"visibility": "off"
}
]
}
]
这是我的应用程序:
import 'package:flutter/material.dart';
import 'package:map_view/map_view.dart';
var api_key = "AIzaSyDrHKl8IxB4cGXIoELXQOzzZwiH1xtsRf4";
void main() {
MapView.setApiKey(api_key);
runApp(new MaterialApp(
debugShowCheckedModeBanner: false,
home: new MapPage(),
));
}
class MapPage extends StatefulWidget {
@override
_MapPageState createState() => new _MapPageState();
}
class _MapPageState extends State<MapPage> {
MapView mapView = new MapView();
CameraPosition cameraPosition;
var staticMapProvider = new StaticMapProvider(api_key);
Uri staticMapUri;
List<Marker> markers = <Marker>[
new Marker("1", "BSR Restuarant", 28.421364, 77.333804,
color: Colors.amber),
new Marker("2", "Flutter Institute", 28.418684, 77.340417,
color: Colors.purple),
];
showMap() {
mapView.show(new MapOptions(
mapViewType: MapViewType.normal,
initialCameraPosition:
new CameraPosition(new Location(28.420035, 77.337628), 15.0),
showUserLocation: true,
title: "Recent Location"));
mapView.setMarkers(markers);
mapView.zoomToFit(padding: 100);
mapView.onMapTapped.listen((_) {
setState(() {
mapView.setMarkers(markers);
mapView.zoomToFit(padding: 100);
});
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
cameraPosition =
new CameraPosition(new Location(28.420035, 77.337628), 2.0);
staticMapUri = staticMapProvider.getStaticUri(
new Location(28.420035, 77.337628), 12,
height: 400, width: 900, mapType: StaticMapViewType.roadmap);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Flutter Google maps"),
),
body: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Container(
height: 300.0,
child: new Stack(
children: <Widget>[
new Center(
child: Container(
child: new Text(
"Map should show here",
textAlign: TextAlign.center,
),
padding: const EdgeInsets.all(20.0),
),
),
new InkWell(
child: new Center(
child: new Image.network(staticMapUri.toString()),
),
onTap: showMap,
)
],
),
),
new Container(
padding: new EdgeInsets.only(top: 10.0),
child: new Text(
"Tap the map to interact",
style: new TextStyle(fontWeight: FontWeight.bold),
),
),
new Container(
padding: new EdgeInsets.only(top: 25.0),
child: new Text(
"Camera Position: \n\nLat: ${cameraPosition.center
.latitude}\n\nLng:${cameraPosition.center
.longitude}\n\nZoom: ${cameraPosition.zoom}"),
),
],
),
);
}
}
解决方案
看起来像这样(https://github.com/flutter/plugins/pull/1697)昨天刚刚合并。仍在试图弄清楚,但它终于来了!
推荐阅读
- lodash - `underscore`和`lodash`的`escape`和`unescape`功能一样吗?
- c - 无法从分叉进程内部处理 Linux 上的信号
- r - 如何在 knit 和 rmarkdown 中注册 Racket 引擎?
- python-3.x - 在 Python 3.7 中使用 ExchangeLib 读取 Outlook 中的自定义标签/标志
- r - 如何在特定表中插入有关相似性度量(igraph)的结果?
- sql - 如何使用 sp_ExecuteSql 对名称在变量中的数据库运行带参数的查询
- openshift - 使用 Python 管理 Openshift 集群
- logging - 在linux中匹配模式> 0后获取行
- javascript - Discord.js awaitMessages 循环?
- c# - 从 Utils.CopyArray 复制 C# 数组,我的源代码不会转换