Bing Maps is a online Maps provider, owned by Microsoft. As like OSM, it provide Maps tile images based on our requests and combines those images into a single one to display Maps area.
The Bing Maps can be rendered using the urlTemplate property, which is based on the URL generated by the getBingUrlTemplate method in the Maps. The format of the required URL of Bing Maps varies from other online map providers. As a result, a built-in getBingUrlTemplate method has been included that returns the URL in a generic format. In the meantime, a subscription key is required for Bing Maps. The Bing Maps key can be obtained from here, then append it to the Bing Maps URL before passing it to the getBingUrlTemplate method. The URL returned by this method must be passed to the urlTemplate property.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
layers:[{
}]
});
map.appendTo('container');
Bing Maps provides different types of Maps and it is supported in the Maps control.
To render the light version of the road Maps, set the CanvasLight value is passed via the URL into the getBingUrlTemplate method demonstrated in the following code sample.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/CanvasLight?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
zoomSettings: {
zoomFactor: 12,
},
centerPosition : {
latitude: 38.8951,
longitude: -77.0364
},
layers:[{
}]
});
map.appendTo('container');
Bing Maps layer can be zoomed and panned. Zooming helps to get a closer look at a particular area on a Maps for in-depth analysis. Panning helps to move a Maps around to focus the targeted area.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
zoomSettings: {
enable: true,
toolBars: [{ "Zoom", "ZoomIn", "ZoomOut", "Pan", "Reset" }]
},
layers: [{
}]
});
map.appendTo('container');
Markers can be added to the layers of Bing Maps by setting the corresponding location’s coordinates of latitude and longitude using markerSettings. Navigation lines can be added on top of an Bing Maps layer for highlighting a path among various places by setting the corresponding location’s coordinates of latitude and longitude in the navigationLineSettings.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
zoomSettings: {
zoomFactor: 4
},
centerPosition: {
latitude: 29.394708
logitude: -94.954653
},
layers: [{
markerSettings: [{
visible: true,
height: 25,
width: 15,
dataSouce: [{
latitude: 34.060620,
longitude: -118.330491,
name: "California"
},
{
latitude: 40.724546,
longitude: -73.850344,
name: "New York"
}],
}],
navigationLineSettings: [{
visible: true,
color: "blue",
angle: 0.1,
latitude: {
34.060620, 40.724546
},
longitude: {
-118.330491, -73.850344
}
}]
}]
});
map.appendTo('container');
Any GeoJSON shape can be rendered as a sublayer on top of the Bing Maps layer for highlighting a particular continent or country in Bing Maps by adding another layer and specifying the type property of Maps layer to SubLayer.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
layers: [
{
// Add Bing Map.
},
{
shapeData: Africa_Continent,
type: 'SubLayer',
shapeSettings: {
fill: "blue"
}
}
]
});
map.appendTo('container');
The legend can be added to the tile Maps by setting the visible property of legendSettings to true.
var map = new ej.maps.Maps({
load: function(args){
args.maps.getBingUrlTemplate("https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial?output=json&uriScheme=https&key=?").then(function(url) {
args.maps.layers[0].urlTemplate= url;
});
},
legendSettings: {
visible: true,
type: 'Markers',
useMarkerShape:true,
toggleLegendSettings: {
enable: true,
applyShapeSettings: false,
border: {
color: 'green',
width: 2
}
}
},
layers: [
{
shapeDataPath: 'name',
shapePropertyPath: 'name',
shapeSettings: {
fill: '#E5E5E5'
},
markerSettings: [
{
dataSource: markerDataSource,
colorValuePath: 'color',
shapeValuePath:'shape',
legendText: 'country',
visible: true
}
]
}
]
});
map.appendTo('#element');