mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Make it work for mobile
This commit is contained in:
parent
508a63a60d
commit
28cf2287f2
@ -1,20 +1,13 @@
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { apiClient } from '../../services/api';
|
||||
import {
|
||||
MapContainer,
|
||||
GeoJSON,
|
||||
useMapEvents,
|
||||
Circle,
|
||||
TileLayer,
|
||||
Tooltip,
|
||||
Marker,
|
||||
} from 'react-leaflet';
|
||||
import { MapContainer, GeoJSON, useMapEvents, TileLayer, Tooltip, Marker } from 'react-leaflet';
|
||||
import { useTheme, LinearProgress } from '@mui/material';
|
||||
import { UseAppStoreType, AppContext } from '../../contexts/AppContext';
|
||||
import { GeoJsonObject } from 'geojson';
|
||||
import { Icon, LeafletMouseEvent, Point } from 'leaflet';
|
||||
import { PublicOrder } from '../../models';
|
||||
import OrderTooltip from '../Charts/helpers/OrderTooltip';
|
||||
import getWorldmapGeojson from '../../geo/Web';
|
||||
|
||||
interface Props {
|
||||
orderType?: number;
|
||||
@ -45,9 +38,7 @@ const Map = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (!worldmap) {
|
||||
apiClient
|
||||
.get(baseUrl, '/static/assets/geo/countries-coastline-10km.geo.json')
|
||||
.then(setWorldmap);
|
||||
getWorldmapGeojson(apiClient, baseUrl).then(setWorldmap);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@ -58,13 +49,18 @@ const Map = ({
|
||||
order?: PublicOrder,
|
||||
) => {
|
||||
const color = orderType == 1 ? 'Blue' : 'Lilac';
|
||||
const path =
|
||||
window.NativeRobosats === undefined
|
||||
? '/static/assets'
|
||||
: 'file:///android_asset/Web.bundle/assets';
|
||||
|
||||
return (
|
||||
<Marker
|
||||
key={key}
|
||||
position={position}
|
||||
icon={
|
||||
new Icon({
|
||||
iconUrl: `../../../static/assets/vector/Location_robot_${color}.svg`,
|
||||
iconUrl: `${path}/vector/Location_robot_${color}.svg`,
|
||||
iconAnchor: [18, 32],
|
||||
iconSize: [32, 32],
|
||||
})
|
||||
@ -126,6 +122,7 @@ const Map = ({
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
|
||||
referrerPolicy='no-referrer'
|
||||
/>
|
||||
{getOrderMarkers()}
|
||||
</>
|
||||
|
7
frontend/src/geo/Native.js
Normal file
7
frontend/src/geo/Native.js
Normal file
@ -0,0 +1,7 @@
|
||||
import worldmap from '../../static/assets/geo/countries-coastline-10km.geo.json';
|
||||
|
||||
const getWorldmapGeojson = async (_apiClient, _baseUrl) => {
|
||||
return worldmap;
|
||||
};
|
||||
|
||||
export default getWorldmapGeojson;
|
5
frontend/src/geo/Web.js
Normal file
5
frontend/src/geo/Web.js
Normal file
@ -0,0 +1,5 @@
|
||||
export const getWorldmapGeojson = async (apiClient, baseUrl) => {
|
||||
return apiClient.get(baseUrl, '/static/assets/geo/countries-coastline-10km.geo.json');
|
||||
};
|
||||
|
||||
export default getWorldmapGeojson;
|
@ -133,6 +133,15 @@ const configMobile: Configuration = {
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/geo/Web.js'),
|
||||
loader: 'file-replace-loader',
|
||||
options: {
|
||||
condition: 'if-replacement-exists',
|
||||
replacement: path.resolve(__dirname, 'src/geo/Native.js'),
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/components/RobotAvatar/placeholder.json'),
|
||||
loader: 'file-replace-loader',
|
||||
@ -158,6 +167,10 @@ const configMobile: Configuration = {
|
||||
from: path.resolve(__dirname, 'static/assets/sounds'),
|
||||
to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/sounds'),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/assets/vector'),
|
||||
to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/vector'),
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user