我正在使用 syncfusion_flutter_maps 包在我的颤振应用程序中导入谷歌地图,但无法用它更改地图样式。它需要 urlTemplate 。我们如何在这里使用谷歌地图样式?就像我们在 Flutter 谷歌地图包中所做的那样,只需提供 json 文件即可。
在这个包中,我们需要 urlTemplate;你可以在这里结帐:https ://help.syncfusion.com/flutter/maps/tile-layer
在这里,他们使用了一些 openStreetMap url 模板,但我想使用谷歌地图样式。让我知道是否有人这样做。
SfMaps(
layers: <MapLayer>[
MapTileLayer(
/// URL to request the tiles from the providers.
///
/// The [urlTemplate] accepts the URL in WMTS format i.e. {z} —
/// zoom level, {x} and {y} — tile coordinates.
///
/// We will replace the {z}, {x}, {y} internally based on the
/// current center point and the zoom level.
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', // Want to use google maps styling here. How can I do that?
zoomPanBehavior: _zoomPanBehavior,
controller: _mapController,
initialMarkersCount: _worldWonders.length,
tooltipSettings: const MapTooltipSettings(
color: Colors.transparent,
),
markerTooltipBuilder: (BuildContext context, int index) {
if (!_isDesktop) {
return ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 150,
height: 80,
color: Colors.grey,
child: Image.asset(
_worldWonders[index].tooltipImagePath,
fit: BoxFit.fill,
),
),
Container(
padding: const EdgeInsets.only(
left: 10.0, top: 5.0, bottom: 5.0),
width: 150,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_worldWonders[index].place,
style: const TextStyle(
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text(
_worldWonders[index].state +
', ' +
_worldWonders[index].country,
style: const TextStyle(
fontSize: 10, color: Colors.black),
),
)
]),
),
]),
);
}
return const SizedBox();
},
markerBuilder: (BuildContext context, int index) {
final double _markerSize =
_currentSelectedIndex == index ? 40 : 25;
return MapMarker(
latitude: _worldWonders[index].latitude,
longitude: _worldWonders[index].longitude,
alignment: Alignment.bottomCenter,
child: GestureDetector(
onTap: () {
if (_currentSelectedIndex != index) {
_canUpdateFocalLatLng = false;
_tappedMarkerIndex = index;
_pageViewController.animateToPage(
index,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
}
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
height: _markerSize,
width: _markerSize,
child: FittedBox(
child: Icon(Icons.access_alarm,
color: _currentSelectedIndex == index
? Colors.blue
: Colors.green,
size: _markerSize),
),
),
),
);
},
),
],
),