How to create circle on current location in flutter

后端 未结 5 2012
旧时难觅i
旧时难觅i 2021-02-07 07:06

I am working on flutter project.On which I have to draw one circle on my current location on google map.Does any one have idea.

I want like this in flutter

5条回答
  •  死守一世寂寞
    2021-02-07 07:29

    If you use flutter_map plugin, then you can draw radius circle easily. Here is the code.

    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
                )
            )
        ],
    ),)
    

提交回复
热议问题