SDKs overview
Bing Maps offers a suite of Software Development Kits (SDKs) and libraries designed to enable developers to integrate mapping and geospatial capabilities into various applications. These tools abstract the complexities of direct API interactions, providing pre-built components and functions for common mapping tasks such as displaying interactive maps, performing geocoding and reverse geocoding, calculating routes, and adding custom data layers. The official SDKs are tailored for web, mobile, and Universal Windows Platform (UWP) development, ensuring compatibility across Microsoft's primary development ecosystems and broader web standards.
The SDKs are structured to support a range of use cases, from simple map display to complex enterprise solutions requiring custom data visualization and spatial analysis. Developers can utilize these SDKs to access Bing Maps' extensive global coverage, high-resolution imagery, and traffic data. Microsoft maintains comprehensive documentation and examples for each SDK, facilitating integration into new and existing projects.
Official SDKs by language
Bing Maps provides official SDKs for several programming languages and platforms, catering to different development environments. These SDKs are maintained by Microsoft and offer direct access to Bing Maps functionalities, ensuring compatibility and optimal performance. The primary official SDKs include those for JavaScript, iOS, Android, and Windows UWP, each designed to leverage the native capabilities of its respective platform while providing consistent access to mapping features.
Official SDKs table
| Language/Platform | SDK Name | Primary Use | Maturity |
|---|---|---|---|
| JavaScript | Bing Maps V8 Web Control | Web applications, interactive maps | Stable |
| iOS (Swift/Objective-C) | Bing Maps SDK for iOS | Native iOS applications | Stable |
| Android (Java/Kotlin) | Bing Maps SDK for Android | Native Android applications | Stable |
| Windows UWP (C#/XAML) | Bing Maps SDK for UWP | Windows desktop and mobile apps | Stable |
Installation
Installation methods vary depending on the specific Bing Maps SDK and target platform. Each SDK follows standard practices for package management and project integration within its respective ecosystem.
JavaScript (Bing Maps V8 Web Control)
The Bing Maps V8 Web Control is integrated directly into web pages using a script tag. No separate package installation is typically required. The map loads asynchronously from Microsoft's content delivery network (CDN).
<script type='text/javascript' async defer
src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=YOUR_BING_MAPS_KEY'>
</script>
Replace YOUR_BING_MAPS_KEY with your actual Bing Maps API key, which can be obtained from the Bing Maps Dev Center.
iOS (Bing Maps SDK for iOS)
The Bing Maps SDK for iOS can be integrated using CocoaPods, a dependency manager for Swift and Objective-C Cocoa projects. This method simplifies the process of adding and managing the SDK within an Xcode project.
Using CocoaPods:
- Ensure CocoaPods is installed. If not, install it via Terminal:
sudo gem install cocoapods. - Navigate to your Xcode project directory in Terminal.
- Initialize CocoaPods:
pod init. This creates aPodfile. - Edit the
Podfileto add the Bing Maps SDK dependency:
target 'YourProjectName' do
use_frameworks!
pod 'BingMapsSDK'
end
- Install the SDK:
pod install. - Open the
.xcworkspacefile (not.xcodeproj) in Xcode to continue development.
Refer to the Bing Maps SDK for iOS getting started guide for detailed instructions.
Android (Bing Maps SDK for Android)
The Bing Maps SDK for Android is typically integrated into Android Studio projects by adding dependencies to the project's build.gradle file.
Using Gradle:
- Open your Android project in Android Studio.
- In your module-level
build.gradlefile (usuallyapp/build.gradle), add the Bing Maps SDK dependency within thedependenciesblock:
dependencies {
implementation 'com.microsoft.bing.maps:bingmaps-sdk:1.0.0'
}
Note: Check the Bing Maps SDK for Android documentation for the latest version number.
- Sync your project with Gradle files.
- Add your Bing Maps API key to your
AndroidManifest.xmlor programmatically.
Windows UWP (Bing Maps SDK for UWP)
For Universal Windows Platform (UWP) applications, the Bing Maps SDK is integrated via NuGet Package Manager in Visual Studio.
- Open your UWP project in Visual Studio.
- Right-click on your project in Solution Explorer and select "Manage NuGet Packages...".
- Search for
Microsoft.Bing.Maps.MapControl.UWP. - Select the package and click "Install".
Further configuration, including adding the map control to your XAML and setting the API key, is detailed in the Bing Maps SDK for UWP documentation.
Quickstart example
This quickstart demonstrates how to display a basic map using the Bing Maps V8 Web Control (JavaScript SDK).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bing Maps Quickstart</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#myMap {
position: relative;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="myMap"></div>
<script type='text/javascript'>
var map;
function GetMap() {
map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'YOUR_BING_MAPS_KEY',
center: new Microsoft.Maps.Location(47.6062, -122.3321), // Seattle, WA
zoom: 12
});
}
</script>
<script type='text/javascript' async defer
src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=YOUR_BING_MAPS_KEY'>
</script>
</body>
</html>
In this example:
- The
<div id="myMap"></div>element serves as the container for the map. - The Bing Maps V8 Web Control is loaded asynchronously via a
<script>tag, specifyingcallback=GetMapto execute theGetMapfunction once the API is loaded. - The
GetMapfunction initializes a newMicrosoft.Maps.Mapobject, passing the map container, your API key (credentials), and initial map options likecenterandzoomlevel. - Remember to replace
'YOUR_BING_MAPS_KEY'with your actual Bing Maps API key.
Community libraries
While Microsoft provides official SDKs, the broader developer community has also contributed libraries and wrappers to extend Bing Maps functionality or simplify its integration in specific contexts. These community-driven projects can offer alternative approaches, support for less common frameworks, or specialized tools not covered by the official SDKs.
For example, projects exist that provide Bing Maps integration for popular JavaScript frameworks or backend languages. Developers often create these to address specific project requirements, integrate with existing toolchains, or offer different paradigms for interacting with the Bing Maps REST Services. It's important to note that community libraries may not always receive the same level of support or updates as official SDKs and their compatibility with the latest Bing Maps API versions should be verified.
One common use case for community libraries involves integrating Bing Maps with server-side applications for tasks like geocoding or routing without a direct client-side map display. For instance, a developer might use a Python library to call the Bing Maps REST Locations API to process addresses in batch. While no single prominent, universally adopted community library dominates for Bing Maps in the same way some other mapping platforms might have, developers frequently share code snippets and smaller utility libraries on platforms like GitHub to assist with specific tasks or framework integrations. Searching for "Bing Maps" on code repositories typically yields various examples and helper functions.
When considering community-contributed code, developers should evaluate the project's activity, maintenance status, and licensing. Resources such as the Mozilla Developer Network's guide to JavaScript or similar language-specific resources can provide context for evaluating such libraries.