-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added examples of search control for vanilla, react, vue
- Loading branch information
MokujinMap
committed
May 15, 2024
1 parent
24290ca
commit 267c212
Showing
5 changed files
with
233 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,57 @@ | ||
import type {MMapLocationRequest, LngLatBounds} from '@mappable-world/mappable-types'; | ||
import type {MMapLocationRequest, LngLatBounds, SearchResponse, Margin, Feature} from '@mappable-world/mappable-types'; | ||
|
||
mappable.ready.then(() => { | ||
mappable | ||
.getDefaultConfig() | ||
.setApikeys({search: 'pk_ZAROIlpukeMufiKGZFwyulaUQEXIjDySkgduDDiovkifzqXLsJweeFmxeoRwZNNc'}); | ||
}); | ||
|
||
const BOUNDS: LngLatBounds = [ | ||
[54.58311, 25.9985], | ||
[56.30248, 24.47889] | ||
]; | ||
|
||
export const LOCATION: MMapLocationRequest = {bounds: BOUNDS}; | ||
export const MARGIN: Margin = [30, 30, 30, 30]; | ||
|
||
export const initialMarkerProps = { | ||
properties: { | ||
name: 'Dubai', | ||
description: 'United Arab Emirates' | ||
}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [55.289311, 25.229762] | ||
} | ||
} as Feature; | ||
|
||
export const findSearchResultBoundsRange = (searchResult: SearchResponse) => { | ||
let minLng: number | null = null; | ||
let maxLng: number | null = null; | ||
let minLat: number | null = null; | ||
let maxLat: number | null = null; | ||
|
||
searchResult.forEach((searchResultElement) => { | ||
const [lng, lat] = searchResultElement.geometry.coordinates; | ||
|
||
if (lng < minLng || minLng === null) { | ||
minLng = lng; | ||
} | ||
|
||
if (lng > maxLng || maxLng === null) { | ||
maxLng = lng; | ||
} | ||
|
||
if (lat < minLat || minLat === null) { | ||
minLat = lat; | ||
} | ||
|
||
if (lat > maxLat || maxLat === null) { | ||
maxLat = lat; | ||
} | ||
}); | ||
|
||
return [ | ||
[minLng, maxLat], | ||
[maxLng, minLat] | ||
] as LngLatBounds; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters