Skip to content

Commit

Permalink
fix externals, update
Browse files Browse the repository at this point in the history
  • Loading branch information
ToastHawaii committed Jul 13, 2024
1 parent 38354b7 commit 9d7f99c
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 28 deletions.
6 changes: 3 additions & 3 deletions docs/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.244e88ca.css",
"main.js": "/static/js/main.7d0c22d4.js",
"main.js": "/static/js/main.59d17f6e.js",
"index.html": "/index.html",
"main.244e88ca.css.map": "/static/css/main.244e88ca.css.map",
"main.7d0c22d4.js.map": "/static/js/main.7d0c22d4.js.map"
"main.59d17f6e.js.map": "/static/js/main.59d17f6e.js.map"
},
"entrypoints": [
"static/css/main.244e88ca.css",
"static/js/main.7d0c22d4.js"
"static/js/main.59d17f6e.js"
]
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html class="help" lang="en"><head><title></title><meta charset="utf-8"/><link rel="manifest" href="/manifest.json"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="theme-color" content="#da532c"/><meta name="msapplication-navbutton-color" content="#da532c"/><meta name="msapplication-starturl" content="/"/><link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png"/><link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#da532c"/><link rel="shortcut icon" href="/icons/favicon.ico"/><meta name="msapplication-TileColor" content="#da532c"/><meta name="msapplication-config" content="/icons/browserconfig.xml"/><link rel="stylesheet" href="/lib/leaflet.css"/><link rel="stylesheet" href="/lib/OverPassLayer.css"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"/><meta name="monetization" content="$ilp.uphold.com/BwpBDr48YqPi"/><script src="/serviceWorkerRegister.js"></script><script defer="defer" src="/static/js/main.7d0c22d4.js"></script><link href="/static/css/main.244e88ca.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script async src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script><script async type="text/javascript" src="https://taginfo.openstreetmap.org/js/taglists.js"></script></body></html>
<!doctype html><html class="help" lang="en"><head><title></title><meta charset="utf-8"/><link rel="manifest" href="/manifest.json"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="theme-color" content="#da532c"/><meta name="msapplication-navbutton-color" content="#da532c"/><meta name="msapplication-starturl" content="/"/><link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png"/><link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#da532c"/><link rel="shortcut icon" href="/icons/favicon.ico"/><meta name="msapplication-TileColor" content="#da532c"/><meta name="msapplication-config" content="/icons/browserconfig.xml"/><link rel="stylesheet" href="/lib/leaflet.css"/><link rel="stylesheet" href="/lib/OverPassLayer.css"/><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"/><meta name="monetization" content="$ilp.uphold.com/BwpBDr48YqPi"/><script src="/serviceWorkerRegister.js"></script><script defer="defer" src="/static/js/main.59d17f6e.js"></script><link href="/static/css/main.244e88ca.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script async src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script><script async type="text/javascript" src="https://taginfo.openstreetmap.org/js/taglists.js"></script></body></html>

Large diffs are not rendered by default.

File renamed without changes.

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"leaflet-overpass-layer": "github:ToastHawaii/leaflet-overpass-layer",
"md5": "2.3.0",
"moment": "2.30.1",
"moment-timezone": "0.5.45",
"opening_hours": "3.8.0",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
24 changes: 12 additions & 12 deletions src/client/externalResources.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"bicycle-self-repair": [
{
"name": "Bikekitchen",
"url": "http://www.heureux-cyclage.org/les-ateliers-dans-le-monde?lang=en"
"url": "https://www.heureux-cyclage.org/les-ateliers-dans-le-monde"
},
{
"name": "Fahrradselbsthilfewerkstätten in Berlin",
Expand Down Expand Up @@ -153,7 +153,7 @@
},
{
"name": "RestEssBar",
"url": "http://restessbar.ch/de",
"url": "https://restessbar.ch/standorte/",
"bounds": [45.818, 5.9559, 47.8085, 10.4923]
},
{
Expand Down Expand Up @@ -186,7 +186,7 @@
},
{
"name": "falling fruit",
"url": "http://fallingfruit.org/?z={zoom}&y={lat}&x={lng}&t=OSM"
"url": "https://fallingfruit.org/?z={zoom}&y={lat}&x={lng}&t=OSM"
},
{
"name": "Zero Waste Map",
Expand Down Expand Up @@ -287,27 +287,27 @@
"animal": [
{
"name": "Zoo-Infos.org - Schweiz",
"url": "http://ch.zoo-infos.org/set.html?karte.php",
"url": "https://ch.zoo-infos.org/set.html?karte.php",
"bounds": [45.818, 5.9559, 47.8085, 10.4923]
},
{
"name": "Zoo-Infos.de - Deutschland",
"url": "http://www.zoo-infos.de/set.html?karte.php",
"url": "https://www.zoo-infos.de/set.html?karte.php",
"bounds": [47.27, 5.87, 55.1, 15.04]
},
{
"name": "Zoo-Infos.org - Österreich",
"url": "http://at.zoo-infos.org/set.html?karte.php",
"url": "https://at.zoo-infos.org/set.html?karte.php",
"bounds": [46.3723, 9.5307, 49.0205, 17.1608]
},
{
"name": "Zoo-Infos.org - Frankreich",
"url": "http://fr.zoo-infos.org/set.html?karte.php",
"url": "https://fr.zoo-infos.org/set.html?karte.php",
"bounds": [42.13, -5.02, 51.27, 8.43]
},
{
"name": "Arca-Net",
"url": "http://arca-net.info/map_categories/frame_map.asp?sprache=de",
"url": "https://arca-net.info/suche-in-karte/",
"bounds": [-32.0, -0.3, 52.3, 68.9]
}
],
Expand All @@ -332,14 +332,14 @@
"garden": [
{
"name": "Arca-Net",
"url": "http://arca-net.info/map_categories/frame_map.asp",
"url": "https://arca-net.info/suche-in-karte/",
"bounds": [-32.0, -0.3, 52.3, 68.9]
}
],
"garden-with-name": [
{
"name": "Arca-Net",
"url": "http://arca-net.info/map_categories/frame_map.asp",
"url": "https://arca-net.info/suche-in-karte/",
"bounds": [-32.0, -0.3, 52.3, 68.9]
}
],
Expand Down Expand Up @@ -387,12 +387,12 @@
"bicycle": [
{
"name": "Velafrica",
"url": "http://velafrica.ch/de/Machen-Sie-mit/Sammelstellen",
"url": "https://velafrica.ch/wie-sie-helfen/velospende/",
"bounds": [45.818, 5.9559, 47.8085, 10.4923]
},
{
"name": "Bikekitchen",
"url": "http://www.heureux-cyclage.org/les-ateliers-dans-le-monde?lang=en"
"url": "https://www.heureux-cyclage.org/les-ateliers-dans-le-monde"
},
{
"name": "Fahrradselbsthilfewerkstätten in Berlin",
Expand Down
2 changes: 1 addition & 1 deletion src/osm-app-component/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function App<M>({
externalResources?: any;
}) {
const { t } = useTranslation();

// printTagInfoList(t, "https://priceless.zottelig.ch/", filters);

const params = getQueryParams();
Expand Down
18 changes: 18 additions & 0 deletions src/osm-app-component/control/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ export function search(map: Map, value: string) {
});
}

export function searchCountry(map: Map, country: string) {
getJson("https://nominatim.openstreetmap.org/search", {
format: "json",
country: country,
limit: 1,
}).then((r) => {
const result = r[0];
if (!result) return;
map.flyToBounds(
[
[result.boundingbox[0], result.boundingbox[2]],
[result.boundingbox[1], result.boundingbox[3]],
],
{ animate: false }
);
});
}

export function Search({ map }: { map: Map }) {
const { t } = useTranslation();

Expand Down
26 changes: 19 additions & 7 deletions src/osm-app-component/initMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import icon from "leaflet/dist/images/marker-icon.png";
import icon2x from "leaflet/dist/images/marker-icon-2x.png";
import iconShadow from "leaflet/dist/images/marker-shadow.png";
import { TFunction } from "i18next";
import { search } from "./control/Search";
import { search, searchCountry } from "./control/Search";
import { getUserCountry } from "./utilities/getUserCountry";

delete (L.Icon.Default.prototype as any)._getIconUrl;

Expand Down Expand Up @@ -152,13 +153,24 @@ export async function initMap(

type State = { lat: number; lng: number; zoom: number };

const state = get<State>("position") || {
lat: 47.37,
lng: 8.54,
zoom: minZoom,
};
let state = get<State>("position") as State;

map.setView(new L.LatLng(state.lat, state.lng), state.zoom);
if (!state) {
// try get position from user
const userCountry = getUserCountry();
if (userCountry) {
searchCountry(map, userCountry);
} else {
state = state || {
lat: 47.37,
lng: 8.54,
zoom: minZoom,
};
map.setView(new L.LatLng(state.lat, state.lng), state.zoom);
}
} else {
map.setView(new L.LatLng(state.lat, state.lng), state.zoom);
}

// placeholders for the L.marker and L.circle representing user's current position and accuracy
let currentPosition: L.Layer | L.Marker<any>;
Expand Down
22 changes: 22 additions & 0 deletions src/osm-app-component/utilities/getUserCountry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import latest from "moment-timezone/data/meta/latest.json";

export function getUserCountry() {
const timeZoneCityToCountry: { [city: string]: string } = {};

Object.keys(latest.zones).forEach((z) => {
const cityArr = z.split("/");
const city = cityArr[cityArr.length - 1];
timeZoneCityToCountry[city] = (latest.countries as any)[
(latest.zones as any)[z].countries[0]
].name;
});

if (Intl) {
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var tzArr = userTimeZone.split("/");
const userCity = tzArr[tzArr.length - 1];
return timeZoneCityToCountry[userCity];
}

return undefined;
}

0 comments on commit 9d7f99c

Please sign in to comment.