| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import * as WebBrowser from 'expo-web-browser';
- import * as React from 'react';
- import { StatusBar } from 'expo-status-bar';
- import { Div, Button } from 'react-native-magnus';
- import { Appbar } from 'react-native-paper';
- import { WebView } from 'react-native-webview';
- import { useTranslation } from 'react-i18next';
- import useModel from 'flooks';
- import { useRequest } from 'ahooks';
- import MapModel from './model';
- import {
- toastShow,
- toastHide,
- toastInfo,
- toastSuccess,
- } from '../utils/SystemUtils';
- export default function SearchMapScreen() {
- const { t } = useTranslation();
- const webRef = React.useRef();
- const { getNowLocation } = useModel(MapModel);
- const { run } = useRequest(
- (location) =>
- `/merchant/heatMap?longitude=${location.lng}&latitude=${location.lat}`,
- {
- manual: true,
- }
- );
- return (
- <>
- <WebView
- ref={webRef}
- source={{
- uri: `http://dingdong.izouma.com/map/heat3D`,
- }}
- style={{ flexGrow: 1, width: '100%' }}
- onMessage={({ nativeEvent }) => {
- console.log(nativeEvent);
- }}
- onLoadEnd={() => {
- getNowLocation().then((res) => {
- const { location } = res;
- run(location).then((res) => {
- var list = res.map((item) => {
- return {
- count: item.count,
- lng: item.longitude,
- lat: item.latitude,
- };
- });
- webRef.current.injectJavaScript(
- `window.draw(${JSON.stringify(list)},'${JSON.stringify(
- location
- )}')`
- );
- });
- });
- }}
- />
- </>
- );
- }
|