Skip to content

Data Presentation

API Design

On the location search page, users only need to define a simple JSON format to display location data on the map. We have defined the relevant specifications, which are dynamically used in the UI rendering. You just need to follow the specifications during development.
There are two main ways to obtain data sources: open data API and static JSON. Please refer to the detailed explanation for usage.

The complete JSON format is as follows:

JSON
{
  "list": [
    {
      "name": "交通運輸、停車場、充電站",
      "places": [
        {
          "id": "pa-1",
          "name": "微笑單車 2.0",
          "icon": "",
          "agency": "台北市政府交通局",
          "type": "交通運輸、停車場、充電站",
          "data_type": "api",
          "request_url": "https://tcgbusfs.blob.core.windows.net/dotapp/youbike/v2/youbike_immediate.json",
          "data_path": "",
          "format_fields": {
            "id": "sno",
            "name": "sna",
            "area": "sarea",
            "address": "ar",
            "lat": "latitude",
            "lng": "longitude"
          },
          "service_infos": [
            {
              "title": "備註",
              "value_fields": [
                {
                  "title": "可借車輛",
                  "value_field": "available_rent_bikes"
                },
                {
                  "title": "可停空位",
                  "value_field": "available_return_bikes"
                }
              ]
            },
            {
              "title": "更新時間",
              "value_field": "updateTime"
            }
          ]
        },
        {
          "id": "pa-3",
          "name": "停車場",
          "icon": "",
          "agency": "台北市停車管理工程處",
          "type": "交通運輸、停車場、充電站",
          "data_type": "json",
          "request_url": "/public/mock/find-place/TCMSV_alldesc.json",
          "data_path": "",
          "format_fields": {
            "id": "id",
            "name": "name",
            "area": "area",
            "address": "address",
            "lat": "EntranceCoord.EntrancecoordInfo[0]?.Xcod",
            "lng": "EntranceCoord.EntrancecoordInfo[0]?.Ycod"
          },
          "service_infos": [
            {
              "title": "概況",
              "value_field": "summary"
            },
            {
              "title": "費率",
              "value_field": "payex"
            }
          ]
        }
      ]
    },
    {
      "name": "飲水機、公廁、哺集乳室、AED場所",
      "places": [
        {
          "id": "pb-1",
          "name": "飲水機/提供飲水店家",
          "icon": "/public/images/icon_drinking.svg",
          "agency": "台北市政府環境保護局",
          "type": "飲水機、公廁、哺集乳室、AED場所",
          "data_type": "api",
          "request_url": "https://data.taipei/api/v1/dataset/52538305-ed23-490c-8f67-3efff2d777c3?scope=resourceAquire",
          "data_path": "result.results",
          "format_fields": {
            "id": "_id",
            "name": "場所名稱",
            "area": "行政區",
            "address": "場所地址",
            "lat": "緯度",
            "lng": "經度"
          },
          "service_infos": [
            {
              "title": "場所開放時間",
              "value_field": "場所開放時間"
            },
            {
              "title": "飲水台數",
              "value_field": "飲水台數"
            }
          ]
        },
        {
          "id": "pb-3",
          "name": "公廁",
          "icon": "/public/images/icon_toilet.svg",
          "agency": "",
          "type": "飲水機、公廁、哺集乳室、AED場所",
          "data_type": "json",
          "request_url": "/public/mock/find-place/public_toilet_taipei.json",
          "data_path": "",
          "format_fields": {
            "id": "id",
            "name": "name",
            "area": "city",
            "address": "address",
            "lat": "latitude",
            "lng": "longitude"
          },
          "service_infos": [
            {
              "title": "等級",
              "value_field": "grade"
            }
          ]
        }
      ]
    }
  ]
}

Data Field Descriptions

Service Map - Data

FieldPurposeExample
nameService map category, displayed as a header in the map menuTransportation, Parking, Charging Stations
placesService locations under this categorySee table below

Places

FieldPurposeExample
idKeypa-1
nameService map nameYouBike 2.0
iconIcon, place image files in the /public/images directory; if empty, no icon will be displayed/public/images/icon_drinking.svg
agencyService providing agencyTaipei City Government Department of Transportation
typeCategory to which the map belongsTransportation, Parking, Charging Stations
data_typeData source formatapi or json
request_urlData retrieval URL
If json, place the static json file in the /public/mock directory and reference it
api: https://tcgbusfs.blob.core.windows.net/dotapp/youbike/v2/youbike_immediate.json
json: /public/mock/find-place/TCMSV_alldesc.json
data_pathIf the data return value is not an array, specify the path to the data object; if the return value is an array, leave it blankresult.results
(i.e., the data object is located in the responseData.result.results array)
format_fieldsData field mappingSee table below format_fields
service_infosDetailed data informationSee table below service_infos

Format Fields

This section is mainly used to map fields from different data sources by filling in the field names of the data.

FieldPurposeExample
idKeyFill in the field name for the key value in the data
Required
nameLocation nameFill in the field name for the location name in the data
Required
areaLocation area, e.g., districtFill in the field name for the location area in the data
Required
addressDetailed location addressFill in the field name for the detailed location address in the data
Required
latLatitudeFill in the field name for the latitude in the data
Required; without latitude, the location cannot be plotted on the map
lngLongitudeFill in the field name for the longitude in the data
Required; without longitude, the location cannot be plotted on the map

Service Infos

FieldPurposeExample
titleTitle of the detailed informationRemarks
value_fieldsContains multiple sub-details; each item corresponds to a title and its associated value_field, presenting multiple related pieces of information under the same titleChoose between value_fields or value_field, see JSON above for details
value_fieldContains a single sub-detail, corresponding to a single data field, presenting a single piece of informationChoose between value_field or value_fields, see JSON above for details