gpt4 book ai didi

google-maps - 在 flutter map_view 中样式化 poi

转载 作者:IT王子 更新时间:2023-10-29 07:05:56 56 4
gpt4 key购买 nike

MapStyleOptions 等价于什么

boolean success = googleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.style_json));

在飞镖/flutter 中?

如何使用我从 https://mapstyle.withgoogle.com/ 获得的以下样式在 flutter 中设置 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) 昨天刚刚合并。仍在努力弄清楚,但它终于来了!

关于google-maps - 在 flutter map_view 中样式化 poi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52910329/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com