Apart from the OpenStreetMap and Bing Maps, you can also render the maps from other map service provided by specifying layerType
as OSM
and the URL generated by map provider in the URLTemplate
property. Here, Google maps is rendered. This provides customizable maps with your own content and imagery.
Refer to Google maps licensing.
//tslint:disable
import { world_map } from 'world-map.ts';
import { usa_map } from 'usa.ts'
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(
<MapsComponent id="maps">
<LayersDirective>
<LayerDirective layerType='OSM'
urlTemplate= "http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level" />
</LayersDirective>
</MapsComponent>,
document.getElementById("maps") as HTMLElement
);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(<MapsComponent id="maps">
<LayersDirective>
<LayerDirective layerType='OSM' urlTemplate="http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level"/>
</LayersDirective>
</MapsComponent>, document.getElementById("maps"));
You can zoom and pan the Google maps layer. Zooming helps you get a closer look at a particular area on a map for in-depth analysis. Panning helps you to move a map around to focus the targeted area.
//tslint:disable
import { world_map } from 'world-map.ts';
import { usa_map } from 'usa.ts'
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(
<MapsComponent id="maps" zoomSettings= {{enable: true}}>
<LayersDirective>
<LayerDirective layerType='OSM'
urlTemplate= "http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level" />
</LayersDirective>
</MapsComponent>,
document.getElementById("maps") as HTMLElement
);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(<MapsComponent id="maps" zoomSettings={{ enable: true }}>
<LayersDirective>
<LayerDirective layerType='OSM' urlTemplate="http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level"/>
</LayersDirective>
</MapsComponent>, document.getElementById("maps"));
Markers can be added to the layers of Google maps by setting the corresponding location’s coordinates of latitude and longitude using markerSettings
property. You can add navigation lines on top of an Google maps layer for highlighting a path among various places by setting the corresponding location’s coordinates of latitude and longitude in the navigationLineSettings
property.
//tslint:disable
import { world_map } from 'world-map.ts';
import { usa_map } from 'usa.ts'
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, Zoom, MarkersDirective, NavigationLine, NavigationLinesDirective, NavigationLineDirective, MarkerDirective, Marker, Inject } from '@syncfusion/ej2-react-maps';
ReactDOM.render(
<MapsComponent id="maps" zoomSettings= {{ zoomFactor: 4}}
centerPostion = {{
latitude: 29.394708,
longitude: -94.954653
}}>
<LayersDirective>
<LayerDirective layerType='OSM'
urlTemplate= "http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level">
<MarkerDirective visible={true}
height={25}
width={15}
dataSource={[
{
latitude: 34.060620,
longitude: -118.330491,
name: "California"
},
{
latitude: 40.724546,
longitude: -73.850344,
name: "New York"
}
]}
>
</MarkerDirective>
<NavigationLinesDirective>
<NavigationLineDirective visible={true}
latitude={[34.060620, 40.724546]}
longitude={[-118.330491,-73.850344]}
color="blue"
angle={90}
width={5} />
</NavigationLinesDirective>
</LayerDirective>
</LayersDirective>
</MapsComponent>,
document.getElementById("maps") as HTMLElement
);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, NavigationLinesDirective, NavigationLineDirective, MarkerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(<MapsComponent id="maps" zoomSettings={{ zoomFactor: 4 }} centerPostion={{
latitude: 29.394708,
longitude: -94.954653
}}>
<LayersDirective>
<LayerDirective layerType='OSM' urlTemplate="http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level">
<MarkerDirective visible={true} height={25} width={15} dataSource={[
{
latitude: 34.060620,
longitude: -118.330491,
name: "California"
},
{
latitude: 40.724546,
longitude: -73.850344,
name: "New York"
}
]}>
</MarkerDirective>
<NavigationLinesDirective>
<NavigationLineDirective visible={true} latitude={[34.060620, 40.724546]} longitude={[-118.330491, -73.850344]} color="blue" angle={90} width={5}/>
</NavigationLinesDirective>
</LayerDirective>
</LayersDirective>
</MapsComponent>, document.getElementById("maps"));
You can render any GeoJSON shape as a sublayer on top of an Google maps layer for highlighting a particular continent or country in Google maps by adding another layer and specifying the type to SubLayer.
//tslint:disable
import { world_map } from 'world-map.ts';
import { usa_map } from 'usa.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(
<MapsComponent id="maps">
<LayersDirective>
<LayerDirective layerType='OSM'
urlTemplate= "http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level" />
<LayerDirective shapeData= {usa_map}
type= 'SubLayer'
shapeSettings = {{
fill: 'blue'
}}>
</LayerDirective>
</LayersDirective>
</MapsComponent>,
document.getElementById("maps") as HTMLElement
);
import { usa_map } from 'usa.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective } from '@syncfusion/ej2-react-maps';
ReactDOM.render(<MapsComponent id="maps">
<LayersDirective>
<LayerDirective layerType='OSM' urlTemplate="http://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level"/>
<LayerDirective shapeData={usa_map} type='SubLayer' shapeSettings={{
fill: 'blue'
}}>
</LayerDirective>
</LayersDirective>
</MapsComponent>, document.getElementById("maps"));