douyuefei3546 2019-07-02 11:22
浏览 67
已采纳

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

I'm facing an issue with update data on the ArcGIS feature layer using API in PHP. Data is updating on the feature layer as expected, But data on the map is not representing. Every time when I'm pushing data to the Feature layer, Map is showing blank. But it's data section showing correct data.

Below is my code sample:-

<?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());

I'm getting success response:-

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

And data is also updated in the Feature layer data section. But that updated data points are not reflecting on the map. It seems geometry is not correct.

  • 写回答

1条回答 默认 最新

  • dqzlqfqeh845799833 2019-07-04 09:43
    关注

    You need to correct geometry data. Here is the correct:-

    {
        "x" : $longitude, 
        "y" : $latitude, 
        "spatialReference" : {
            "wkid" : 4326
        }
    }
    

    you can read documentation from here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?