Introducing the Bing Maps API
Oct 7 |
In this article, I will briefly discuss the benefits of using Bing Maps and how to get up and running using the Bing Maps API.
Table of Contents
Why use the Bing Maps API?
Bing Maps has been around since 2005. Today, Bing Maps offers a bird's-eye view, satellite imaging, real-time traffic and directions. While Google Maps is the undisputed mapping leader, Bing Maps has some advantages. Google has better in-depth coverage, but Bing Maps often offers superior aerial and 3D imagery. Most developers find Bings API to be more intuitive, and easier to implement custom mapping solutions. Additionally, Bing Maps is more generous and straightforward with its free tier pricing. For the casual or low to medium-volume blogger who is looking for a low-cost mapping API, I believe that Bing Maps is the better choice and hope to show you how you can use Bing Maps in your blog in the next several articles.
Bing Maps vs. Google Maps Cost Analysis
On paper alone, it seems like Google Maps is more generous with its free tier. For example, Bing Maps offers 125k map loads per year and Google Maps offers 28,500 map loads a month for a free developer license. However, what constitutes a 'mapload' is quite different between the two providers.
Google considers an autosuggest returned from its API a map load, and Google charges more for a dynamic map, where the user can pan and zoom than it does for a static map that does not allow for user interaction. Google's pricing is rather complex and can quickly add up when creating sophisticated mapping applications.
Bing Maps pricing is more straightforward, and unlike Google Maps- you don't need to provide a credit card when signing up for a Bing Maps Developer Key.
Get a Free Bing Maps Key
To get a Bing Maps API Key, go to https://docs.microsoft.com/en-us/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-maps-key, and follow the directions. Unless you plan on having unusually busy traffic, you should not have to pay for an enterprise plan. I have used Bing Maps on my sites for a couple of years, and although I don't have high-volume sites- I have come nowhere near the 130k map-view limit per year threshold for the free tier.
Outputting a Basic Dynamic Map Using the Bing Maps API
The following code will display a map of the San Juan Islands in Washington State. As you can see, generating dynamic maps on a webpage with the Bing Maps API is quite simple. Click on the button below to explore an interactive map that this code generates. I will delve into the details of a dynamic static map in the next article.
<script type='text/javascript'>
function getSanJuans() {
// Create a location. This takes the latitude and longitude, separated by a comma
var fridayHarbor = new Microsoft.Maps.Location(48.5348,-123.016);
// Map declaration
var sanJuans = new Microsoft.Maps.Map(document.getElementById('sanJuans'), {
// Center our map
center: fridayHarbor,
// Use an aerial image
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
// Zoom out a little bit to get all of the islands
zoom: 11
});
}
</script>
<!-- Map control -->
<script type='text/javascript' src='https://sdk.virtualearth.net/api/maps/mapcontrol?key=yourBingMapKey&callback=getSanJuans' async defer></script>
<div id="sanJuans" style="width:100%;height:100%"></div>
Related Entries
Tags
Bing MapsThis entry was posted on October 7, 2023 at 12:53 AM and has received 1026 views.