page_type | description | languages | products | ||||
---|---|---|---|---|---|---|---|
sample |
An Azure Maps Web SDK module that takes a Mapbox style object and converts it into native Azure Maps classes and adds it to a map instance. |
|
|
An Azure Maps Web SDK module that takes a Mapbox style object and converts it into native Azure Maps classes and adds it to a map instance. Extracts Mapbox light, source, and layer styles, converts them to Azure Maps comparable values, and applies it to the map.
- Supported Sources: vector, raster, geojson, image
- Supported Layers: circle, fill, fill-extrusion, line, heatmap, raster, symbol
- Handles a combinations of Mapbox and Azure Maps style properties to be passed in.
Download the project and copy the azure-maps-mapbox-style-importer
JavaScript file from the dist
folder into your project.
Usage
//Initialize a map instance.
var map = new atlas.Map('myMap', {
//Add your auth options
});
//Wait until the map resources are ready.
map.events.add('ready', function () {
//Create an instance of the mapbox style importer.
var importer = atlas.MapboxStyleImporter(map);
//Import a single source.
//(id: string, data: string | GeoJSON object)
importer.addSource('my-source', {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'properties': {
'color': 'red'
},
'geometry': {
'type': 'Point',
'coordinates': [0, 0]
}
}
}
});
//Import a single later.
importer.addLayer({
'id': 'my-circle-layer',
'type': 'circle',
'source': 'my-source',
'paint': {
'circle-color': ['get', 'color']
}
});
//Import in a style that includes multiple sources and layers.
importer.addStyle({
sources: {
'my-source-1': {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [100, 0]
}
}
}
},
'my-source-2': {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [-100, 0]
}
}
}
}
},
layers: [{
'id': 'my-circle-layer-1',
'type': 'circle',
'source': 'my-source-1',
'paint': {
'circle-color': 'purple'
}
},
{
'id': 'my-circle-layer-2',
'type': 'circle',
'source': 'my-source-2',
'paint': {
'circle-color': 'blue'
}
}]
});
//Update the style options of a layer.
importer.addLayer('my-circle-layer', {
'paint': {
'circle-color': 'red'
}
});
});
Namespace: atlas
A class that converts Mapbox styles into native Azure Maps classes and imports them into an Azure Maps instance.
Contstructor
MapboxStyleImporter(map: atlas.Map)
Methods
Name | Return type | Description |
---|---|---|
addLayer(mapboxLayer: mapbox.Layer, beforeLayer?: string) |
atlas.layer.Layer |
Converts a Mapbox style layer to an Azure Map layer and adds it to a map. |
setLayerOptions(layer: string | atlas.layer.Layer, options: MapboxLayerOptions | atlas.BubbleLayerOptions | atlas.IconOptions | atlas.TextOptions | atlas.LayerOptions | atlas.HeatMapLayerOptions | atlas.LineLayerOptions | atlas.PolygonLayerOptions | atlas.PolygonExtrusionLayerOptions | atlas.SymbolLayerOptions | atlas.ImageLayerOptions | atlas.TileLayerOptions) |
Updates the style options of a layer. Note that this appends/ overwrites individual style options, and does not replace the whole style option unless all previously specified options are included in the new options. | |
addSource(id: string, mapboxSource: mapbox.Source) |
Converts a Mapbox style source to an Azure Map source and adds it to a map. | |
addStyle(mapboxStyle: mapbox.Style) |
Extracts Mapbox light, source, and layer styles, converts them to Azure Maps comparable values, and applies it to the map. |
Name | Type | Description |
---|---|---|
minzoom |
number |
Min zoom level of layer. |
maxzoom |
number |
Max zoom level of layer. |
filter |
any[] |
Layer filter. |
layout |
mapbox.AnyLayout |
Mapbox layout options. |
paint |
mapbox.AnyPaint |
Mapbox paint options. |
- Azure Maps Web SDK Open modules - A collection of open source modules that extend the Azure Maps Web SDK.
- Azure Maps Web SDK Samples
- Azure Maps Gov Cloud Web SDK Samples
- Azure Maps & Azure Active Directory Samples
- List of open-source Azure Maps projects
We welcome contributions. Feel free to submit code samples, file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our Contribution Rules & Guidelines.
You can reach out to us anytime with questions and suggestions using our communities below:
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
MIT
See License for full license text.