Google Maps hyperlink inside a Web Map Popup

1048
4
11-23-2020 01:21 AM
Labels (2)
AlfonsoDodero
New Contributor III

Hi,
I would like to insert an hyperlink to Google Maps within a popup of my Web Map.

In my process, latitude and longitude natively have the following notification type,

example
lon .: 11,213238
lat .: 44,231233

To easily insert them into the hyperlink I would need to convert them by transforming the comma into a period, as required by Google Maps.

Any ideas?

Thanks!

Tags (2)
0 Kudos
4 Replies
ManishPatel
Esri Contributor

Hi @AlfonsoDodero ,

 

One way to achieve this would be you can create a new field and use Arcade expression which can help to create the URL dynamically and this can be used in the popup as hyperlink.

 

Cheers,

Manish

Cheers,
Manish
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AlfonsoDodero ,

 

As far as I know, you can use Arcade to extract the coordinates of  a geometry or the values if stored in numeric decimal field and the decimal will always be a point as required in the URL. There is no need to create a new field, this can be done on the fly and when you return a valid URL the pop-up will automatically show it as a URL. 

 

Do you extract the coordinates from the geometry or do you have lat/lon fields with the decimal values in them?

Tags (1)
0 Kudos
AlfonsoDodero
New Contributor III

Hi XanderBakker,

we have lat/lon fields with the decimal values in them (separated with the comma).

If you had an example to share with us it would be very helpful, anyway  I'll try to use Arcade to generate the URL correctly.


Thanks a lot!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AlfonsoDodero ,

 

A couple of years ago I published a document on GeoNet that shows how to create a hyperlink that opens a new tab with Street View at the location of the feature (Spanish):

https://community.esri.com/t5/comunidad-esri-colombia-ecuador/crear-un-enlace-a-streetview-en-la-ven... 

You mention that the coordinates are stored in a field with a decimal value (I assume that the field is numeric and not text). The comma as a decimal is a way of showing the numeric value but internally it will be stored as a point. When you access the value with Arcade I assume that the value will be retrieved with a decimal point or to be sure you can use a Replace to replace any decimal comma by a point.

Some examples:

// Streetview
var lat = Replace(Text($feature["Latitude Field Name"], "#.#######"), ",", ".");
var lon = Replace(Text($feature["Longitude Field Name"], "#.#######"), ",", ".");
var url = "http://maps.google.com/?cbll=" + lat + "," + lon + "&cbp=12,90,0,0,5&layer=c";
return url;

// Google maps search
var lat = Replace(Text($feature["Latitude Field Name"], "#.#######"), ",", ".");
var lon = Replace(Text($feature["Longitude Field Name"], "#.#######"), ",", ".");
var url = "https://www.google.com/maps/search/?api=1&query=" + lat + "," + lon;
return url;

// Google maps @ location (zoom level 19)
var lat = Replace(Text($feature["Latitude Field Name"], "#.#######"), ",", ".");
var lon = Replace(Text($feature["Longitude Field Name"], "#.#######"), ",", ".");
var url = "https://www.google.com/maps/@" + lat + "," + lon + ",19z";
return url;