maps icon indicating copy to clipboard operation
maps copied to clipboard

feat: allow merging StyleImport configs

Open bvanderdrift opened this issue 1 year ago • 1 comments

Description

Added optional merge property to StyleImport that allows merging an import config with the existing style import config, instead of full override.

Defaults to false when not defined, to stay in line with current behaviour of StyleImport.

I haven't tested this on the example app and/or added an example, since I'm on some strict deadlines. Would love to get some help getting this PR over the finish line.

Checklist

  • [x] I've read CONTRIBUTING.md
  • [x] I updated the doc/other generated code with running yarn generate in the root folder
  • [ ] I have tested the new feature on /example app.
    • [ ] In V11 mode/ios
    • [ ] In New Architecture mode/ios
    • [ ] In V11 mode/android
    • [ ] In New Architecture mode/android
  • [ ] I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

Tested this both on iOS & Android, but for simplicity I only added iOS demo video's here.

Test explained: the map style has both POI not showing & light mode dusk.

merge unset

Expected: full override, so 'POI showing' falls back to default (true).

https://github.com/user-attachments/assets/17df30e9-a2e8-4798-8db2-f25b4ec445a1

merge: false

Expected: full override, so 'POI showing' falls back to default (true).

https://github.com/user-attachments/assets/64c7ed1b-3e76-4b21-ab5c-ef048708b423

merge: true

Expected: merging style, so 'POI showing' stays as defined in the style (false).

https://github.com/user-attachments/assets/6684a273-17cf-4384-b72b-6c9a32ac6f21

Component to test with

import Mapbox, {StyleImport} from '@rnmapbox/maps';
import React from 'react';

const DemoMap = () => {
  return (
    <Mapbox.MapView
      style={{flex: 1}}
      styleURL="mapbox://styles/beerd/cm0xlddce00zx01pm5zyb9om9">
      <Mapbox.Camera
        defaultSettings={{
          centerCoordinate: [4.9041, 52.3676],
          zoomLevel: 13,
        }}
        centerCoordinate={[4.9041, 52.3676]}
      />
      <StyleImport
        id="basemap"
        existing
        config={{
          lightPreset: 'night',
        }}
        merge={true}
      />
    </Mapbox.MapView>
  );
};

export default DemoMap;

bvanderdrift avatar Sep 11 '24 08:09 bvanderdrift

@bvanderdrift thanks much looks amazing. 👍

mfazekas avatar Sep 12 '24 05:09 mfazekas