Skip to content

Commit

Permalink
feat: Add Streetview map (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bigismall authored Nov 22, 2024
1 parent d424aeb commit 9ee863d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
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

0 comments on commit 9ee863d

Please sign in to comment.