Obtaining a Bing Maps keys

The first thing you need before connecting to the Bing Maps servers is a Bing Maps developer key. The Bing Maps portal (http://www.bingmapsportal.com) allows you to create a Bing Maps account and one or more Bing Maps keys.

To request a Bing Maps developer key from Microsoft:

  1. Go to http://www.bingmapsportal.com.

  2. Sign in with your Windows Live ID, or create one.

  3. In the "My Keys" section, create a new key.

    • For the key type, select "Basic".

    • For the application type, select "Dev/Test".

Note that additional terms may apply for deployment. For more information on Bing Maps licensing, see the Licensing info guide.

Visualizing the data on the map

Visualizing Bing Maps data on a Lightspeed view requires the same two steps as the majority of the formats:

// Create the bing maps data source to specify what kind of data we want
TLcdBingMapsDataSource dataSource =
    new TLcdBingMapsDataSourceBuilder(applicationID)
        .mapStyle(ELcdBingMapsMapStyle.AERIAL_WITH_LABELS)
        .build();

//Decode the data source into a model
ILcdModelDecoder decoder = new TLcdCompositeModelDecoder(
    TLcdServiceLoader.getInstance(ILcdModelDecoder.class)
);
ILcdModel model = decoder.decodeSource(dataSource);

//Create a layer for it
TLspBingMapsLayerFactory layerFactory = new TLspBingMapsLayerFactory();
ILspLayer layer = layerFactory.createLayers(model).iterator().next();

//Add the layer to the view
view.addLayer(layer);

An additional step compared to other formats is that Bing Maps terms of use from Microsoft require to show copyright information on the map.

  • For AWT/Swing views

//The Bing Maps terms of use require to display the icon and copyright information on the map
//Here we add them to the overlay component of an ILspAWTView
TLcdBingMapsLogoIcon logoIcon = new TLcdBingMapsLogoIcon(view);
view.getOverlayComponent().add(logoIcon.asComponent(), TLcdOverlayLayout.Location.NORTH_WEST);

TLspBingMapsCopyrightIcon copyrightIcon = new TLspBingMapsCopyrightIcon(view);
copyrightIcon.setAlignment(ELcdHorizontalAlignment.RIGHT);
view.getOverlayComponent().add(copyrightIcon.asComponent(), TLcdOverlayLayout.Location.NORTH_WEST);
  • For JavaFX views

TLcdBingMapsLogoIcon logoIcon = new TLcdBingMapsLogoIcon(view);
Node logoNode = new TLcdFXIcon(logoIcon);

TLspBingMapsCopyrightIcon copyrightIcon = new TLspBingMapsCopyrightIcon(view);
Node copyrightNode = new TLcdFXIcon(copyrightIcon);

FXUtil.findOverlayPane(view).ifPresent(overlayPane -> {
  HBox box = new HBox(logoNode, copyrightNode);
  overlayPane.add(box, TLcdOverlayPane.Location.SOUTH_WEST);
});

This results in a Bing Maps layer with default styling. See Visualizing Raster Data for more information about visualizing and styling raster data.

This code snippet uses the TLcdCompositeModelDecoder initialized with all available model decoders in the service registry.

The actual model decoder class responsible for decoding Bing Maps data sources is the TLcdBingMapsModelDecoder.