Skip to content

[FEATURE] Example for bing map usage? #1197

@xyzbilal

Description

@xyzbilal

Describe The Problem
Trying to implement bing maps in tile layer options but white screen only

Describe Your Solution

Provide an example for usage for it.

Alternatives/Workarounds

no workaround


Additional Information
I m trying to implement a map without titles, roads etc. bing maps gives me this opportunity but I m getting white screen instead

my FlutterMap implementation

 FutureBuilder(
        future: getBingUrlTemplate(
            'http://dev.virtualearth.net/REST/V1/Imagery/Metadata/RoadOnDemand?output=json&include=ImageryProviders&key=$bingMapKey'),
        builder: (context, snapshot) {
          if (snapshot.hasData) {
          String url = snapshot.data! as String;
          print(url);
          url = url.replaceAll("en-US", "tr-TR");
          url = url.replaceAll("it=G,L&shading=hill","it=A,G,RL&shading=t");
          print(url);
   
        return FlutterMap(
                  mapController: c.mapController,
                  options: MapOptions(
                      zoom: 11.0,
                      onTap: (tap, points) {
                        // my Logic
                      }),
                  layers: [
                    TileLayerOptions(
                      urlTemplate:snapshot.data as String,
                      attributionBuilder: (_) {
                        return SizedBox(); //Material(child:Text("© OpenStreetMap contributors"));
                      },
                    ),
                    PolygonLayerOptions(polygons:polies),


                  ],
                );
          }else{
            return SizedBox();
          }
          })

function to get link

Future<String?> getBingUrlTemplate(String url) async {
  final Response response = await GetConnect().get(url);
  assert(response.statusCode == 200, 'Invalid key');

  if (response.statusCode == 200) {
    final Map<String, dynamic> decodedJson = response.body ;
    late String imageUrl;
    late String imageUrlSubDomains;
    if (decodedJson['authenticationResultCode'] == 'ValidCredentials') {
      for (final String key in decodedJson.keys) {

  

        if (key == 'resourceSets') {
          // ignore: avoid_as
          final List<dynamic> resourceSets = decodedJson[key] as List<dynamic>;
          for (final dynamic key in resourceSets[0].keys) {
            if (key == 'resources') {
              final List<dynamic> resources =
                  // ignore: avoid_as
                  (resourceSets[0])[key] as List<dynamic>;
              final Map<String, dynamic> resourcesMap =
                  // ignore: avoid_as
                  resources[0] as Map<String, dynamic>;
              imageUrl = resourcesMap['imageUrl'].toString();
              final List<dynamic> subDomains =
                  // ignore: avoid_as
                  resourcesMap['imageUrlSubdomains'] as List<dynamic>;
              imageUrlSubDomains = subDomains[0].toString();
              break;
            }
          }
          break;
        }
      }

      final List<String> splitUrl = imageUrl.split('{subdomain}');
      return splitUrl[0] + imageUrlSubDomains + splitUrl[1];
    }
  }
  return null;
}

Applicable Platforms
Select platforms that this request applies to.

  • All/any
  • Android
  • iOS
  • Web
  • Windows
  • Others (beta platforms)

Metadata

Metadata

Labels

feature[DEPRECATED] This issue requests a new featureinvalidThis bug isn't reproducible, or the feature already exists

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions