Using javascript in a MapTip
Hi,
We have a map tip that contains a link to a file which comes directly from the layer's attribute. The Map Tip has been set up to contain the text "Click Here for Photo", For some features that attribute is null. Is there anyway we can use javascript or something else, so that if the value is null the text is not shown?
Thanks
Halil
0
-
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 -
I have the same question as Halil.
Can JavaScript if else statement be used inside the maptip?0 -
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 -
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 -
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 -
Welcome everyone, today you're attending class 404 in HTML and CSS XD 0 -
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 = @layerField0 -
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
Du måste logga in om du vill lämna en kommentar.
Kommentarer
8 kommentarer