Google maps 如何在颤振中的当前位置创建圆
我正在做颤振项目。我必须在谷歌地图上的当前位置上画一个圆圈。有人知道吗 我想在《颤栗》中这样Google maps 如何在颤振中的当前位置创建圆,google-maps,flutter,flutter-layout,Google Maps,Flutter,Flutter Layout,我正在做颤振项目。我必须在谷歌地图上的当前位置上画一个圆圈。有人知道吗 我想在《颤栗》中这样 提前感谢。一种方法是更改标记的图标 mapController.addMarker(MarkerOptions( position: LatLng(37.4219999, -122.0862462), icon: BitmapDescriptor.fromAsset('images/circle.png',), ), ); 在android/ios上设置适当的权限后,在go
提前感谢。一种方法是更改标记的图标
mapController.addMarker(MarkerOptions(
position: LatLng(37.4219999, -122.0862462),
icon: BitmapDescriptor.fromAsset('images/circle.png',),
),
);
在android/ios上设置适当的权限后,在google maps选项上设置trackCameraPosition:true
和myLocationEnabled:true
,然后您可以通过以下代码在当前位置添加图像
mapController.addMarker(MarkerOptions(
position: mapController.cameraPosition.target,
icon: BitmapDescriptor.fromAsset('images/circle.png',),
),
);
这是一篇优秀的文章,解释了使用Google Maps for Flatter(开发者预览)插件可以做的所有事情。请记住Google Maps小部件是开发者预览版,版本为0.2。未来几个月,许多事情和能力可能会发生变化。在 但谷歌团队并没有接受,因为提交人的许可证存在问题。我不知道这是否会被合并。有很多拉取请求被接受,但没有集成。如果使用插件,则可以轻松绘制半径圆。这是代码
FlutterMap(
options: MapOptions(
center: LatLng(latitude, longitude),
zoom: 16.0
),
layers: [
TileLayerOptions(
urlTemplate: "map url",
additionalOptions: {
"accessToken" : "xxx",
"id" : "map id"
}
),
MarkerLayerOptions(
markers: Marker( //marker
width: 25.0,
height: 25.0,
point: LatLng(latitude, longitude),
builder: (context) {
return Container(
child: IconButton(
icon: Icon(Icons.my_location),
iconSize: 25.0,
color: Color(0xff9045f7),
onPressed: () {
print('marker tapped');
},
),
);
}
)
),
CircleLayerOptions(
circles: CircleMarker( //radius marker
point: LatLng(latitude, longitude),
color: Colors.blue.withOpacity(0.3),
borderStrokeWidth: 3.0,
borderColor: Colors.blue,
radius: 100 //radius
)
)
],
),)
此功能现已在google_maps_颤振软件包中提供: 部分示例:
Set<Circle> circles = Set.from([Circle(
circleId: CircleId(id),
center: LatLng(latitude, longitude),
radius: 4000,
)]);
GoogleMap(
mapType: MapType.normal,
myLocationEnabled: true,
myLocationButtonEnabled: true,
initialCameraPosition: initialMapLocation,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
onCameraMove: null,
circles: circles,
);
Set circles=Set.from([Circle(
circleId:circleId(id),
中心:经纬度,
半径:4000,
)]);
谷歌地图(
mapType:mapType.normal,
myLocationEnabled:对,
myLocationButtonEnabled:正确,
initialCameraPosition:initialMapLocation,
onMapCreated:(谷歌地图控制器){
_控制器。完成(控制器);
},
onCameraMove:null,
圆圈:圆圈,
);
:谢谢,让我检查一下你的答案和文章。有什么理由画这个圆圈吗?它是否表示当前位置的误差/精度(这是当前流行的地图/导航应用程序的设计)?我想用不同的颜色设置当前位置周围的半径。我是指在当前位置周围设置半径的理由吗?它是否表示不同的半径(1英里、5英里),是否仅出于美学原因等?它仅用于我所选半径上的美学原因,无论我在其上指定了什么。所有特定位置都应向我显示,如餐厅、医院等所选圆半径。我认为此“答案”更像是一个注释而不是答案。谢谢,我的问题是从哪里可以找到访问令牌?@Hardik1344您必须使用才能使用此插件。Mapbox地图也类似于谷歌地图。在Mapbox中创建帐户后,您将获得一个访问令牌。与Google Mapbox不同,Mapbox不需要付费帐户来获取访问令牌。@Thanooshan如何使用Mapbox和map库绘制路由?@Taleb请尝试此插件并查看。谢谢你的努力,我会检查它,然后返回这个圆半径的测量单位是多少?是米还是什么?你发布的链接不起作用。。。还有,你是如何得到圆圈ID的。一个详细的答案是什么需要!!!