Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Streetview map #41

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<label for="wikimapia">Wikimapia</label>
<input type="radio" id="google-maps" name="map-type" value="google">
<label for="google-maps">Google maps</label>
<input type="radio" id="streetview" name="map-type" value="streetview">
<label for="streetview">Street view</label>
<input type="radio" id="bing" name="map-type" value="bing">
<label for="bing">BING</label>
<input type="radio" id="adsb" name="map-type" value="adsb">
Expand Down
10 changes: 9 additions & 1 deletion src/MapFactory.class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { MapObserver } from './Map.class.ts';
import { ADSBExchangeFrame, BingMapsFrame, GoogleMapsFrame, WikiMapiaFrame } from './Providers.ts';
import {
ADSBExchangeFrame,
BingMapsFrame,
GoogleMapsFrame,
GoogleStreetViewFrame,
WikiMapiaFrame,
} from './Providers.ts';
import { GOOGLE_MAPS_API_KEY, MAX_ZOOM } from './constants.ts';
import { MapType } from './types.ts';
import { getMapOptions, getUrlParams } from './url.ts';
Expand All @@ -16,6 +22,8 @@ export class MapFactory {
switch (type) {
case 'google':
return new GoogleMapsFrame($mapElement, mapOptions, { ...mapConfig, apiKey: GOOGLE_MAPS_API_KEY });
case 'streetview':
return new GoogleStreetViewFrame($mapElement, mapOptions, { ...mapConfig, apiKey: GOOGLE_MAPS_API_KEY });
case 'wiki':
return new WikiMapiaFrame($mapElement, mapOptions, mapConfig);
case 'bing':
Expand Down
7 changes: 7 additions & 0 deletions src/Providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export class GoogleMapsFrame extends MapObserver {
}
}

// Google street view embed
export class GoogleStreetViewFrame extends MapObserver {
public getUrl() {
return `https://www.google.com/maps/embed/v1/streetview?key=${this.config.apiKey}&location=${this.mapOptions.lat},${this.mapOptions.lng}&heading=0`;
}
}

export class WikiMapiaFrame extends MapObserver {
getUrl() {
return `https://wikimapia.org/#lat=${this.mapOptions.lat}&lon=${this.mapOptions.lng}&z=${this.mapOptions.zoom}&l=&ifr=1&m=w`;
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type MapType = 'wiki' | 'google' | 'osm' | 'bing' | 'adsb';
export type MapType = 'wiki' | 'google' | 'streetview' | 'osm' | 'bing' | 'adsb';
export type LayerName = 'OSM' | 'OSM DE' | 'Humanitarian' | 'Topography' | 'Cyclo' | 'Satellite' | 'Rail';

// Create array based on the MapType
const mapTypeArray: MapType[] = ['wiki', 'google', 'osm', 'bing', 'adsb'];
const mapTypeArray: MapType[] = ['wiki', 'google', 'streetview', 'osm', 'bing', 'adsb'];
const layerNameArray: LayerName[] = ['OSM', 'OSM DE', 'Humanitarian', 'Topography', 'Cyclo', 'Satellite', 'Rail'];

export const isLayerName = (value: string): value is LayerName => layerNameArray.includes(value as LayerName);
Expand Down