Select to view content in your preferred language

How to add non-ESRI data to map with JavaScript API??

945
3
03-18-2011 06:16 PM
BernieConnors
Deactivated User
Hi,

    I manage some ArcGIS servers and I publish several map services (http://geonb.snb.ca/arcgis/rest/services/).  I have a user that wants to embed my map services into their website.  The user has a simple point dataset.  The user wants to display their point data on top of my map services.  I don't want to add the user's point data to my ArcGIS server.  I want the user to keep their data on their own web server.

  • How can the user add their point data to the map if it is NOT on ArcGIS server?

  • What format should they store the data (KML? Shape?)

  • What JavaScript function should be used to read the data and add it to the map?

  • Are there any examples on the web?


Thanks,
Bernie.
0 Kudos
3 Replies
JamesBurton
Emerging Contributor
Hi,

    I manage some ArcGIS servers and I publish several map services (http://geonb.snb.ca/arcgis/rest/services/).  I have a user that wants to embed my map services into their website.  The user has a simple point dataset.  The user wants to display their point data on top of my map services.  I don't want to add the user's point data to my ArcGIS server.  I want the user to keep their data on their own web server.

  • How can the user add their point data to the map if it is NOT on ArcGIS server?

  • What format should they store the data (KML? Shape?)

  • What JavaScript function should be used to read the data and add it to the map?

  • Are there any examples on the web?


Thanks,
Bernie.


You need to read the data and create an esri.geometry.Point object for each record, then create a Graphics object for each point and draw it on the graphics layer. For this purpose, you want the data to be available in a format which is easily read in Javascript, e.g. JSON or XML.
0 Kudos
KenMorefield
Regular Contributor
Look at some of the samples here: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm

Look at the "File Access With Drag and Drop" under the Experimental category.  Also look at the samples under the Data Access category.  Another good place to look might be the dojo csvstore here: http://arcscripts.esri.com/details.asp?dbid=16544

Ken
0 Kudos
JamesBurton
Emerging Contributor
To give a simplified but more constructive answer, you'd have some server side code that reads from the database and outputs JSON:
[ {x: 123456, y:123456, attribute1: "blah"}, ... ]


Then load it like this:

var params = {param1: "foo"};//params needed by the serverside file
$.get('load-data.php', params, function(data) {
  var graphic;
  $.each(data, function(key, val) {
    graphic = new esri.Graphic(new esri.geometry.Point(val.x, val.y, map.extent.spatialReference), yourSymbol, {"attribute1": val.attribute1}, yourInfoTemplate);
    map.graphics.add(graphic);
}
});

Not tested, HTH.
0 Kudos