1

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.

2

I do not think "latitude" and "longitude" are valid property names to be sent in as a geometry. See the documentation here - I think you want to send an "x", "y", and "spatialReference", like this:

{"x" : $longitude, "y" : $latitude, "spatialReference" : {"wkid" : 4326}}
  • your answer is right. But there is one mistake. here is the correct geomatery {"x" : $longitude, "y" : $latitude, "spatialReference" : {"wkid" : 4326}}. Please correct this, So I can mark as verify. – Lakhwinder Singh Jul 4 at 9:38
  • 1
    @LakhwinderSingh done – GavinR Jul 8 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.