Episerver Google Maps editor update

The Google Maps editor for Episerver has been updated to allow developers to customize settings such as API key, default zoom level and coordinates.

  • Ted Nyberg
  • 26 September 2018
  • 0

Update to the latest version

As of version 1.0.12 of the Episerver Google Maps add-on (available through the Episerver NuGet feed) it is possible to customize the editor using custom property settings. Note that this version requires Episerver CMS 11.

This allows you to set which API key to use for the Google Maps JavaScript API, and also allows you to set the default zoom level and coordinates for when there is no property value set.

Change Google Maps editor settings

The easiest way to override the default settings is to create your own editor descriptor:

C# Expand
[EditorDescriptorRegistration(TargetType = typeof(IGoogleMapsCoordinates), UIHint = UIHint, EditorDescriptorBehavior = EditorDescriptorBehavior.OverrideDefault)]
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = UIHint, EditorDescriptorBehavior = EditorDescriptorBehavior.OverrideDefault)]
public class CustomGoogleMapsEditorDescriptor : GoogleMapsEditorDescriptorBase
    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        base.ModifyMetadata(metadata, attributes);

        // API key for the Google Maps JavaScript API
        metadata.EditorConfiguration["apiKey"] = "your-api-key";

        // Default zoom level from 1 (least) to 20 (most)
        metadata.EditorConfiguration["defaultZoom"] = 5;

        // Default coordinates when no property value is set
        metadata.EditorConfiguration["defaultCoordinates"] = new { latitude = 59.336, longitude = 18.063 };

Fun fact

If you don't change the default coordinates, the editor will default to the coordinates of our office (or our old office, if you're on an older version of the add-on).

Questions or suggestions?

Feel free to post any questions and suggestions in the comments!