【问题标题】:Flutter adding tile layer to current layer颤振将平铺层添加到当前层
【发布时间】:2020-05-12 12:02:10
【问题描述】:

我正在开发一个显示滑雪道和缆车的应用。我可以单独获取这些地图:

对于底图(这是我的主图)

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';

class SkiMapSection extends StatelessWidget {
  const SkiMapSection({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: new FlutterMap(
        options: new MapOptions(
          center: LatLng(40.58, 31.78),
          minZoom: 10.0,
        ),
        layers: [
          TileLayerOptions(
            urlTemplate:
                "https://snowmap.fast-sfc.com/base_snow_map/{z}/{x}/{y}.png", 
            subdomains: ['a', 'b', 'c'],
          ),
        ],
      ),
    );
  }
}

对于滑雪道和升降机,我需要将 urlTemplate: 更改为 https://snowmap.fast-sfc.com/pistes/{z}/{x}/{y}.png

但我的目标是将电梯网址打印到底图上。我怎样才能做到这一点?颤振能做到吗?

干杯

【问题讨论】:

    标签: flutter mobile tile


    【解决方案1】:

    最后,通过将滑雪道层的背景颜色设置为透明,我可以同时显示它们。

    import 'package:flutter_map/flutter_map.dart';
    import 'package:latlong/latlong.dart';
    
    class SkiMapSection extends StatelessWidget {
      const SkiMapSection({Key key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Expanded(
          child: new FlutterMap(
            options: new MapOptions(
              center: LatLng(40.58, 31.78),
              minZoom: 10.0,
            ),
            layers: [
              TileLayerOptions(
                urlTemplate:
                    "https://snowmap.fast-sfc.com/base_snow_map/{z}/{x}/{y}.png",
                //change base_snow_map to pistes
                subdomains: ['a', 'b', 'c'],
              ),
              TileLayerOptions(
                  urlTemplate:
                      "https://snowmap.fast-sfc.com/pistes/{z}/{x}/{y}.png",
                  //change base_snow_map to pistes
                  subdomains: ['a', 'b', 'c'],
                  backgroundColor: Colors.transparent),
            ],
          ),
        );
      }
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-18
      • 2022-10-08
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多