-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showAttachments not honored in Identify.js against MapService #177
Comments
@kcarrier, I don't believe this is a CMV issue. It is my understanding that |
@kcarrier @tmcgee Yes, it has to be a feature layer when added to the map. Try adding it via the operational layers array in viewer.js as a feature layer using: |
@tmcgee & @DavidSpriggs - All I agree the documentation says one thing but I think this code might disprove that theory. You will need to zoom all the way in to get the popup to work, but the attachment comes through here, thoughts? <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the
samples on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>
San Francisco
</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.esriScalebar {
padding: 20px 20px;
}
#map {
padding: 0;
}
</style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
require([
"esri/config",
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/symbols/SimpleMarkerSymbol",
"esri/tasks/GeometryService",
"dojo/dom-construct",
"dojo/parser",
"esri/Color",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function (
esriConfig, Map, Popup, PopupTemplate, ArcGISDynamicMapServiceLayer,
SimpleMarkerSymbol, GeometryService, domConstruct, parser, Color
) {
parser.parse();
esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var popupOptions = {
markerSymbol: new SimpleMarkerSymbol("circle", 32, null,
new Color([0, 0, 0, 0.25])),
marginLeft: "20",
marginTop: "20"
};
//create a popup to replace the map's info window
var popup = new Popup(popupOptions, domConstruct.create("div"));
map = new Map("map", {
basemap: "topo",
center: [-84.259420, 39.750745],
zoom: 17,
infoWindow: popup
});
var popupTemplate = new PopupTemplate({
title: "TEST",
fieldInfos: [
{
fieldName: "STR_NAME",
visible: true,
label: "Type"
},
{
fieldName: "HyperLink",
visible: true,
label: "Hyperlink"
}
],
showAttachments: true
});
var demographicsLayer = new ArcGISDynamicMapServiceLayer("http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer");
demographicsLayer.setInfoTemplates({
13: { infoTemplate: popupTemplate }
});
map.addLayer(demographicsLayer);
});
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'"
style="width: 100%; height: 100%; margin: 0;">
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"
style="border:1px solid #000;padding:0;">
</div>
</div>
</body>
</html> |
@kcarrier The behaviour in CMV is due to the way we set the templates on the features independent of the layer. In your example it is set on the actual layer. I will investigate and see if we can fix this. |
'setInfoTemplate' was just added to Dynamic and Tile layers at version 3.10 so it sounds like the documentation has some catching up to do. An There has potential to greatly simplify the Identify widget using infoTemplates at the layer level. However, adding the infoTemplate to the dynamic layer like this as opposed to the returned features has an undesirable side effect of interfering with other map tools that use a click (Edit, Draw, Measure, StreetView, Directions). This occurs in some instances today with feature layer infoTemplates (and other graphics such as features returned from a FInd). We addressed it for the Edit widget and feature layer infoTemplates. Alternative strategies have been discussed for a centralized approach instead of custom code for each individual widget. In the example provided, it is not clear to me what triggers the identify at just the highest zoom level. It will require some investigation to determine when to let the API handle the map click and when to do it the "CMV way". In my opinion, more documentation of this behavior from ESRI is required before we should support this behavior. Another consideration is that some users of CMV are intentionally not using version 3.10 of the API. I'm not sure of the reasoning for this but it is something that needs to be considered before supporting an api feature that just appeared in the newest version. |
@tmcgee - What triggers the identify is the layered in this case 13, this is the highest level zoom layerid in the rest endpoint. var demographicsLayer = new ArcGISDynamicMapServiceLayer("http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer");
demographicsLayer.setInfoTemplates({
13: { infoTemplate: popupTemplate }
});
map.addLayer(demographicsLayer); |
I recognize it is the highest zoom level but why would that trigger the identify? Seems somewhat arbitrary. Any documentation on this? |
@tmcgee - Good point not real sure. I can look around but @DavidSpriggs might be able to answer this better than I can, worth a call to Esri support though to see if they can explain it to a newbie like me, LOL. |
good luck with ESRI support. LOL |
Well that was a quick call, looks like it happens on a click event of a graphic, basically was told same thing documentation says so we might have to wait on a better explanation from David in my opinion. |
There is no graphic involved with a dynamic layer. There is one for a feature layer. So it sounds like the support person's explanation is bit out of date too. ;) My point is more that the documentation is currently lacking. Even with an explanation from David (or my own exploration of the api's code on this), we may not want to build code to support undocumented behavior that may change in the future. |
@kcarrier @tmcgee This behaviour is all baked into the map now to be more like AGO (you dont have to wire up identify, just define an pop up template and your good). There is a new prop on the map object to turn this on and off: So we can use this new functionality in CMV by turning the feature off when using other tools. |
"Excellent Smithers!" (Bart Simpson reference), Well hopefully when there is time to work on it in CMV I can help test. We really need that feature as we have many map services with attachments enabled. Cannot replace our Flex stuff until I can get that working. I will wait patiently I promise, thanks for the help! |
I saw that addition in the "What's New in Version 3.10" ArcGIS. It says `toggle the default behavior of showing the map's infoWindow when clicking a graphic.' which is incorrect since it appears to apply to dynamic and tiled layers as well. Any idea why the identify is only triggered on the highest zoom level in kcarrier's example? I'm not sure we want to tap into this new feature if identify would only work at the highest zoom. |
@karrier: you can't use a feature layer? that works already. You could add a feature layer (or layers) that only is visible at the highest zoom to mimic this behavior. |
Oh I think I now see why it is only triggered on the highest zoom. The sublayer used in the example is only visible at that zoom level. |
@tmcgee - Feature Layers require SDE and we use file gdb as backend. I prefer to use map services over feature services for performance and file gdb over SDE for performance as well. We replicate the data in WMAS each night via script so there is no performance hit for projecting on the fly. I was told by Esri at UC 2014 that they are working on improving the performance of feature services but in my testing they are slower than map services plus I am not big on having web services hitting my database as we do not do any web editing it is all read only. More a preference, could it be done sure but there are some deeper issues like having to reconfig my entire backend process for pop-ups? |
Are you talking about Feature Layers or Feature Services? You can have feature layers that point to a single sublayer in a Map Service. It does not have to be a Feature Service. In your Map Service, this is a feature layer: http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer/13 Using a Feature Layer may not be your desired outcome. I am just pointing out that it is possible. |
Do I understand correctly that currently showAttachments will only work with feature layers and not dynamic layers in the CMV? |
That is correct. The ESRI Javascript API did not support |
having trouble showing attachments added as feature layer in viewer.js. Is where a example with attachments configured? |
The SF311 layer in the demo app uses showAttachments. For this particular layer, the infoTemplate is not defined in identify.js and so is created automatically by cmv. The code detects that attachments are available ( In your own infoTemplate defined in identify.js, you should just need to add With either method, you'll need to confirm that your service has attachments. You can do this by examining the properties from the REST end point for the particular sub-layer of the map service/feature service. |
Well, tried both methods, no Attachments are visible. Maybe because its a secure service? |
Do you see the "Attachments:" heading at the bottom of the Info Window with the message "No Attachments Found"? If so, then your infoTemplate is configured correctly in CMV but the ESRI API is not finding the attachments. That's an API issue. You might want to try one of the ESRI sandbox examples with your service to see if it has similar results. I'm not aware of a problem with showAttachments with a secure service. |
Try this one, it has a sandbox link: |
The sandbox works with my feature layer. but it doesnt work with CMV
Thank you guys. |
Hello guys, Thank you, |
@goriliukasbuxton there has been no additional attention given to the additional |
Here is another one, it is a point service layerIds: [1,3,5,7,9,11,13] http://engineer.gomvo.org/arcgis/rest/services/WMAS/MCEO_SurveyRecords/MapServer Here is some code I was using viewer.js: operationalLayers: [{
type: 'dynamic',
url: 'http://engineer.gomvo.org/arcgis/rest/services/WMAS/MCEO_SurveyRecords/MapServer',
title: 'Survey Records',
options: {
id: 'SurveyRecords',
opacity: 1.0,
visible: true,
imageParameters: imageParameters
},
identifyLayerInfos: {
layerIds: [1,3,5,7,9,11,13]
}
}, identify.js: SurveyRecords: {
1: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
3: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
5: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
7: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
9: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
11: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
},
13: {
title: 'SURVEY_NUMBER',
showAttachments: true,
fieldInfos: [{
fieldName: 'SURVEY_NUMBER',
visible: true
}]
}
}, |
@tmcgee - Thanks for looking into this, let me know if you need anything else. |
Along these lines, I just noticed an issue in my CMV application with opening attachments on a secured service via the attachment link in the feature's ID pop up window. The attachment links display as intended in the pop up window, but when the user clicks on the attachment link the URL is calling for a redirect that requires the user to authenticate with our ArcGIS Server in order to see the attached image. Of course, the attachments work fine if the service is public. I'm already using proxy to auto authenticate user access to secure services, so I'm a little stumped as to why clicking on the attachment link leads to a login redirect page (the standard ArcGIS Server REST API Login page) instead of direct authentication from the functioning proxy. Any thoughts as to whether this is an ESRI thing or a CMV issue? Thanks. |
@taran03 All of the logic for displaying the contents within the InfoWindow including the list of attachments and opening those attachments is handled by the ESRI JS API. Sorry if that comes across like I'm passing the buck. ;) |
Ok, that is what I suspected. Thanks for confirming this. |
@tmcgee - I know you have other things in your life to do but I was just curious what the initial findings were from the examples we were able to provide. |
@kcarrier Sorry, I have not had the opportunity yet. |
@tmcgee - Hope you had a good time at DevSummit, just checking in. |
@kcarrier this is still on my "when I get around to it" list. |
@kcarrier: I finally spent some time this afternoon to look into this. This default map functionality behind the mapclick is not well documented in the API docs beyond what @DavidSpriggs mentioned about the You can use the built-in functionality within the map in CMV. You will need to not include the identify widget in your app and you will need to define your infoTemplates directly within each operationalLayer like this:
I have not tested whether this plays nice with other cmv widgets that interact with the map so there may be a can of worms there. I'm not sure if it a good idea or not to do away with the current Identify widget completely within CMV and rely on this undocumented functionality. That would require more discussion. I'm not a fan of their approach since using QueryTask as ESRI does instead of IdentifyTask is certainly less efficient for the server and the client. Now that I have a better understanding of what they are doing and why it behaves the way it does, I have a few thoughts to explore how we might incorporate similar |
@tmcgee - I just tested the code above and it does not work as expected. Still no attachments coming through in the Popup Window, just the Survey Number comes through in the title and in the field section. |
Hmm. I used the exact layer config that I posted above and the attachments were there in the InfoWindow. Did you disable the cmv Identify widget? That's an integral step to getting this to work.. |
@tmcgee - Disabling the identify fixed it, sorry glossed over that step. So rather than build the identifies in the identify.js file, I would just build them within viewer.js correct? Thanks for the prompt reply very much appreciated! |
@tmcgee - Thanks again for all the help! |
@DavidSpriggs , @tmcgee . Hi all, love the work going on here. Just wondering, with regard to the showInfoWindowOnClick functionality, where abouts in CMV do I setInfoWindowOnClick(true); ? |
@igover007 There isn't anything to set for this functionality. The default value is true. |
@tmcgee - It appears I might not be able to use the description method in the viewer.js file, it is like it does not recognize anything except the first field value, all other field values come back blank. The attachments still work as you explained earlier but now the field values are not coming through as they were in the identify.js file. When I use fieldInfos[{}] as specified in the Esri JS API documentation the values come through, any thoughts. My code example can be seen below, the map service is publicly accessible. |
@kcarrier the description property in your example looks correct (when used in identify.js). This |
@tmcgee - I think I see where I screwed up I did not close the table |
@tmcgee - I am trying to allow for the attachments to be visible and this is working the issue I am running into now is that I have some fields which have hyperlinks and i am not sure how to set the code up to support both hyperlinks and showAttachments. The question I guess I need to try and figure out is there any way of having a hyperlink value inside of fieldInfos. description works but only for the first field and I am not sure if it is possible to get a hyperlink inside of fieldInfos any thoughts?
|
@tmcgee - I think I figured out how to get description to work in conjunction with fieldInfos. I was trying some different methods and move fieldInfos above description and with both of them under the PopupTemplate it is now working and I can have hyperlinks and attachments, in case anyone ever runs across this, here is how I got it to work. It almost seems like in order for description to work inside of viewer.js as shown below you have to have fieldInfos setup so the api knows how to get the field and field value from REST or something along those lines.
|
I found this thread looking for answer, my popups were not showing attachments in for dynamic layers, I needed for only a few items...add similar lines starting around line 288 of the identify.js file.
|
REST Service : http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer
LayerId: 13
identify.js
viewer.js
Attachments are not showing in popup.
The text was updated successfully, but these errors were encountered: