I don't fully understand what you mean with regards to SQL Server, but assuming that you're able to retrieve the point information (perhaps in JSON format) you could create a Feature Layer, which would allow you to specify the popup using setInfoTemplate. See documentation here.
Hi Kunal,
Thanks for the additional information. The link you sent shows that you have access to ArcGIS Server, so a suggestion is to start with the Feature Layer samples from the Samples page, for example the Popup or On Demand Mode samples, both of which contain examples of popups containing information.
Steve
var content = "<b>Type</b>: ${ftype}" + "<br /><b>Code</b>: ${fcode}"; var infoTemplate = new esri.InfoTemplate("Rivers", content);
var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/MapServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: infoTemplate });
Hi Kunal,
First, define the content of the popup like below:var content = "<b>Type</b>: ${ftype}" + "<br /><b>Code</b>: ${fcode}"; var infoTemplate = new esri.InfoTemplate("Rivers", content);
Then, add the feature layer to your app, defining the infoTemplate you set above:var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/MapServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: infoTemplate });
In the example above (from Feature Layer -> On demand samples), all values are available in the output fields of the feature layer but only ftype and fcode will actually display in the pop because they are the only fields set up in the content. You don't need any extra coding.
Hope that helps.
Ed
function findRelatedRecords(features) { var relatedTopsQuery = new esri.tasks.RelationshipQuery(); relatedTopsQuery.outFields = ["*"]; relatedTopsQuery.relationshipId = 3; relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID]; wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) { var fset = relatedRecords[features[0].attributes.OBJECTID]; var items = dojo.map(fset.features, function(feature) { return feature.attributes; }); //Create data object to be used in store var data = { identifier: "OBJECTID", //This field needs to have unique values label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: items }; //Create data store and bind to grid. store = new dojo.data.ItemFileReadStore({ data:data }); grid.setStore(store); grid.setQuery({ OBJECTID: '*' }); }); }
Kunal,
In your map service you have four layers, each with the same schema:
FID (Type: esriFieldTypeOID, Alias: FID)
Shape (Type: esriFieldTypeGeometry, Alias: Shape)
StationKey (Type: esriFieldTypeDouble, Alias: StationKey)
StationID (Type: esriFieldTypeString, Alias: StationID, Length: 50 )
Latitude (Type: esriFieldTypeDouble, Alias: Latitude)
Longitude (Type: esriFieldTypeDouble, Alias: Longitude)
Location (Type: esriFieldTypeString, Alias: Location, Length: 254 )
Location_2 (Type: esriFieldTypeString, Alias: Location_2, Length: 254 )
County (Type: esriFieldTypeString, Alias: County, Length: 254 )
State (Type: esriFieldTypeString, Alias: State, Length: 254 )
If you want to display related information then you need to use the queryRelatedFeatures method on your feature layer. First, set up a relationship between your lat/long feature class and your external table in your service project. Restart the service, refresh the REST cache if necessary. At the REST endpoint you should see values in the 'Relationships' section at the bottom of the page, similar to http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0. This means the related data can be used by the API.
After that you need to add some code to your app that will find the related records. There's a sample which shows you how to do this here http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/fl_query_relat.... The part that actually queries the related records is here:function findRelatedRecords(features) { var relatedTopsQuery = new esri.tasks.RelationshipQuery(); relatedTopsQuery.outFields = ["*"]; relatedTopsQuery.relationshipId = 3; relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID]; wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) { var fset = relatedRecords[features[0].attributes.OBJECTID]; var items = dojo.map(fset.features, function(feature) { return feature.attributes; }); //Create data object to be used in store var data = { identifier: "OBJECTID", //This field needs to have unique values label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: items }; //Create data store and bind to grid. store = new dojo.data.ItemFileReadStore({ data:data }); grid.setStore(store); grid.setQuery({ OBJECTID: '*' }); }); }
Note the relationshipId in the code above needs to be the same as the id of the relationship in the REST endpoint of your service.
Good luck!
var template = new esri.InfoTemplate(); template.setTitle("<b>${StationKey}</b>"); template.setContent(getTextContent); var featureLayer = new esri.layers.FeatureLayer("http://geoapps.rc.rit.edu/ArcGIS/rest/services/eInvertebrates2/MapServer/layers",{ mode: esri.layers.FeatureLayer.MODE_SELECTION, outFields: ["*"], infoTemplate:template }); map.addLayer(featureLayer); dojo.connect(map, 'onLoad', function(theMap) { //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map,map.resize); }); } function getTextContent(graphic) { var attr = graphic.attributes.StationKey; return attr + "<br>" + graphic.attributes.Latitude + "<br/> Planted on " + graphic.attributes.Longitude; }
var featureLayer = new esri.layers.FeatureLayer("http://geoapps.rc.rit.edu/ArcGIS/rest/services/eInvertebrates2/MapServer/layers",{ mode: esri.layers.FeatureLayer.MODE_SELECTION, outFields: ["*"], infoTemplate:template });
var featureLayer = new esri.layers.FeatureLayer("http://geoapps.rc.rit.edu/ArcGIS/rest/services/eInvertebrates2/MapServer/3",{ mode: esri.layers.FeatureLayer.MODE_SELECTION, outFields: ["*"], infoTemplate:template });