简体   繁体   中英

ArcGIS Online: Populate an existing form dynamically with Hosted Feature Layer Data

I have a pre-existing form (.pdf &.doc) that I am trying populate with attribute data from an ArcGIS Online hosted feature layer. I am not sure if there is a way to use the ArcGIS API for Javascript with FPDF? or if there is another method for doing something like this.

I have tried the following method and it works just fine, but I do not want to have to download the data periodically to handle any new data that has come in. Also, I am looking to have this form be produced when a user clicks on a link in a popup with the web mapping application (screenshot below).

https://justincolegis.com/2017/12/13/using-survey123-or-any-gis-data-to-populated-reports-in-word/

screenshot of popup

**Update: Basically what I do not know how to do, since moving our data to hosted feature layers, is how to grab the attributes from the feature and place that information into an already existing pdf document/form.

Below is a section of the PHP file that uses FPDF and arrays by querying the Oracle table. This works for old data sitting that resides on our server in the Oracle table but this does not work for new data that has gone in to the layer since moving it to a hosted feature layer.

    /Query
    $query = 'SELECT OBJECTID, SITEID, TARGET_SPECIES, DATE_TREATMENT, WATER_BODY,
     AQ_WORKERS, AQ_WEATHER, AQ_WINDSPEED, AQ_TEMP, AQ_WINDDIRECTION, AQ_TOTAL_AI,
     AQ_MIX_USED, AQ_RAIN, AQ_TREATMENT_TYPE, LOCATION, ST_GROUP, COUNTY, AQ_CONTROL_METHOD,
     AQ_APPLICATION_METHOD, AQ_CHEMICALUSED, CH_EPACONCENTRATION,
     AQ_CHEMICALUSED2, CH_EPACONCENTRATION2, MT_COMPANY, NPDES_COC, PDMP,
     AQ_RATEOFAPPLICATION, LATITUDE, LONGITUDE, AQ_MIX_RATE, APPLICATION_AREA, 
     AQ_EFFECTIVENESS FROM WEB_AQTREATMENT WHERE OBJECTID = '.$_GET['id'];

        ob_start();
        $pdf = new FPDI();
        $pdf->addPage('P');
        $pagecount = $pdf->setSourceFile('../../../../../treatment_form.pdf');
        $tplIdx = $pdf->importPage(1);
        $pdf->useTemplate($tplIdx);
        $pdf->SetFont('Helvetica','I',9);
        $pdf->SetTextColor(0,0,0);
        //
        //PERMITTEE INFORMATION
        //
        //PermitNumber (L/R), (U/D)
        $pdf->SetXY(114, 69);
        $pdf->Write(0, $array[20]);
        //Permittee Name (L/R), (U/D)
        $pdf->SetXY(114, 80);
        $pdf->Write(0, $array[19]);
        //Body of Water Treated (L/R), (U/D)
        $pdf->SetXY(114, 92);
        $pdf->Write(0, $array[4]);
        //County
        $pdf->SetXY(176, 92);
        $pdf->Write(0, $array[16]);
        //Date (L/R), (U/D)
        $pdf->SetXY(41.5, 135.5);
        //$pdf->MultiCell(30,5,$array[3],0, 'L');
        $pdf->Write(0,$array[3]);
        //Name of Person Applying Chemical (L/R), (U/D)
        $pdf->SetXY(73, 134);
        $pdf->MultiCell(65,5,$array[5],0,'L');
        //Name of Company (L/R), (U/D)
        $pdf->SetXY(142, 136.5);
        $pdf->Write(0, $array[25]);

If the feature service has every field you need in the form, then instead of sending only the id you could send all the fields you need, or you could even use graphic toJSON method to serialize it and then send everything,

function popupContent (feature) {
    // your custom popup content
    ...
    // instead of sending id send all the graphic data
    fetch(url, {
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        headers: {
          'Content-Type': 'application/json'
        },
        body: feature.graphic.toJSON()
    });
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM