Skip to main content

Display image from related table (attachment) in map tip.

Comments

11 comments

  • Permanently deleted user
    Hi Bobbi, 

     

    If you want to grab an attachment from a data link add to the layer, then all you need to do is reference the data link and column name in the map tip to have the picture display. The syntax should look like this:  <img src="{dataLinkId.ColumnName}" style="width:300px; height:200px;"/> or this: {dataLinkId.ColumnName} depending on how your attachment column is formatted.

     

    I hope this helps.

     

    Regards, 

     

    Carmen
    0
  • Jason Hannigan
    Just a follow up, I have tried this with photo attachements and all it returns is a long list of numbers from the blob field that stores the photo. Is there a step I am missing or conversion needed?
    0
  • Permanently deleted user
    Hi Jason, 

     

    The code above (<img src="{dataLinkId.ColumnName}" style="width:300px; height:200px;"/>) does not support an image blob. So if your column is in blob data type, then you would need to somehow convert the blob into a URL so it can be read by the img tag. I just did a quick Google search and it looks like most people use Javascript to convert the image (i.e. http://stackoverflow.com/questions/7650587/using-javascript-to-display-blob) before using the img tag. 

     

    I have not tested this but I do not believe that the Feature Description parameter supports Javascript unfortunately. So is it possible for you to add a column to the table that contains a URL/filepath to the image? That way, you can reference this column in the maptip to display it.

     

    I hope this helps.

     

    Carmen
    0
  • Jason Hannigan
    Thanks Carmen, once I realized the javascript wouldn't work I tried something else. I was able to create a url link using the OBJECTID field to access the image in the attachment table for the related blob image. Since I only had one image for each point and the feature ObjectID was used as the attachmentID, I could just create the url for the display of the attachment image in this format -   "<img src="https://<domain>/arcgis/rest/services/<ServiceName>/MapServer/0/{OBJECTID}/attachments/{OBJECTID}" style="width:300px; height:200px;"/>

     

    This doesn't work if the attachmentID is different than the ObjectID.
    0
  • João Pinheiro
    Hi Jason, can you explain me this "  "<img src="https://<domain>/arcgis/rest/services/<ServiceName>/MapServer/0/{OBJECTID}/attachments/{OBJECTID}" style="width:300px; height:200px;"/>

     

    This doesn't work if the attachmentID is different than the ObjectID." 

     

    You, create enable Create Attachments on the feature class?

     

    I don´t understand parameter "attachments" on the URL

     

    Thanks
    0
  • Jason Hannigan
    Yes, just enable attachments on the feature class and then add the photos as attachments. When you publish the service, you should see the attachment table in the rest service. Then just use the url above with your parameters. This will only work for 1 to 1 attachments, more than 1 attachment per feature will not work using this method. The attachments parameter is just part of the url that is returned in the attachments rest url.
    0
  • João Pinheiro
    Hi Jason, thanks for you response.

     

    I've already been able to build the URL using the above parameters, but when I set the URL in the element description, the map does not load the image. see sample URL below:

     

    <img src="https://MyServer/arcgis/rest/services/CopyGeometry/MapServer/0/{OBJECTID}/attachments/{ATTACHMENTID}" style="width:300px; height:200px;"/>

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XdYJ&feoid=Body&refid=0EMf2000000YBO1"_/_img_If you set the URL by passing the parameter values the image loads. see sample URL below

     

    <img src="https://MyServer/arcgis/rest/services/CopyGeometry/MapServer/0/405/attachments/1" style="width:300px; height:200px;"/>

     

    The value of parameter OBJECTID is differente the value of parameter ATTACHMENTID.

     

    Is this the problem?

     

    Thanks
    0
  • Jason Hannigan
    Yes, this only works if the attachmentID and ObjectID are the same. 
    0
  • João Pinheiro
    But, the value of OBJECTID never equal the value of ATTACHMENTID.

     

    I create new feature class, and enabled Create Attachments. 

     

    Whent I inserted new record of the feature class and add attachment, but the value of ATTACHMENTID is different than OBJECTID. Why?

     

    See de images.

     

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XdZW&feoid=Body&refid=0EMf2000000YBP9" _/_img_

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XdZW&feoid=Body&refid=0EMf2000000YBPE" _/_img_

     

    Thanks

     

     
    0
  • Jason Hannigan
    I've gone back to the layer set up in Geocortex and it appears I have created a Data Link to the related table. For my case, I created a data link called TrailPhotos and selected the attachment table from the database and chose the Rel_ObjectID column. Clicking Next will take you to the Data Link conditions. Add a condition similar to the screenshot below:

     

    _img_ alt="Data Link Parameter" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XdZb&feoid=Body&refid=0EMf2000000YBPJ" _/_img_

     

    I set the attachementID (Rel_ObjectID) from the attachment table to equal the ObjectID from the featureclass. Here is the advanced settings for the data link:

     

    _img_ alt="Advanced Data Link Settings" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=907f2000000XdZb&feoid=Body&refid=0EMf2000000YBPO" _/_img_

     

    Sorry, I forgot about this step, it was set up a few years ago and hasn't been touched since.
    0
  • Permanently deleted user
    Does this work on PDFs? or does this have to be JPEG or PNG?
    0

Please sign in to leave a comment.