8

We want to declare our own map type, so that we can use a more minimal map than the road map; akin to something created using https://mapstyle.withgoogle.com/

The map mode can be defined in Sitecore:

e.g.

/sitecore/system/Settings/Feature/Experience Accelerator/Maps/Enums/Map Modes/OurMap

but it looks like Sitecore.XA.Feature.Maps.Repositories.MapsRepository.MapMode reads it from data source but then casts it to a MapModes enum. This enum is later ToString'd in GetJsonDataProperties and this appears to be the only place the enum appears to be used.

It looks like we have to specify our own MapsRepository and override GetJsonDataProperties (where MapMode is ToString'd) just to set our own map mode.

Is there another way to reduce the features used on a map without affecting the existing MapModes? Am I missing something?

1

Map mode string which is passed to the component-map.js and later on passed to google-maps-connector.js or bing-maps-connector.js depending on what map provider are you using. This mode is next used to create a certain map and inform Google or Bing map in which mode render.

If you want to extend Google or Bing with an additional mode which recently becomes available for one of those then yes - your thinking is correct. I would:

  1. Create new repository which is inheriting from MapsRepository
  2. Override just MapMode property (it's virtual as most of the things in SXA)
  3. Replace current IMapsRepository implementation which is in the container with your one.

There is one more way - if you always want to use this new map mode then override component-map.js and just hardcode this mode there (line 197). In that case, you don't need any backend code changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.