Skip to main content
Solved

Can you use a hyperlink as the label attribute in a map created by the HTMLReportGenerator transformer?


drc43
Contributor
Forum|alt.badge.img+11
  • Contributor

I'm trying to build a workflow as such:

A user is presented with a HTML file showing a web map with features that is created by the HTMLReportGenerator. The user can click on a feature on the map displaying the tooltip which has a hyperlink as set in the Label Attribute setting in the transformer. The user can then click the hyperlink to be directed to an additional webpage or form.

Is it possible to have a hyperlink in this setting? Whenever I try it, the HTML page returns with no web map at all.

Best answer by chrisatsafe

Hi @drc43​ ,

 

Apologies for the late reply but in case you are still looking for the answer to this. 

 

You can achieve this by using the regular a href html tag but it's a bit of a two step process. 

  1. Create the label including some hyperlinked tag. 
  2. Use a couple of StringPairReplacers to ensure the labels/hyperlinks are correctly formatted after the HTMLReportGenerator. 

 

The HTMLReportGenerator does some character encoding so you need to fix it with the StringPairReplacers. If you inspect the HTML after the HTMLReportGenerator, you'll notice your a href tag in the label isn't quite right so the easiest way to fix it up is using the StringPairReplacers to put the encoded characters back to the appropriate character(s).

HTMLReportGenerator (note the < > ' ' characters output as encoded characters  &lt;  &#x27;  etc. ):

"popupContent":"&lt;a href=&#x27;https://www.safe.com&#x27; target=&#x27;_blank&#x27;&gt;CLICK HERE&lt;/a&gt; to go to our website!"

After StringPairReplacers

"popupContent":"<a href='https://www.safe.com' target='_blank'>CLICK HERE</a> to go to our website!"

 

Result!

 

2021-07-28_16-18-45I've attached the workspace for your reference :)

 

Hope that helps!

View original
Did this help you find an answer to your question?

3 replies

chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • Best Answer
  • July 28, 2021

Hi @drc43​ ,

 

Apologies for the late reply but in case you are still looking for the answer to this. 

 

You can achieve this by using the regular a href html tag but it's a bit of a two step process. 

  1. Create the label including some hyperlinked tag. 
  2. Use a couple of StringPairReplacers to ensure the labels/hyperlinks are correctly formatted after the HTMLReportGenerator. 

 

The HTMLReportGenerator does some character encoding so you need to fix it with the StringPairReplacers. If you inspect the HTML after the HTMLReportGenerator, you'll notice your a href tag in the label isn't quite right so the easiest way to fix it up is using the StringPairReplacers to put the encoded characters back to the appropriate character(s).

HTMLReportGenerator (note the < > ' ' characters output as encoded characters  &lt;  &#x27;  etc. ):

"popupContent":"&lt;a href=&#x27;https://www.safe.com&#x27; target=&#x27;_blank&#x27;&gt;CLICK HERE&lt;/a&gt; to go to our website!"

After StringPairReplacers

"popupContent":"<a href='https://www.safe.com' target='_blank'>CLICK HERE</a> to go to our website!"

 

Result!

 

2021-07-28_16-18-45I've attached the workspace for your reference :)

 

Hope that helps!


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • July 28, 2021
chrisatsafe wrote:

Hi @drc43​ ,

 

Apologies for the late reply but in case you are still looking for the answer to this. 

 

You can achieve this by using the regular a href html tag but it's a bit of a two step process. 

  1. Create the label including some hyperlinked tag. 
  2. Use a couple of StringPairReplacers to ensure the labels/hyperlinks are correctly formatted after the HTMLReportGenerator. 

 

The HTMLReportGenerator does some character encoding so you need to fix it with the StringPairReplacers. If you inspect the HTML after the HTMLReportGenerator, you'll notice your a href tag in the label isn't quite right so the easiest way to fix it up is using the StringPairReplacers to put the encoded characters back to the appropriate character(s).

HTMLReportGenerator (note the < > ' ' characters output as encoded characters  &lt;  &#x27;  etc. ):

"popupContent":"&lt;a href=&#x27;https://www.safe.com&#x27; target=&#x27;_blank&#x27;&gt;CLICK HERE&lt;/a&gt; to go to our website!"

After StringPairReplacers

"popupContent":"<a href='https://www.safe.com' target='_blank'>CLICK HERE</a> to go to our website!"

 

Result!

 

2021-07-28_16-18-45I've attached the workspace for your reference :)

 

Hope that helps!

Worth noting, if you are using this in an app that uses the data streaming service, you'll want to set target='_blank' in the tag so the link opens in a new tab! Otherwise, the user would have to re-run the app to see the map again.


drc43
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • August 5, 2021
chrisatsafe wrote:

Hi @drc43​ ,

 

Apologies for the late reply but in case you are still looking for the answer to this. 

 

You can achieve this by using the regular a href html tag but it's a bit of a two step process. 

  1. Create the label including some hyperlinked tag. 
  2. Use a couple of StringPairReplacers to ensure the labels/hyperlinks are correctly formatted after the HTMLReportGenerator. 

 

The HTMLReportGenerator does some character encoding so you need to fix it with the StringPairReplacers. If you inspect the HTML after the HTMLReportGenerator, you'll notice your a href tag in the label isn't quite right so the easiest way to fix it up is using the StringPairReplacers to put the encoded characters back to the appropriate character(s).

HTMLReportGenerator (note the < > ' ' characters output as encoded characters  &lt;  &#x27;  etc. ):

"popupContent":"&lt;a href=&#x27;https://www.safe.com&#x27; target=&#x27;_blank&#x27;&gt;CLICK HERE&lt;/a&gt; to go to our website!"

After StringPairReplacers

"popupContent":"<a href='https://www.safe.com' target='_blank'>CLICK HERE</a> to go to our website!"

 

Result!

 

2021-07-28_16-18-45I've attached the workspace for your reference :)

 

Hope that helps!

Thanks for this @chrisatsafe​ !  I was short one StringPairReplacer and that was messing things up.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings