Hi @memphis ,
Please try as follows:
Step1: Add the Geolocation column to a list using PnP PowerShell:
Connect-PnPOnline -url "https://TENANT.sharepoint.com/sites/SITEURL"
$list = Get-PnPList -Identity "LISTNAME"
Add-PnPField -List $list -Type GeoLocation -DisplayName "GeoLocationField" -InternalName "GeoLocationField" -AddToDefaultView -Required
Step2: Add a list item by passing the Geolocation valueas an object programmatically:
static void Main(string[] args)
{
string userName = "xxx@TENANT.onmicrosoft.com";
Console.WriteLine("Enter your password.");
SecureString password = GetPassword();
// ClienContext - Get the context for the SharePoint Online Site
// SharePoint site URL - https://domain.sharepoint.com/sites/xxx
using (var clientContext = new ClientContext("https://TENANT.sharepoint.com/sites/SITEURL"))
{
// SharePoint Online Credentials
clientContext.Credentials = new SharePointOnlineCredentials(userName, password);
List oList = clientContext.Web.Lists.GetByTitle("your list name");
ListItemCreationInformation itemCreationInfo = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(itemCreationInfo);
oListItem["Title"] = "Test1";
FieldGeolocationValue oGeolocationValue = new FieldGeolocationValue();
oGeolocationValue.Latitude = (double)17.4;
oGeolocationValue.Longitude = (double)78.4;
oListItem["GeoLocationField"] = oGeolocationValue;
oListItem.Update();
clientContext.ExecuteQuery();
}
}
private static SecureString GetPassword()
{
ConsoleKeyInfo info;
//Get the user's password as a SecureString
SecureString securePassword = new SecureString();
do
{
info = Console.ReadKey(true);
if (info.Key != ConsoleKey.Enter)
{
securePassword.AppendChar(info.KeyChar);
}
}
while (info.Key != ConsoleKey.Enter);
return securePassword;
}
Step3: Set the Bing Maps key at the web level with SharePoint PnP PowerShell:
Connect-PnPOnline -url "https://TENANT.sharepoint.com/sites/SITEURL"
Set-PnPPropertyBagValue -Key "BING_MAPS_KEY" -Value "YOURKEYVALUE"
Step 4: Create a map view from the SharePoint UI , please remember to see the result in classic experience since JSLink based customizations (client-side rendering) are not supported in modern experiences:
Reference:
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.