Skip to main content

Using javascript in a MapTip

Comments

8 comments

  • Permanently deleted user
    That would be a nice trick, and one I would use.  In the meantime, for features that don't have an associated document, we point to a dummy document that says "Sorry, no photo for this feature" - not elegant, but at least it doesn't leave the user hanging.
    0
  • Permanently deleted user
    I have the same question as Halil.

     

    Can JavaScript if else statement be used inside the maptip?
    0
  • Permanently deleted user
    I think you can accomplish this with css. See below (this is in the maptip)... <a class="PhotoLink" href="">Click here for photo.</a> <a class="PhotoLink" href="http://linkToPhoto.com">Click here for photo</a>

     

    Then for the css (this is in the extensible css file): .PhotoLink[href='']{     visibility: hidden; }

     

    Also, jsfiddle for it here --> https://jsfiddle.net/8n3fkomj/3/
    0
  • Chris Roberts
    We have implemented something similar to Matthew:

     

    Map Tip: <div class="photo_{PHOTO}"> <a href="http://data.environment.ppf.env.sa.gov.au/Image-Catalogue/Pages/Default.aspx?DHNO={DHNO}" target="_Blank">View drill hole image catalogue in WaterConnect</a> </div>

     

    In the css file:

     

      /* hides drill hole photo url if there is no photo */ .photo_N{ display:none; }

     

     
    0
  • Chris Roberts

     

    Should of added that the {PHOTO} field has a value of N or Y, so if this will only display the link if the field value is Y

     

    If you were wanting to hide if a NULL value it would be:

     

    .photo_ {

     

    display:none;

     

    }
    0
  • Permanently deleted user
    Welcome everyone, today you're attending class 404 in HTML and CSS XD
    0
  • John Nerge
    Another option is to set up a one to one data link on the layer and use the output as your link text. Something like:

     

    SELECT 'Click here for photo' AS PhotoLink

     

    FROM myTable

     

    WHERE myPhotoField is not null

     

    AND myJoinField = @layerField
    0
  • Permanently deleted user
    Thanks for all your responses. I like John's solution of using data link values in maptips, because you can use SQL to modify the output value, based on the input value from your table, because in my case, changing the table value is not possible.

     

    For example, if you have a "Status" field where 1 is active and 0 is inactive, but want to show in the maptip active or inactive text instead of 0 or 1, then this data link solution is very useful.

     

    SELECT value, 

     

           CASE status                     

     

             WHEN  '1' THEN 'Active'

     

             WHEN  '0' THEN 'Inactive'

     

           END

     

    FROM table 

     

    WHERE condition;
    0

Please sign in to leave a comment.