カスタムポップアップにハイパーリンクを含むWebマップがいくつかあります。リンク先には、マップ上で別の操作を行う際に参考になる情報が表示されるものもあります。しかし、これらのポップアップでは、リンクが常に別のタブで開きます。一度に表示できるタブは1つだけなので、マップが隠れてしまうのが嫌です。HTMLなら簡単にできますが、Arcade式ではどうすればよいのでしょうか?
When you add a text element, click the source <> icon to edit in html. See the tip on this documentation page:
https://doc.arcgis.com/en/arcgis-online/create-maps/configure-pop-ups-mv.htm#ESRI_SECTION1_B7B559DA30964877909B95706627B007
However this actually won't work the way you want it to, ever.
https://doc.arcgis.com/en/arcgis-online/reference/supported-html.htm
When an a tag is used, the href target URL always opens in a new browser tab.
I thought it might be enforced by end users browser's but it looks like this is also enforced by ArcGIS.
You can return html within a popup. Add a text or arcade section your popup and then:
Here's an example arcade snipped that could be used:
var url = $feature["URL_Field"];return "<a href='" + url + "' target='_blank' onclick=\"window.open(this.href, 'newwindow', 'width=800,height=600'); return false;\">Open link</a>";
Genius! Thank you for the reply. I must be missing something though:
When I put the expression in a text element, it just puts the HTML string in the popup so I tried the Arcade element which did produce a working hyperlink, but it seems to ignore the javascript in there and just open the page in another tab. Here's the expression I made:
var inParam = $feature["wmext_Pole_JPA"]; if (IsEmpty(inParam)) {return ""}; var base_url = "https://scjpc.net/search/jpa/details/"; inParam = Replace(inParam, '-', ''); inParam = Replace(inParam, ' ', ''); inParam = Replace(inParam, '/', ''); base_url = base_url + inParam; var returntxt = "<a href='" + base_url + inParam + "' target='_blank' onclick=\"window.open(this.href, 'newwindow', 'width=800,height=600'); return false;\">HTML</a>"; return { type : 'text', text : returntxt //this property supports html tags }
Thanks for those links. I did follow that tip and used the source button, but just got the HTML string.
Most browsers default to opening things in tabs, but I set mine to open in new windows, so is enforced by ArcGIS, but additionally I don't think you can embed Javascript in the HTML. Just for grins I tried this
<H1 onclick="alert('clicked'); " ############################## </H1>
and it didn't work either.
Bummer.....
ログインすると、投稿したり、更新をフォローしたりできます。初めてですか?無料アカウントを登録しましょう。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.