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 GXY view requires the same two steps as the majority of the formats:

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

// 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 an async layer for it
ILcdGXYLayer layer = new TLcdBingMapsGXYLayerFactory().createGXYLayer(model);
layer = ILcdGXYAsynchronousLayerWrapper.create(layer);

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

//The BingMaps license agreement requires to display the icon and copyright information on the map
TLcdBingMapsLogoIcon logoIcon = new TLcdBingMapsLogoIcon(view);
overlayPanel.add(logoIcon.asComponent(), TLcdOverlayLayout.Location.SOUTH_WEST);

TLcdBingMapsGXYCopyrightIcon copyrightIcon = new TLcdBingMapsGXYCopyrightIcon(view);
copyrightIcon.setAlignment(ELcdHorizontalAlignment.RIGHT);
overlayPanel.add(copyrightIcon.asComponent(), TLcdOverlayLayout.Location.SOUTH_WEST);

This results in a Bing Maps layer with default styling.

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.