Sitecore : Habitat MapField Issue

Home > Sitecore Customization > Sitecore : Habitat MapField Issue
Sitecore MapView Issue

Sitecore Habitat provides MapField to setup location related information. From July 2018 Google has deprecated keyless usage as well as their pricing model. Below the actual error when configuring MapField in Sitecore Habitat. Due to this issue Forward and Reverse Geocoding and Google Map is not displaying in Sitecore.

Sitecore MapField Issue

Google Cloud Platform Portal Check

Before applying the solution. Please check your Google Cloud Platform Portal (https://console.cloud.google.com/google/maps-apis/overview) to check enabled applications under Google API. Please refer below image –

Google Map Platform

Steps to enable MapField in Sitecore

We have successfully overcome this issue by applying few tweaks in Sitecore. Below is the methodology we have have adopted to apply the change. We have updated three files to arrive at the solution.

  1. Modify XML file

Path: src\Feature\Maps\code\Sitecore\Shell\Applications\Content Manager\Dialogs\Maps
File Name: MapLocationPickerDialog.xml
Change: Removed “Key=Google API Key” and appended Querystring with Google API Key value. Please refer below image –

MapView XML Change

  1. Modify Javascript file

Path: src\Feature\Maps\code\Scripts\Maps
File Name: map.js
Change: Updated Google API Key in data-key attribute. Please refer below image –

Map JS Change for MapField

  1. Modify CS file

Path: src\Feature\Maps\code\Sitecore\Shell\Applications\ContentEditor\FieldTypes
File Name: MAPField.cs
Change: Add Google API key in GetMapImageUrl function. Please refer below image –

CS File Change for MapField

Hope this is helpful. Happy Coding.

Let us have coffee together and discuss your requirement for Sitecore. Mail us at info@addact.in.