帆js和GeoJSON格式

问题描述 投票:1回答:1

任何人都知道如何在Sails js模型中存储GEOJSON?我想在Sails js模型中存储特征和点。

var geojsonFeature = {
"type": "Feature",
"properties": {
    "name": "Coors Field",
    "amenity": "Baseball Stadium",
    "popupContent": "This is where the Rockies play!"
},
"geometry": {
    "type": "Point",
    "coordinates": [-104.99404, 39.75621]
}

};

javascript ecmascript-6 leaflet sails.js
1个回答
0
投票

Sails' Attributes documentation中,您可以找到Sail的水线支持的5种类型(Sail中的基础ORM)

  • 字符串
  • 数字
  • boolean
  • json
  • ref

在您的情况下,您嵌入了多个对象。类似以下内容可能会起作用:

attributes: {
  type: {
    type: 'string',
    enum: ['Feature','This','That','Other'], // not required...
  },
  properties: {
    type: 'json'
  },
  geometry: {
    type: 'json'
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.