johnmdye

Dynamic Microsoft Birds Eye View in XSL Template

Discussion created by johnmdye on Feb 12, 2014
This isn't really a python question, but I figured this was probably the best forum to pose the question since it involved code.

My End Users wanted to be able to view photos of our locations inside of ArcMap by clicking on a given point, which of course is possible but they actually wanted multiple photos displayed like an image gallery that they can flip through. I don't know of any way to dynamically create a photo gallery to review the photo attachments of a point in the attribute table.

To complicate matters a little more, we don't even have the neccessary license to create the attachments. So as a compromise, we agreed it was acceptable if I just iFramed Microsoft Birds Eye imagery of the location into an HTML Popup, which gives them a good view idea of what the location's surroundings look like, even if the imagery is a bit dated.

What I'm currently doing to accomplish this is calculating a field in the attribute tables to hold the bird's eye link:
"http://dev.virtualearth.net/embeddedMap/v1/ajax/BirdseyeWithLabels?zoomLevel=18&center=" + str(!LAT!) + "_" + str(!LON!) + "&pushpins=" + str(!LAT!) + "_" + str(!LON!) + "&culture=en-us"


Then I used this XSL Template from Ed Dempsey (thanks Ed, wherever you are) to iframe the link held in the 'Birds Eye View' field in the attribute table and display the result in the HTML Popup.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:variable name="ignoreFieldNames" select="'|OBJECTID|Shape|Shape_Length|Shape_Area|ATTACHMENTID|REL_OBJECTID|CONTENT_TYPE|ATT_NAME|DATA_SIZE|DATA|'"/>
  <xsl:variable name="headerRowColor" select="'#000066'"/>
  <xsl:variable name="headerFontColor" select="'FFFFFF'"/>
  <xsl:variable name="alternateRowColor" select="'#FFFFFF'"/>
  <xsl:variable name="alternateFontColor" select="'#000000'"/>
 <xsl:template match="/">
  <html>
   <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
   </head>
   <body>
    <xsl:variable name="nameCol" select="FieldsDoc/Fields/Field/FieldName"/>
    <table border="1" width="600" cellpadding="5" cellspacing="0">
     <tr bgcolor="#66CCFF">
      <xsl:if test="string-length($nameCol) != 0">
       <th width="50%" align="left">Field Name</th>
      </xsl:if>
      <th width="50%" align="left">Field Value</th>
     </tr>
     <xsl:variable name="index" select="1"/>
     <xsl:for-each select="FieldsDoc/Fields/Field">
      <tr>
       <xsl:if test="(position() +1) mod 2">
        <xsl:attribute name="bgcolor">#66CCFF</xsl:attribute>
                <xsl:attribute name="fontcolor">#FFFFFF</xsl:attribute>
       </xsl:if>
       <xsl:if test="string-length($nameCol) != 0">
        <td>
         <xsl:value-of select="FieldName"/>
        </td>
       </xsl:if>
       <td>
        <xsl:choose>
                  <xsl:when test="FieldName[starts-with(., 'Birds Eye View')]">
                    <xsl:variable name="BirdsEyeLink" select="FieldValue"/>
                    <iframe src="{$BirdsEyeLink}" width="550" height="450">An Internet Connection is required to view Bird's Eye</iframe>
         </xsl:when>
         <xsl:otherwise>
          <xsl:value-of select="FieldValue"/>
         </xsl:otherwise>
        </xsl:choose>
       </td>
      </tr>
     </xsl:for-each>
    </table>
    <br/>
   </body>
  </html>
 </xsl:template>
  <xsl:template match="Field">
    <tr>
      <xsl:if test="(position() +1) mod 2">
        <xsl:attribute name="bgcolor">
          <xsl:value-of select="$alternateRowColor"/>
        </xsl:attribute>
        <xsl:attribute name ="color">
          <xsl:value-of select ="$alternateFontColor"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:if test="(position() +0)">
        <xsl:attribute name="bgcolor">
          <xsl:value-of select="$headerRowColor"/>
        </xsl:attribute>
        <xsl:attribute name="color">
          <xsl:value-of select="$headerFontColor"/>
        </xsl:attribute>
      </xsl:if>
    </tr>
  </xsl:template>
</xsl:stylesheet>


However, what I'd like to get away from is whenever the user uses the identify tool, the actual Birds Eye link appears in the Identify Window. I don't really want to show the actual link. The same thing goes with raising the attribute table. When the user views the attribute table, they see the Bird's Eye Link for the given record. I just want to not show the field in the attribute table or identify window.

If I turn the field off, then the iFrame doesn't work because the XSL Template can't find the field holding the link. If I turn off the field visibility, same thing happens (I had always thought turning a field off was different from turning off field visibility, but they appear to be the same thing).

So what I'm wondering now, is whether or not it is possible to just do this dynamically within the XSL Template.
I did some googling and discovered there is a tag <xsl: value-of> tag that can probably used to dynamically grab the LAT and LON and populate them into the appropriate place in the Link, but I'm not sure how to insert the resulting link into the top of the table produced by the XSL Template.

Admitedly, I'm not very well versed at all with XSL, so any help is appreciated.

Outcomes