使用react传单显示GeoJSON中不同类型对象的最有效方法

使用react传单显示GeoJSON中不同类型对象的最有效方法,geojson,react-leaflet,Geojson,React Leaflet,这是我的GeoJSON示例,它将后端提供给前端 { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { deviceType: 'mine' }, geometry: { type: 'Point', coordinates: [-0.2197265625, 51.27050757321479], },

这是我的GeoJSON示例,它将后端提供给前端

{
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: { deviceType: 'mine' },
      geometry: {
        type: 'Point',
        coordinates: [-0.2197265625, 51.27050757321479],
      },
    },
    {
      type: 'Feature',
      properties: { deviceType: 'mine'},
      geometry: {
        type: 'Point',
        coordinates: [-0.2327265623, 51.27022757321422],
      },
    },
    {
      type: 'Feature',
      properties: { deviceType: 'favorite' },
      geometry: {
        type: 'Point',
        coordinates: [-0.263671875, 51.445448545784195],
      },
    },
    {
      type: 'Feature',
      properties: { deviceType: 'public' },
      geometry: {
        type: 'Point',
        coordinates: [0.10711669921875, 51.43346414054374],
      },
    },
}
我左右为难,我应该走哪条路:

  • 在后端,将响应拆分为多个GeoJSON对象,然后在前端,我可以用标准方式处理每个实例(不太喜欢这个解决方案)

  • 发送一个GeoJSON对象,该对象包含my features的所有变体,并在前端地图上通过features对其进行分组

目前,我使用第二个选项,首先映射特征并按“deviceType”键对它们进行分组,然后将react传单中的GeoJSON层分配给它们,然后将其提供给react laeflet映射

这就是我正在做的吗?如果源json变得非常大,我应该担心吗?还有其他建议如何正确地做到这一点

谢谢你,内纳德