Angular オープン ストリート マップ画像の表示
Angular IgxOpenStreetMapImagery
は、世界中の OpenStreetMap© のコントリビューターが共同で作成した無料の地理的画像マッピングサービスです。これは、構成オプションなしで、道路地図スタイル限定で世界の地理的画像を提供します。この地理的画像サービスは、www.OpenStreetMap.org に直接アクセスして利用できます。
デフォルトでは、Ignite UI for Angular マップ コンポーネントには、Open Street Maps の地理的画像が既に表示されています。したがって、Open Street Maps から地理的画像を表示するように、コントロールを構成する必要はありません。
Angular オープン ストリート マップ画像の表示の例
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { CommonModule } from "@angular/common";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { IgxGeographicMapModule } from "igniteui-angular-maps";
import { IgxDataChartInteractivityModule } from "igniteui-angular-charts";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxGeographicMapModule,
IgxDataChartInteractivityModule
],
providers: [],
schemas: []
})
export class AppModule {}
ts
import { AfterViewInit, Component, ViewChild } from "@angular/core";
import { IgxGeographicMapComponent } from "igniteui-angular-maps";
import { IgxOpenStreetMapImagery } from "igniteui-angular-maps";
@Component({
standalone: false,
selector: "app-root",
styleUrls: ["./app.component.scss"],
templateUrl: "./app.component.html"
})
export class AppComponent implements AfterViewInit {
@ViewChild("map", { static: true })
public map: IgxGeographicMapComponent;
constructor() {
}
public ngAfterViewInit(): void {
const tileSource = new IgxOpenStreetMapImagery();
this.map.backgroundContent = tileSource;
this.map.updateZoomWindow({ left: 0.2, top: 0.1, width: 0.7, height: 0.7});
}
}
ts
<div class="container vertical">
<igx-geographic-map #map
width="100%"
height="100%"
zoomable="true" >
</igx-geographic-map>
</div>
html
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
コード スニペット
このコード例では、マップ コンポーネントの BackgroundContent
を OpenStreetMap© コントリビューターの地理画像を提供する IgxOpenStreetMapImagery
オブジェクトに明示的に設定します。
<igx-geographic-map #map
width="100%"
height="100%"
zoomable="true" >
</igx-geographic-map>
html
import { IgxGeographicMapComponent } from 'igniteui-angular-maps';
import { IgxOpenStreetMapImagery } from 'igniteui-angular-maps';
public map: IgxGeographicMapComponent;
const tileSource = new IgxOpenStreetMapImagery();
this.map.backgroundContent = tileSource;
ts
API リファレンス