Load GPX file into viewer Javascript API

6099
9
Jump to solution
01-16-2014 04:05 AM
RobinAlexis_Olaya
New Contributor
Hi, i´m need load a gpx file into viewer build on Javascript API. How i'll do it?
0 Kudos
1 Solution

Accepted Solutions
9 Replies
RobertoPepato
Occasional Contributor II
I don't think you can do this directly through the Javascript API.

One thing you can do is:

Author and publish a geoprocessing service using model builder or arcpy that does de job of converting GPX data do Feature Class (more info: http://resources.arcgis.com/en/help/main/10.2/index.html#//001200000050000000), execute this geoprocessing service and add the resultant layer to the map through the Javascript API.

Regards.

Roberto Pepato.
0 Kudos
RobinAlexis_Olaya
New Contributor
I don't think you can do this directly through the Javascript API.

One thing you can do is:

Author and publish a geoprocessing service using model builder or arcpy that does de job of converting GPX data do Feature Class (more info: http://resources.arcgis.com/en/help/main/10.2/index.html#//001200000050000000), execute this geoprocessing service and add the resultant layer to the map through the Javascript API.

Regards.

Roberto Pepato.


Hi, thanks but i did that, the problem is i'm not know how load o drag/drop the gpx file and the js code get this to entry parameter.

Example:

  function processCsvData2 (file){
   var params = {"GpxFile":file}

   gp3.submitJob(params, completeCallback3 , statusCallback3,function(error){
    alert(error);
    esri.hide(loading);
   });
  }

      function completeCallback3(jobInfo){
        if(jobInfo.jobStatus !== "esriJobFailed"){
          gp3.getResultData(jobInfo.jobId,"GpxToShape", displayResult2);
        }
      }
  
function statusCallback3(jobInfo) {
        var status = jobInfo.jobStatus;
        if(status === "esriJobFailed"){
          alert(status);
          esri.hide(loading);
        }
        else if (status === "esriJobSucceeded"){
          esri.hide(loading);
        }
    }
0 Kudos
RobertoPepato
Occasional Contributor II
Let me see if I got it right:

What you're saying is that you need to know how to set the Input_GPX_File parameter to the GP service?

If the answer is yes, I think that you should use a file uploader component to upload the gpx file to a directory on the remote file system (your webserver). This directory should be shared and accessible by the server that was running AGS (in case of separate servers). Then, you could assume that your AGS server already knows the path to the remote directory( e.g. /mnt/share/gpxfiles ) and you can compose the already know part with the file name after the upload and prior to the GP execution.

For example, if you are processing a file called police.gpx, assuming the fixed prefix, you could just build the "/mnt/share/gpxfiles/police.gpx" string and pass it to te GP Service. Better yet, you can compose this string inside the GP service so nobody will never now the paths to your filesystem.

Regards.

Roberto Pepato.
0 Kudos
RobinAlexis_Olaya
New Contributor
Let me see if I got it right:

What you're saying is that you need to know how to set the Input_GPX_File parameter to the GP service?

If the answer is yes, I think that you should use a file uploader component to upload the gpx file to a directory on the remote file system (your webserver). This directory should be shared and accessible by the server that was running AGS (in case of separate servers). Then, you could assume that your AGS server already knows the path to the remote directory( e.g. /mnt/share/gpxfiles ) and you can compose the already know part with the file name after the upload and prior to the GP execution.

For example, if you are processing a file called police.gpx, assuming the fixed prefix, you could just build the "/mnt/share/gpxfiles/police.gpx" string and pass it to te GP Service. Better yet, you can compose this string inside the GP service so nobody will never now the paths to your filesystem.

Regards.

Roberto Pepato.


Thanks i'll try that and comment. Very thanks.
0 Kudos
nicogis
MVP Frequent Contributor
0 Kudos
RobinAlexis_Olaya
New Contributor
Thank you very much for your help, I'll practice it and tell them.

From Cali, Colombia.
0 Kudos
RobinAlexis_Olaya
New Contributor
see http://studioat.maps.arcgis.com/home/item.html?id=10ffc2f50f6c430b912cf23ae8e2643b


Sincerely, can you please update the link. shown as unavailable. thanks
0 Kudos
nicogis
MVP Frequent Contributor
0 Kudos
RobinAlexis_Olaya
New Contributor
Thanks, i resolve the problem with the uodate property of geoprocessing.

function uploadFile() {
  //subi gpx con upload y itemID (via uploadSucceeded)
  var upload = esri.request({
   url: "http://****/arcgis/rest/services/GPX/GPServer/uploads/upload",
   form: dojo.byId("uploadForm"),
   content: { f: "json" }
  });
  upload.then(uploadSucceeded, uploadFailed);
}

function uploadSucceeded(response,io) {
       var itemID = response["item"].itemID;
       //submit the GP Task by passing the itemID info the input parameter
       var params = {'GpxFile': "{'itemID':'" +itemID+ "'}" };
       gp.submitJob(params, completeCallback, statusCallback, function(error){
   alert(error);  
       });
    }
0 Kudos