Angular Geographic Symbol Map
In Angular map component, you can use the IgxGeographicSymbolSeriesComponent
to display geo-spatial data using points or markers in a geographic context. This type of geographic series is often used to render a collection of geographic locations such as cities, airports, earthquakes, or points of interests.
Angular Geographic Symbol Map Example
Data Requirements
Similarly to other types of geographic series in the map component, the IgxGeographicSymbolSeriesComponent
has the ItemsSource
property which can be bound to an array of objects. In addition, each data item in this object must have two numeric data columns that store a geographic location (longitude and latitude). These data columns are then mapped to the latitudeMemberPath
and longitudeMemberPath
properties. The IgxGeographicSymbolSeriesComponent
uses values of these mapped data columns to plot symbol elements in the geographic map component.
Code Snippet
The following code shows how to bind the IgxGeographicSymbolSeriesComponent
to locations of cities loaded from a shape file using the IgxShapeDataSource
.
<div className="sampleRoot" >
<igx-geographic-map #map
width="700px"
height="500px"
zoomable="true" >
</igx-geographic-map>
</div>
<ng-template let-series="series" let-item="item" #template>
<div>
<div *ngIf="item.org;then hasOrg; else notOrg" ></div>
<span [style.color]="series.brush">
{{item.name}}
</span>
<br/>
<span>
Population {{item.pop}} M
</span>
</div>
<ng-template #hasOrg>
<span>
Population {{item.pop}} M
</span>
<br />
</ng-template>
<ng-template #notOrg>
<span>
</span>
</ng-template>
</ng-template>
import { AfterViewInit, Component, TemplateRef, ViewChild } from "@angular/core";
import { MarkerType } from 'igniteui-angular-charts';
import { IgxGeographicMapComponent } from 'igniteui-angular-maps';
import { IgxGeographicSymbolSeriesComponent } from "igniteui-angular-maps";
import { WorldLocations } from "../../utilities/WorldLocations";
@Component({
selector: "app-map-geographic-scatter-symbol-series",
styleUrls: ["./map-geographic-scatter-symbol-series.component.scss"],
templateUrl: "./map-geographic-scatter-symbol-series.component.html"
})
export class MapTypeScatterSymbolSeriesComponent implements AfterViewInit {
@ViewChild ("map")
public map: IgxGeographicMapComponent;
@ViewChild("template")
public tooltip: TemplateRef<object>;
constructor() {
}
public ngAfterViewInit(): void {
this.addSeriesWith(WorldLocations.getCities(), "Gray");
this.addSeriesWith(WorldLocations.getCapitals(), "rgb(32, 146, 252)");
}
public addSeriesWith(locations: any[], brush: string) {
const symbolSeries = new IgxGeographicSymbolSeriesComponent ();
symbolSeries.dataSource = locations;
symbolSeries.markerType = MarkerType.Circle;
symbolSeries.latitudeMemberPath = "lat";
symbolSeries.longitudeMemberPath = "lon";
symbolSeries.markerBrush = "White";
symbolSeries.markerOutline = brush;
symbolSeries.tooltipTemplate = this.tooltip;
this.map.series.add(symbolSeries);
}
}
API References
IgxGeographicSymbolSeriesComponent
ItemsSource
latitudeMemberPath
longitudeMemberPath
IgxShapeDataSource