What the Google Maps custom editor looks like
How the custom editor works
This version of the Google Maps custom editor works for any string property, meaning coordinates are saved comma-separated like “50.000,20,000” (latitude, longitude).
For details on the dijit implementation, see the extensive comments in the main Editor.js file.
How to add the Google Maps editor to your site
Place the contents of the widget folder in /ClientResources/Scripts (or a sub-folder therein):
Include the root namespace in module.config in your site root. Note that the path attribute is relative to the ClientResources folder. The following assumes the widget folder is located at /ClientResources/Scripts/widgets/googlemaps:
Create an editor descriptor class mapping to the widget type by its namespace:
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = UIHint)]
public class CoordinatesEditorDescriptor : EditorDescriptor
{
public const string UIHint = "CoordinatesEditorDescriptor";
public CoordinatesEditorDescriptor()
{
ClientEditingClass = "tedgustaf.googlemaps.Editor";
}
}
Next, add an EditorDescriptor attribute with the CoordinatesEditorDescriptor type to any string property:
[EditorDescriptor(EditorDescriptorType = typeof(CoordinatesEditorDescriptor))]
public virtual string Coordinates { get; set; }
You should now be able to use the Google Maps editor in EPiServer:
Simplifying property access
Instead of saving the value as a string, one could modify the dijit to support either a block type or a custom property type, as that would eliminate the need for parsing the string when you want to get the coordinates programmatically. I.e., you would be able to get coordinates like CurrentPage.Coordinates.Longitude and CurrentPage.Coordinates.Longitude, respectively.
Known issues and limitations
The editor relies on the Google Maps SDK loaded from CDN. The editor will break if you do not have an active internet connection, effectively preventing the EPiServer UI from loading.
Download
The Episerver Google Maps editor add-on is available on the Episerver NuGet feed.