How to create AddEdit app from sample?

835
4
Jump to solution
05-24-2017 04:06 AM
MikalaRandich
New Contributor II

Hello,

I am trying to create an app from the Add/Edit sample provided in App Studio (Desktop 1.4.18) and am having trouble changing it to use one of our feature service layers instead of the provided default. I'm not very good with coding, but have changed these lines in Qt to try to get the app to load a different feature service layer from ArcGIS Online, but none of the points hosted in the feature service appear in the app and it is no longer "clickable" to add a new point. Any advice on what I'm doing wrong would be greatly appreciated!

Thank you,

Mikala

Changed line 36 from 

property string featureServiceURL : appWindow.info.propertyValue("featureServiceURL","");
to
property string featureServiceURL : appWindow.info.propertyValue("https://services1.arcgis.com/5Gtv38l8677OspKm/arcgis/rest/services/survey_database_join/FeatureServe...","");

Changed line 70 from 

url: appWindow.info.propertyValue("basemapServiceUrl", "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")
to 
url: appWindow.info.propertyValue("basemapServiceUrl", "https://scgis.maps.arcgis.com/home/webmap/viewer.html?webmap=c0e67a328e69428ba26209544a613255")

Changed line 76 from
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0"
to
url: "https://services1.arcgis.com/5Gtv38l8677OspKm/arcgis/rest/services/database_survey_join/FeatureServe..."

0 Kudos
1 Solution

Accepted Solutions
nakulmanocha
Esri Regular Contributor

Please revert the changes back to original code.

You cannot replace basemapserviceurl with a webmap. So if you are interested in a specific basemap get the url and replace it with the one on line 70. But remember it is optional.

Only thing you really need to change is the featureservice url on line 76. Also url of the layer must end with some index such as "0" which defines the Layer index. So the right url would be

https://services1.arcgis.com/5Gtv38l8677OspKm/arcgis/rest/services/database_survey_join/FeatureServe... 

And it looks like your layer is secured which requires OAuth 2.0 authentication. For that please refer this 

Use OAuth 2.0 authentication—ArcGIS Runtime SDK for Qt | ArcGIS for Developers 

But for testing purpose just make your service publically available for brief moment and test the layer as mentioned above in the sample and you should be able to add and view features.

I hope this helps.

Nakul

View solution in original post

4 Replies
nakulmanocha
Esri Regular Contributor

Please revert the changes back to original code.

You cannot replace basemapserviceurl with a webmap. So if you are interested in a specific basemap get the url and replace it with the one on line 70. But remember it is optional.

Only thing you really need to change is the featureservice url on line 76. Also url of the layer must end with some index such as "0" which defines the Layer index. So the right url would be

https://services1.arcgis.com/5Gtv38l8677OspKm/arcgis/rest/services/database_survey_join/FeatureServe... 

And it looks like your layer is secured which requires OAuth 2.0 authentication. For that please refer this 

Use OAuth 2.0 authentication—ArcGIS Runtime SDK for Qt | ArcGIS for Developers 

But for testing purpose just make your service publically available for brief moment and test the layer as mentioned above in the sample and you should be able to add and view features.

I hope this helps.

Nakul

MikalaRandich
New Contributor II

Hi Nakul,

Thank you so much for your help! Your instructions worked well, I made the online feature service shared with 'everyone' and now the app allows me to view, click, and edit features from the layer I wanted. However, I still can't click and add a new point, and ideally I'd like to change the basemap to World Imagery, which I attempted but didn't work. Any further suggestions? Let me know if you'd like to look at the entire code or different portions of it.

Thanks again,

Mikala 

//BASEMAP
        ArcGISTiledMapServiceLayer {
            url: appWindow.info.propertyValue("basemapServiceUrl", "http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer")
        }

 //ADD POINT FUNCTION
    function addPoint(pointX, pointY, pointSR) {
        if (addButtonClicked == "add item"){
            //console.log(pointX+500);
            var featureJson = {
                geometry: {
                    x: pointX,
                    y: pointY,
                    spatialReference: pointSR
                },
                attributes: {
                    eventtype : "eventtype",
                    eventdate : "district",
                    eventtype: 17
                }
            }
        }
        if (featureServiceTable.featureTableStatus === Enums.FeatureTableStatusInitialized) {
            var newFeature = featureServiceTable.addFeature(featureJson);
            dispTable(newFeature);
        }
    }
0 Kudos
nakulmanocha
Esri Regular Contributor

To change the basemap. Please make the edit in the appinfo.json properties like below. That is where it picks the basemapServiceurl value

"properties": {
        "basemapServiceUrl": "http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer",
        "titleBackgroundColor": "#00b2ff",
        "titleTextColor": "#fefdfd"
    },

Also make sure your feature service layer has the editing permissions to add new features from the  Feature Layer (hosted settings.

Finally make sure the attributes match to attributes listed in the Add Point function code. I am sure your feature layer doesn't have the following attributes

attributes: {
                    eventtype : "eventtype",
                    eventdate : "district",
                    eventtype: 17
                }
MikalaRandich
New Contributor II

Thank you so much for your help!

0 Kudos