How to spot different locations with colors on Map?

前端 未结 1 1796
谎友^
谎友^ 2021-01-16 18:29

Let me tell you what my motive is. I am making an app in which the locations which are highly affected by COVID is displayed by red, orange, and green colors. They are actua

相关标签:
1条回答
  • 2021-01-16 19:03

    I found this. It is easy as flutter provides you to write the single line code in the Widgets, so you can easily do the same.

    for (var index in mapDataFinal)
     if (redZoneData.contains(index))
      new Marker(
      width: 80.0,
      height: 80.0,
      point: new LatLng(26.8467, 80.9462),
      builder: (ctx) => new Container(
                              height: 10,
                              width: 10,
                              decoration: new BoxDecoration(
                                shape: BoxShape.circle,
                                color: Colors.red,
                              ),
                            ),
                          )
    

    Don't need to put curly braces over there. Full Code is here:

    new MarkerLayerOptions(markers: [
                      for (var index in mapDataFinal)
                        if (redZoneData.contains(index))
                          new Marker(
                            width: 80.0,
                            height: 80.0,
                            point: new LatLng(26.8467, 80.9462),
                            builder: (ctx) => new Container(
                              height: 10,
                              width: 10,
                              decoration: new BoxDecoration(
                                shape: BoxShape.circle,
                                color: Colors.red,
                              ),
                            ),
                          )
                        else if (orangeZoneData.contains(index))
                          new Marker(
                            width: 80.0,
                            height: 80.0,
                            point: new LatLng(10.8505, 76.2711),
                            builder: (ctx) => new Container(
                              height: 10,
                              width: 10,
                              decoration: new BoxDecoration(
                                shape: BoxShape.circle,
                                color: Colors.orange,
                              ),
                            ),
                          )
                        else if (greenZoneData.contains(index))
                          new Marker(
                            width: 80.0,
                            height: 80.0,
                            point: new LatLng(22.2587, 71.1924),
                            builder: (ctx) => new Container(
                              height: 10,
                              width: 10,
                              decoration: new BoxDecoration(
                                shape: BoxShape.circle,
                                color: Colors.green,
                              ),
                            ),
                          )
                    ]),
    
    0 讨论(0)
提交回复
热议问题