Proximi.io Map for React Native
- fixed imports
- included lib folder
- added image management methods
- added source management methods
- added layer management methods
To install Proximi.io Map to React Native Project, run:
yarn add proximiio/react-native-proximiio
yarn add proximiio/react-native-proximiio-map
Set USE_FRAMEWORKS linkage to static, either by using USE_FRAMEWORKS variable or hardcoding
use_frameworks! :linkage => :static
inside ios/Podfile
Add Proximi.io Maven repository into build.gradle repositories section
maven { url "https://maven.proximi.io/repository/android-releases/" }
Its required from application to handle bluetooth and location permissions,
eg. when using react-native-permissions
const PermissionList = Platform.OS === 'ios'
? [
PERMISSIONS.IOS.BLUETOOTH,
PERMISSIONS.IOS.LOCATION_ALWAYS,
PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
]
: [
PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION,
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
PERMISSIONS.ANDROID.BLUETOOTH_SCAN,
];
refer to example app implementation in this repository for more details
Insert Map Component
export default function App() {
let mapView = useRef<ProximiioMap | null>(null);
return (
<ProximiioMap
ref={(ref) => (mapView.current = ref)}
style={{ flex: 1 }}
token={ProximiioToken}
center={PlaceCoordinates}
zoom={16}
level={0}
pitch={0}
bearing={0}
onClick={onPoiClick}
onReady={onReady}
onTouchMove={onTouchMove}
icons={Icons}
/>
)
}
Use your Proximi.io Token here, you can find it Proximi.io Portal under Application
Use { lng: 12.345, lat: 12.345 } format to set the default center of map
Fires when user taps a POI Feature
Fires when map has finished loading
Add an image to the style. This image can be displayed on the map like any other icon in the style's sprite using the image's ID with icon-image, background-pattern, fill-pattern, or line-pattern.
Use base64 encoded image as uri parameter
Check whether or not an image with a specific ID exists in the style. This checks both images in the style's original sprite and any images that have been added at runtime using Map#addImage.
Remove an image from a style. This can be an image from the style's original sprite or any images that have been added at runtime using Map#addImage.
Adds a source to the map's style.
Returns the source with the specified ID in the map's style.
Check whether or not source exists in style.
Removes a source from the map's style.
Adds a MapLibre style layer to the map's style.
A layer defines how data from a specified source will be styled. Read more about layer types and available paint and layout properties in the MapLibre Style Specification.
Returns the layer with the specified ID in the map's style.
Checks whether or not layer exists in style.
Moves a layer to a different z-position.
beforeId is ID of an existing layer to insert the new layer before. When viewing the map, the id layer will appear beneath the beforeId layer.
Removes the layer with the given ID from the map's style.
Sets the map's geographical centerpoint.
Sets current user position on map
Sets the map's zoom level
Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that evokes flight. The animation seamlessly incorporates zooming and panning to help the user maintain her bearings even after traversing a great distance.
see https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/FlyToOptions for available options
Pans the map to the specified location with an animated transition.
Sets current map floor level
Sets displayed POI Feature filtering, you can define standard js filter for Feature and wrap it in ``, eg: `function (feature) { return feature.properties.title === 'Checkpoint' }`
Cancels current POI Feature filtering
Calculates and returns Route data without displaying, you can either use Feature id as start/destination or coordinates with level
type ProximiioRouteConfiguration {
startFeatureId?: string;
startLatLonLevel?: number[];
destinationFeatureId?: string;
destinationLatLonLevel?: number[];
destinationTitle?: string | undefined;
waypointFeatureIdList?: string[][];
wayfindingOptions?: ProximiioWayfindingOptions;
}
export type ProximiioWayfindingOptions = {
avoidBarriers: boolean;
avoidElevators: boolean;
avoidEscalators: boolean;
avoidNarrowPaths: boolean;
avoidRamps: boolean;
avoidRevolvingDoors: boolean;
avoidStaircases: boolean;
avoidTicketGates: boolean;
pathFixDistance: number;
};
Calculates and returns Route data while displaying Routing elements on map, you can either use Feature id as start/destination or coordinates with level, see above for ProximiioRouteConfiguration spec
Cancels current started Route
Returns array of Amenity objects
Returns array of GeoJSON Features
Please see example/src/App.tsx inside this repository, meanwhile feel free to contact us on our Slack for more information.
To use example app edit example/src/constants.ts
and set your Proximi.io Application Token and default coordinates for
your place
Proximi.io 2024