HOW TO
The aim of this article is to provide a workflow to add a Google Maps link in the pop-up window of an ArcGIS Enterprise feature service.

"https://www.google.com/maps/?q=" + $feature.lat + "," + $feature.long



The expression for the Latitude :
// The expression below if only applicable if the basemap is using the Web Mercator projection.
// Create a function to convert meters to lat
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
function MetersToLatLon(geom) {
if (IsEmpty(geom)) {
return null
}
var originShift = 2.0 * PI * 6378137.0 / 2.0
var lat = (geom.y / originShift) * 180.0
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0)
return Round(lat, 6)
}
// Call the function and return the latitude
MetersToLatLon(Geometry($feature))
The expression for the Longitude :
// The expression below if only applicable if the basemap is using the Web Mercator projection.
// Create a function to convert meters to long
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
function MetersToLatLon(geom) {
if (IsEmpty(geom)) {
return null
}
var originShift = 2.0 * PI * 6378137.0 / 2.0
var lon = (geom.x / originShift) * 180.0
return Round(lon, 6)
}
// Call the function and return the longitude
MetersToLatLon(Geometry($feature))
Note:
As stated as comments in the expressions, thees expressions are only applicable if the basemap used when creating the features is using the Web Mercator projection. However it does not depend on the feature service coordinate system.



Article ID: 000038099
Get help from ArcGIS experts
Start chatting now