A React Native wrapper for Microsoft Bing Maps.
Using npm:
npm install --save react-native-bing-maps
Using yarn:
yarn add react-native-bing-maps
Automatic linking is supported for both iOS and Android
Previous versions need to do manual linking. No support is offered for these previous react-native versions. Upgrade to modern versions of react-native. Use upgrade-helper
tool on the internet if needed.
Bing Maps Key. Must be obtained to use the Bing Maps SDK. The Bing Maps Key will need to be set through the API to use the Bing Maps native control and to make API requests to Bing Maps services. Visit the Bing Maps Dev Center Help page for detailed steps on obtaining one.
In order to use Bing Maps on Android you need to add the credential key to gradle.
secrets.gradle
file in android/app/
folder with the following contentsext.credentialsKey = "you_bing_maps_key_here"
android/app/build.gradle
file by addingapply from: 'secrets.gradle'
at the top.
buildTypes.each {
it.buildConfigField "String", "CREDENTIALS_KEY", "\"$credentialsKey\""
}
in the android
field next to defaultConfig
. This will apply the same key to all build types.
for separate creadential key for build types you can add it respective build type config
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import BingMapsView from 'react-native-bing-maps';
export default function App() {
return (
<View style={styles.container}>
<BingMapsView
credentialsKey="your_bing_maps_api_key"
mapLocation={{ lat: 12.9010875, long: 77.6095084, zoom: 15 }}
style={styles.box}
/>
</View>
);
}
Bing Map key accquired from above steps.
describes the currect location of the map. The MapLocation type is described here
Array of pins to be displayed on the map. The MapPin type is described here.
string in JSON format to change the appearance of the map. Refer How to change Appearance of map for detailed info. Or you can use map stylesheet generator to generate the JSON.
Style to be applied to the parent view of Bing Map view.
Sets the building visibility on the map.
Sets the landmarks icons visibility on the map.
Sets transit features visibility on the map.
Sets compass button visiblity on the map.
Sets tilt button visibility on the map.
Sets zoom buttons visibility on the map.
Sets the microsoft copyright caption visibility on the map.
Event returns lat
and long
of the pin clicked on map.
Event returns the loading status of the map.
type BingMapsProps = {
credentialsKey: string;
pins?: MapPin[];
mapLocation?: MapLocation;
mapStyle?: string;
style?: ViewStyle;
buildingsVisible?: boolean;
businessLandmarksVisible?: boolean;
transitFeaturesVisible?: boolean;
compassButtonVisible?: boolean;
tiltButtonVisible?: boolean;
zoomButtonsVisible?: boolean;
copyrightDisplay?: 'allowHiding' | 'always';
onMapPinClicked?: (e: NativeSyntheticEvent<EventTarget>) => void;
onMapLoadingStatusChanged?: (e: NativeSyntheticEvent<EventTarget>) => void;
};
MapLocation {
lat: number;
long: number;
zoom: number;
}
Where zoom
is a number between 1 and 19. For more info on zoom levels visit Microsoft's docs on Understanding Scale and Resolutions
MapPin {
lat: number;
long: number;
icon: string;
}
where icon
is the SVG string for the pin icon you want to display;
MIT