mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
providers: complete?
This commit is contained in:
parent
552e3effb8
commit
b6bd300e1b
14 changed files with 150 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
|||
import { editor } from '$modules/Editor';
|
||||
import { COLORS, CONFIG } from '$config';
|
||||
import saveAs from 'file-saver';
|
||||
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
|
||||
import { DEFAULT_PROVIDER, PROVIDERS, replaceProviderUrl } from '$constants/providers';
|
||||
|
||||
const latLngToTile = latlng => {
|
||||
const { map } = editor.map;
|
||||
|
@ -65,13 +65,6 @@ export const getPolyPlacement = () => (
|
|||
: editor.poly.poly.getLatLngs().map((latlng) => ({ ...editor.map.map.latLngToContainerPoint(latlng) }))
|
||||
);
|
||||
|
||||
const replaceProviderUrl = (provider, { x, y, zoom }) => {
|
||||
const { url, range } = (PROVIDERS[editor.provider] || PROVIDERS[DEFAULT_PROVIDER]);
|
||||
const random = (range && range.length >= 2) ? Math.round((Math.random() * (range[1] - range[0])) + range[0]) : 1;
|
||||
|
||||
return url.replace('{x}', x).replace('{y}', y).replace('{z}', zoom).replace('{s}', random);
|
||||
};
|
||||
|
||||
const getImageSource = coords => replaceProviderUrl(editor.provider, coords);
|
||||
|
||||
export const imageFetcher = source => new Promise((resolve, reject) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue