颤音:地图摄像头位置不更新到新的Latlong
我正在使用流构建器,该材料在几秒钟后发送API请求并提取坐标(LAT,LNG)。
我想在新提取坐标上更新地图位置(相机位置&标记)。
但是相机位置正在更新,而不是专注于新的坐标。 我的Google Map小部件位于Stream Builder内部,我们正在通过快照传递数据 例如latlng = latlng(snapshot.data ['lat'],snapshot.data ['lng'])
to 标记:setMarker(Markers,MarkerId,latlng,latlng,),
> & 初始cameraposition:cameraposition(目标:latlng,Zoom:9.0,)
I am using Stream Builder that sends api request after some seconds and fetch coordinates (lat, lng).
I want to update the map location (camera position & marker) on newly fetch coordinates.
But Camera position is updating and not focusing on new coordinates.
My google map widget is inside of stream builder and in which we are passing data through snapshot
e.g latlng = LatLng(snapshot.data['lat'],snapshot.data['lng'])
to markers: SetMarker( markers, markerID, latlng, ),
& initialCameraPosition: CameraPosition( target: latlng, zoom: 9.0, )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Googlemaps flutter上的小部件确实具有属性initialcameraposition,但顾名思义,这只是一个初始值,如果您想在加载它后要更新地图,我建议您使用回调on mapcreated,您可以在其中使用控制器。动画到某个位置。
这样做会看起来像这样:
希望这会有所帮助! )
The GoogleMaps widget on Flutter does have the attribute initialCameraPosition but as the name says this is just an initial value, if you want to update the map once this has loaded i'd recommend the use of the callback onMapCreated, where you can use the controller to animate to a certain position.
Doing so would look something like this:
Hope this helps! ;)