MCPcopy Create free account
hub / github.com/react-native-maps/react-native-maps / takeSnapshot

Method takeSnapshot

src/MapView.tsx:963–985  ·  view source on GitHub ↗

* Takes a snapshot of the map and saves it to a picture * file or returns the image as a base64 encoded string. * * @param args Configuration options * @param [args.width] Width of the rendered map-view (when omitted actual view width is used). * @param [args.height] Height of the ren

(args: SnapshotOptions)

Source from the content-addressed store, hash-verified

961 * @return Promise Promise with either the file-uri or base64 encoded string
962 */
963 takeSnapshot(args: SnapshotOptions): Promise<string> {
964 // Sanitize inputs
965 const config = {
966 width: args.width || 0,
967 height: args.height || 0,
968 region: args.region || {},
969 format: args.format || 'png',
970 quality: args.quality || 1.0,
971 result: args.result || 'file',
972 };
973 if (config.format !== 'png' && config.format !== 'jpg') {
974 throw new Error('Invalid format specified');
975 }
976 if (config.result !== 'file' && config.result !== 'base64') {
977 throw new Error('Invalid result specified');
978 }
979
980 if (this.fabricMap.current) {
981 // @ts-ignore
982 return this.fabricMap.current.takeSnapshot(config);
983 }
984 return Promise.reject('takeSnapshot not supported on this platform');
985 }
986
987 /**
988 * Convert a coordinate to address by using default Geocoder

Callers

nothing calls this directly

Calls 1

takeSnapshotMethod · 0.65

Tested by

no test coverage detected