Get started with Woosmap for React Native

Get access to Woosmap services for your native mobile developments on hybrid React Native development.

  1. Installation
  2. Dependency
  3. How to display Map
  4. Accessing various map functions
  5. Customize loader

The Woosmap React Native plugin is a library that embeds interactive maps directly into your application. You can also add stores overlay to the map to call out points of interest and get relative information.

The SDK offers an interface to manage the Indoor Mapview and subscribe to events on the map.

Please get your email and token from your pro account. You may ask for one if necessary, or you can test with our developers’ credentials if you lack time.

  Android iOS
Support SDK 33+ 13.0+

Installation

sh
        npm install @woosmap/react-native-woosmap

    

Dependency

How to display Map

  1. Instantiating a WoosmapView: WoosmapView can be initialize with either public key or private key (Note: An unrestricted private key is not supported.)
src/plugin_snippet.tsx
        import {
  WoosmapView,
  MapController,
  LatLngBounds,
  WoosPadding,
  LatLng,
} from '@woosmap/react-native-woosmap';
// ...
<WoosmapView
        ref={mapRef}
        mapOptions={mapOptions}
        wooskey={'Your Woosmap public key'}
        click={() => {
          console.log('click');
        }}
      />


    
        import {
  WoosmapView,
  MapController,
  LatLngBounds,
  WoosPadding,
  LatLng,
} from '@woosmap/react-native-woosmap';
// ...
<WoosmapView
        ref={mapRef}
        mapOptions={mapOptions}
        wooskey={Platform.OS === 'android'
            ? 'Woosmap android private key'
            : 'Woosmap iOS private key'}
        click={() => {
          console.log('click');
        }}
      />


    

Accessing various map functions

src/plugin_snippet.tsx
        await mapRef.current?.fitBounds(
      LatLngBounds.jsonToObj({
        ne: { lat: 48.844437932920535, lng: 2.3743880269761393 },
        sw: { lat: 48.854437932920535, lng: 2.3843880269761393 },
      }),
      WoosPadding.jsonToObj({ top: 2, left: 2, right: 3, bottom: 3 })
    );

    
src/plugin_snippet.tsx
        const result:LatLng = await mapRef.current?.getCenter();

    
src/plugin_snippet.tsx
         const result: LatLngBounds = await mapRef.current?.getBounds(
        WoosPadding.jsonToObj({top: 2, left: 2, right: 3, bottom: 3}));

    
src/plugin_snippet.tsx
        const result: numeric = (await mapRef.current?.getHeading()) as numeric;

    
src/plugin_snippet.tsx
        const result: numeric = (await mapRef.current?.getTilt()) as numeric;

    
src/plugin_snippet.tsx
        const result: numeric = (await mapRef.current?.getZoom()) as numeric;

    
src/plugin_snippet.tsx
        await mapRef.current?.panBy(20, 10);

    
src/plugin_snippet.tsx
        await mapRef.current?.panTo(
        LatLng.jsonToObj({lat: 48.844437932920535, lng: 2.3743880269761393}),
        WoosPadding.jsonToObj({top: 2, left: 2, right: 3, bottom: 3}));

    
src/plugin_snippet.tsx
        await mapRef.current?.panToBounds(
        LatLngBounds.jsonToObj({
          ne: {lat: 48.844437932920535, lng: 2.3743880269761393},
          sw: {lat: 48.854437932920535, lng: 2.3843880269761393}
        }),
        WoosPadding.jsonToObj({top: 2, left: 2, right: 3, bottom: 3}));

    
src/plugin_snippet.tsx
        await mapRef.current?.setCenter(
        LatLng.jsonToObj({lat: 48.844437932920535, lng: 2.3743880269761393}),
        WoosPadding.jsonToObj({top: 2, left: 2, right: 3, bottom: 3}));

    
src/plugin_snippet.tsx
        await mapRef.current?.setHeading(20);

    
src/plugin_snippet.tsx
        await mapRef.current?.setTilt(5);

    
src/plugin_snippet.tsx
        await mapRef.current?.setZoom(20);

    

Customize loader

Plugin allows customization of the loader on the map. To change the loader, you need to add a gif image to the assets folder and update the loader setting in the widget as shown below.

src/plugin_snippet.tsx
            <WoosmapView
        ref={mapRef}
        mapOptions={mapOptions}
        wooskey={Platform.OS === 'android'
            ? 'Woosmap android private key'
            : 'Woosmap iOS private key'}
        loader={require('../../asset/loader/spinner.gif')}
        ...
        ...
        />

    
Was this article helpful?
Have more questions? Submit a request