import { MapUtils, MapRegion } from'./MapUtils';
import { IgcGeographicMapModule } from'igniteui-webcomponents-maps';
import { IgcGeographicMapComponent } from'igniteui-webcomponents-maps';
import { IgcDataChartInteractivityModule } from'igniteui-webcomponents-charts';
import { BingMapsImageryStyle } from'igniteui-webcomponents-maps';
import { IgcBingMapsMapImagery } from'igniteui-webcomponents-maps';
import { ModuleManager } from'igniteui-webcomponents-core';
ModuleManager.register(
IgcDataChartInteractivityModule,
IgcGeographicMapModule
);
exportclassMapDisplayImageryBingTiles{
private geoMap1: IgcGeographicMapComponent;
private geoMap2: IgcGeographicMapComponent;
private geoMap3: IgcGeographicMapComponent;
constructor() {
this.geoMap1 = document.getElementById('map1') as IgcGeographicMapComponent;
this.geoMap2 = document.getElementById('map2') as IgcGeographicMapComponent;
this.geoMap3 = document.getElementById('map3') as IgcGeographicMapComponent;
this.createMap1(this.geoMap1);
this.createMap2(this.geoMap2);
this.createMap3(this.geoMap3);
}
createMap1(map: IgcGeographicMapComponent) {
map.zoomable = true;
const tileSource = new IgcBingMapsMapImagery();
tileSource.apiKey = MapUtils.getBingKey();
tileSource.imageryStyle = BingMapsImageryStyle.Aerial;
// resolving BingMaps uri based on HTTP protocol of hosting websitelet tileUri = tileSource.actualBingImageryRestUri;
let isHttpSecured = window.location.toString().startsWith('https:');
if (isHttpSecured) {
tileSource.bingImageryRestUri = tileUri.replace('http:', 'https:');
} else {
tileSource.bingImageryRestUri = tileUri.replace('https:', 'http:');
}
map.backgroundContent = tileSource;
// optional - navigating to a map region
MapUtils.navigateTo(map, MapRegion.Caribbean);
}
createMap2(map: IgcGeographicMapComponent) {
map.zoomable = true;
const tileSource = new IgcBingMapsMapImagery();
tileSource.apiKey = MapUtils.getBingKey();
tileSource.imageryStyle = BingMapsImageryStyle.AerialWithLabels;
// resolving BingMaps uri based on HTTP protocol of hosting websitelet tileUri = tileSource.actualBingImageryRestUri;
let isHttpSecured = window.location.toString().startsWith('https:');
if (isHttpSecured) {
tileSource.bingImageryRestUri = tileUri.replace('http:', 'https:');
} else {
tileSource.bingImageryRestUri = tileUri.replace('https:', 'http:');
}
map.backgroundContent = tileSource;
// optional - navigating to a map region
MapUtils.navigateTo(map, MapRegion.Caribbean);
}
createMap3(map: IgcGeographicMapComponent) {
map.zoomable = true;
const tileSource = new IgcBingMapsMapImagery();
tileSource.apiKey = MapUtils.getBingKey();
tileSource.imageryStyle = BingMapsImageryStyle.Road;
// resolving BingMaps uri based on HTTP protocol of hosting websitelet tileUri = tileSource.actualBingImageryRestUri;
let isHttpSecured = window.location.toString().startsWith('https:');
if (isHttpSecured) {
tileSource.bingImageryRestUri = tileUri.replace('http:', 'https:');
} else {
tileSource.bingImageryRestUri = tileUri.replace('https:', 'http:');
}
map.backgroundContent = tileSource;
// optional - navigating to a map region
MapUtils.navigateTo(map, MapRegion.Caribbean);
}
}
new MapDisplayImageryBingTiles();
ts
<!DOCTYPE html><html><head><title>MapDisplayImageryBingTiles</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container horizontal" ><igc-geographic-mapid="map1"class="container"height="100%"width="100%"></igc-geographic-map><igc-geographic-mapid="map2"class="container"height="100%"width="100%"></igc-geographic-map><igc-geographic-mapid="map3"class="container"height="100%"width="100%"></igc-geographic-map></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
このサンプルが気に入りましたか? 完全な Ignite UI for Web Componentsツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。