使用PHP中的API更新ArcGIS Feature图层数据

时间:2019-07-02 11:22:30

标签: php arcgis-js-api

我正在使用PHP中的API在ArcGIS要素图层上更新数据时遇到问题。数据正在要素图层上按预期方式进行更新,但是地图上的数据无法表示。每次将数据推送到要素图层时,地图都会显示为空白。但这是显示正确数据的数据部分。

下面是我的代码示例:-

<?php

$feature = [
    'geometry' => [
        'longitude' => $longitude,
        'latitude' => $latitude
    ],
    'attributes' => [
        'id'                                => (int) $item->id,
        'project_name'                      => (string) $item->project_name,
        'queue_position'                    => (string) $item->queue_position,
        'request_receive_date'              => $item->request_receive_date,
        'queue_date'                        => $item->queue_date,
        'application_status'                => (string) $item->application_status,
        'study_process'                     => (string) $item->study_process,
        'type_1'                            => (string) $item->type_1,
        'type_2'                            => (string) $item->type_2,
        'fuel_1'                            => (string) $item->fuel_1,
        'fuel_2'                            => (string) $item->fuel_2,
        'mw_1'                              => (string) $item->mw_1,
        'mw_2'                              => (string) $item->mw_2,
        'mw_total'                          => (string) $item->mw_total,
        'deliverability_status'             => (string) $item->deliverability_status,
        'county'                            => (string) $item->county,
        'state'                             => (string) $item->state,
        'utility'                           => (string) $item->utility,
        'substation_or_transmission_line'   => (string) $item->substation_or_transmission_line,
        'proposed_online_date'              => $item->proposed_online_date,
        'current_online_date'               => $item->current_online_date,
        'supplemental_review'               => (string) $item->supplemental_review,
        'phase_1_cluster_study'             => (string) $item->phase_1_cluster_study,
        'phase_2_cluster_study'             => (string) $item->phase_2_cluster_study,
        'optional_study'                    => (string) $item->optional_study,
        'agreement_status'                  => (string) $item->agreement_status,
        'latitude'                          => $latitude,
        'longitude'                         => $longitude
    ]
];

$formParams = [
    'token'                 => 'aUIIAqYYo3gx-5rgBGxLGBFOn_KOm9bbNe..',
    'features'              => json_encode([$feature]),
    'f'                     => 'json',
];

$url = "https://services9.arcgis.com/Azs8YqOMYfa7g8wo/arcgis/rest/services/test_layer/FeatureServer/0/addFeatures";

// I'm using guzzle.
$client = new Client();
$response = $client->post($url, ['form_params' => $formParams]);
$result = json_decode($response->getBody());

我得到了成功的回应:-

{
    "code": 200,
    "message": "Success",
    "data": {
        "addResults": [
            {
                "objectId": 32,
                "uniqueId": 32,
                "globalId": null,
                "success": true
            },
            ...
        ]
    }
}

并且要素图层数据部分中的数据也会更新。但是更新的数据点未反映在地图上。看来几何形状不正确。

1 个答案:

答案 0 :(得分:3)

您需要更正几何数据。 这是正确的:-

if (( chekk > 40 )); then

您可以阅读here

中的文档