![](/img/trans.png)
[英]Use current location to draw poly lines to a destination and also to add markers on google maps with markers flutter
[英]How to use location markers as buttons in Flutter?
我正在 Flutter 中制作一個運輸(資產)跟蹤應用程序。 並使用谷歌地圖插件在谷歌地圖中顯示所有不同的資產。 我想在用戶單擊資產的當前位置標記時顯示有關資產的信息。 在 simpleton 中,我想將位置標記用作按鈕。 如果有任何其他方法可以實現此目的,請分享。
必須有一些代碼來添加標記,如下所示,只需添加onTap
markers.add(
Marker(
zIndex: 100,
markerId: MarkerId(myList[i].code),
position: LatLng(myList[i].latitude, myList[i].longitude),
icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed)
),
onTap: () {
//this is what you're looking for!
setState(() {
currCode=myList[i].code;
//call something here with myList[i].code or store in global constant for widget state
});
}
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.