When Google introduced a requirement for an API key before a map could be embedded into a page, it introduced a measure of complexity that simply stopped many from using the service. In this article we'll provide you with the Bing API-key-free alternative. A simple shortcode will return a Bing Map into your WordPress post or page with shortcode.
The Bing alternative isn't as feature rich as the Google alternative, and sadly, it doesn't support a marker unless the map is rendered programmatically.
The shortcode of
[bm_bing_map latitude="-33.85703468676193" longitude="151.1931205078125"] returns the following:
You may return an aerial view (and include or exclude labels), or alter the level (or scale). As you can tell from the above, the map doesn't support address geocoding out-of-the-box. Instead, you'll have to use a latitude and longitude. You may obtain these details from the Bing Embed page, or via a Google Map URL.
If you required reverse geocoding you should add a few lines into the code to obtain and cache the coordinates; there are plenty of services to choose from, including Google and Bing (although if you had a Google API Key you would be better served by using the Google Map embed code).
Pictured: You may also copy the latitude and longitude directly from a Bing map.. Despite the lack of reverse geocoding, the latitude and longitude does provide a consistent and accurate result.
To return an aerial view of Sydney's GPO we'd use the shortcode of
[bm_bing_map latitude="-33.85703468676193" longitude="151.1931205078125" aerial="1"]. By default the labels are shown but you may exclude them with
labels="0". In this example we'll also zoom out and show a smaller scale map with
level="14" (the shortcode defaults to a level of 17). The result:
The margin above and below the map iframe may be altered with
The Shortcode Function
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
A small number of shortcode attributes apply.
latitude and longitude
longitudeof the reference point. Obtain via Google Maps or Bing Maps.
width and height
heightof the map.
aerialis the 'satellite-style' aerial photograph, rather than a map. If an aerial photograph is returned the
labeloption is made available.
marginalters the margin above and below the map. Defaults to 30px.
We're considering including a feature-rich map feature into our Elementor plugin, but we'll get some feedback from users before we push ahead. If we did build the simple feature we'd certainly include a reverse geocoding function so the latitude and longitude wouldn't be required... but this would likely require we build it to utilise Google's service (thus requiring a Google API Key). If clients have a specific need, please let us know.