Dela via


Configuration Driven Maps framework

Note

Bing Maps Web Control SDK retirement

Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

Configuration driven maps allow you to quickly and easily create a map with your data with little to no coding required. Instead create a JSON configuration fill that specifies the data sets you want to render along with some map options and then easily generate a map from this. Besides providing a minimal coding option for creating map apps, configuration driven maps are great for creating reusable map apps which are data driven. Take for example SharePoint, every user has different permissions and access to different data sets. This can easily be programmatically defined as a configuration file which can then be used to provide all users with a similar map application, but with only the data sets they have access to.

Map configuration files can be loaded in one of two ways:

Configuration file format

A map configuration file defines the options to use when loading the map as well as the modules and datasets to load. The root JSON object is a ConfigurableMapOptions object. Here is an example JSON configuration file which loads the map at a specified location and zoom, with three data layers which are loaded via the GeoXml module.

{
  "mapOptions": {
    "credentials": "YOUR_BING_MAPS_KEY",
    "center": "47.606209,-122.332071",
    "zoom": 4
  },
  "modules": [
    {
      "moduleName": "Microsoft.Maps.GeoXml",
      "moduleOptions": [
        {
          "addLayerFromUrl": "https://bingmapsisdk.blob.core.windows.net/isdksamples/Countries.xml"
        },
        {
          "addLayerFromUrl": "https://github.com/microsoft/BingMapsV8CodeSamples/blob/main/Static/data/kml/SampleKml.kml"
        },
        {
          "addLayerFromUrl": "https://earthquake.usgs.gov/fdsnws/event/1/query?minmagnitude=3&format=geojson",
          "geoXmlOption": {
            "layerName": "geoxml layer loading geojson data"
          }
        }
      ]
    }
  ]
}

A version of this file is hosted by the Bing Maps team here:

https://bingmapsisdk.blob.core.windows.net/isdksamples/configmap2.json

This can be loaded using the ConfigurableMap class in a web app, or into the Bing Maps configurable maps page using the following URL:

https://www.bing.com/maps/configurable?config=https%3A%2F%2Fbingmapsisdk.blob.core.windows.net%2Fisdksamples%2Fconfigmap2.json

Here is a screenshot of the map that is rendered when loading this configuration file.

BMV8_ConfigMap

Try it now

Examples