Search code examples
androidosmdroidbing-maps

initMetaData(this) Error with Bing Satellite View in OSMDroid


I want to display Satellite Tiles from Bing in OSMDroid and have 'osmdroid-third-party-4.3.jar' installed.

The following code is posted over the web to display the Satellite Tiles, but I get always the Error:

'The method initMetaData() in the type BingMapTileSource is not applicable for the arguments' !

/* BING SATELLITE VIEW */
        try{
            BingMapTileSource.initMetaData(this);
          String m_locale =   Locale.getDefault().getDisplayName();
          BingMapTileSource bing = new BingMapTileSource(m_locale);
          bing.setStyle(BingMapTileSource.IMAGERYSET_AERIAL);
          mapView.setTileSource(bing);
        }
        catch(Exception e){
          e.printStackTrace();
        }

Without the Argument 'this' I get the Error:

'The method initMetaData() from the type BingMapTileSource is not visible'

Any Ideas?


Solution

  • First answer wrong.

    updated 22.07.2015

    How to add Bing maps to osmdroid

    Here are step by step instructions. Perhaps someone this will save a lot of time.

    1.Add dependency to gradle

    compile 'org.slf4j:slf4j-android:1.6.1-RC1'
    compile 'org.osmdroid:osmdroid-android:4.3'
    

    2.add library osmdroid-third-party from here

    OR

    add three classes in our project (BingMapTileSource.java, ImageryMetaData.java, ImageryMetaDataResource.java). from here

    3.Getting a Bing Maps Key. Instructions here

    4.Add the Bing Maps Key to the manifest.

    <meta-data android:name="BING_KEY" android:value="ApEqyap8rTa4WTNCNv-3pAGQc7XUsHS6595tuDI3MHR59QlahJ5bqYGYhMYJq6Ae" />
    

    5.The last step. Add map code

            ResourceProxyImpl mResourceProxy = new ResourceProxyImpl(getContext().getApplicationContext());
            MapView mMapView = new MapView(getContext(), 256, mResourceProxy);
            mMapView.setBuiltInZoomControls(true);
            mMapView.setMultiTouchControls(true);
    
            try{
                BingMapTileSource.retrieveBingKey(getContext());
                String m_locale =   Locale.getDefault().getDisplayName();
                BingMapTileSource bing = new BingMapTileSource(m_locale);
                bing.setStyle(BingMapTileSource.IMAGERYSET_AERIAL);
                mMapView.setTileSource(bing);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            mapContent.addView(mMapView);