HOW TO

Create hyperlinks to Google Maps based on latitude and longitude in Portal for ArcGIS and ArcGIS Online Map Viewer pop-ups

Last Published: June 28, 2023

Summary

In Portal for ArcGIS and ArcGIS Online Map Viewer, when the features' latitude and longitude values are stored in double type fields in a hosted feature layer, hyperlinks to the coordinates on Google Maps can be added to the pop-ups using custom Arcade expressions. This article provides the Arcade expressions to do so.

Procedure

  1. Log in to Portal for ArcGIS or ArcGIS Online and open the web map in Map Viewer.
  2. In Map Viewer, on the Settings (light) toolbar, click Configure pop-ups Configure pop-ups icon. in Portal for ArcGIS or Pop-ups in ArcGIS Online.
  3. In the Pop-ups pane, click Fields list, and click Select fields.
The Pop-ups pane in Map Viewer to be configured.
  1. In the Select fields pane, click Add expression.
  2. In the editor, configure the attribute expression. Replace <latitude_fieldname> and <longitude_fieldname> with the name of the fields storing the coordinates.
  • To generate a hyperlink to Google Maps.
var lat = Replace(Text($feature.<latitude_fieldname>, "#.#######"), ",", ".");
var lon = Replace(Text($feature.<longitude_fieldname>, "#.#######"), ",", ".");
var url = "https://www.google.com/maps/search/?api=1&query=" + lat + "," + lon;
return url;
  • To generate a hyperlink to Google Street View.
var lat = Replace(Text($feature.<latitude_fieldname>, "#.#######"), ",", ".");
var lon = Replace(Text($feature.<longitude_fieldname>, "#.#######"), ",", ".");
var url = "http://maps.google.com/?cbll=" + lat + "," + lon + "&cbp=12,90,0,0,5&layer=c";
return url;
  • To generate a hyperlink to Google Maps with an aerial view.
var lat = Replace(Text($feature.<latitude_fieldname>, "#.#######"), ",", ".");
var lon = Replace(Text($feature.<longitude_fieldname>, "#.#######"), ",", ".");
var url = "https://www.google.com/maps/@" + text(lat) + "," + text(lon) + ",38m/data=!3m1!1e3";
return url;
  1. Click Done.
  2. In the Select fields pane, click Done.

In this example, the Google Maps hyperlink based on the coordinates is generated and added to the pop-up.

A pop-up in a web map displaying a hyperlink that redirects the user to another browser tab.

Article ID: 000030641

Software:
  • ArcGIS Online
  • Portal for ArcGIS
  • ArcGIS Enterprise 11 0
  • ArcGIS Enterprise 11 1

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options
Esri Support AI Chatbot