小编ben*_*ter的帖子

如何从geoJson源Mapbox获取所有功能

我已将 geoJson 源加载到我的 mapView 中。我的 .net 中有一个搜索栏activity。所以我的计划是,我想使用添加到地图的源searchBar中的要素类型来填充我的建议。geoJson我想从onMapStyleLoaded方法中做到这一点。

那么,有没有一种方法可以获取所有geoJson属性(例如“名称”)的详细信息,并将所有属性添加到arrayList加载地图时?

@Override
    public void onMapReady(@NonNull final MapboxMap mapboxMap) {
        SearchActivity.this.mapboxMap = mapboxMap;
        mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
            mapboxMap.addOnMapClickListener(SearchActivity.this);
            addGeoJsonSourceToMap(style);
// Create FillLayer with GeoJSON source and add the FillLayer to the map
            style.addLayer(new FillLayer(geoJsonLayerId, geoJsonSourceId)
                    .withProperties(fillOpacity(0.5f)));
                    GeoJsonSource source = style.getSourceAs(geoJsonSourceId);
                    if (source != null){
                        List<Feature> features = source.querySourceFeatures(Expression.get("name"));
                        //I want to all the features of my geoJson source so I can pass …
Run Code Online (Sandbox Code Playgroud)

android mapbox-android

6
推荐指数
0
解决办法
423
查看次数

使用共享首选项列表颤动保存和检索通知

我已经Firebase Cloud Messaging在我的扑动应用程序中实现了。一切正常,但我想将所有消息列表存储在本地shared preferences并在另一个屏幕中检索它们。onMessage 我的所有逻辑都不能很好地工作,因为调用函数时我无法保存消息。

推送通知服务

class PushNotificationService {
  final FirebaseMessaging _fcm = FirebaseMessaging();
  List<String> titles;
  List<String> msgs;
  Future initialise() async {
    notiList = List<NotiMessage>();
    if (Platform.isIOS) {
      // request permissions if we're on android
      _fcm.requestNotificationPermissions(IosNotificationSettings());
      _fcm.configure();
      // For testing purposes print the Firebase Messaging token
      String token = await _fcm.getToken();
      print("FirebaseMessaging token: $token");
    } else{
      String token = await _fcm.getToken();
      print("FirebaseMessaging token: $token");
    }

    _fcm.configure(
      // Called when the app is in the foreground …
Run Code Online (Sandbox Code Playgroud)

sharedpreferences dart flutter

5
推荐指数
1
解决办法
2721
查看次数

如何使 ChipGroup 发挥像 radioGroup 的作用?

如何使 a 的ChipGroup行为类似于radioButton在更改背景颜色时一次可以选择一个项目。

图片截图

我看到了类似这样的链接,但它对我没有帮助,因为我使用 alayoutInflater来显示我的芯片项目。

firebaseFirestore.collection("Categories").addSnapshotListener((queryDocumentSnapshots, e) -> {
            for (DocumentChange doc: queryDocumentSnapshots.getDocumentChanges()){
                if (doc.getType() == DocumentChange.Type.ADDED){
                    Categories categories = doc.getDocument().toObject(Categories.class);
                    post_list.add(categories);
                    Chip chip = (Chip) getLayoutInflater().inflate(R.layout.chip_item_layout, chipGroup, false);
                    chip.setText(categories.getTitle());
                    chipGroup.addView(chip);
                    chipGroup.setOnCheckedChangeListener((chipGroup, id) -> {
                        Chip chip2 = ((Chip) chipGroup.getChildAt(chipGroup.getCheckedChipId()));
                        if (chip2 != null) {
                            for (int i = 0; i < chipGroup.getChildCount(); ++i) {
                                chipGroup.getChildAt(i).setClickable(true);
                                chip2.setChipBackgroundColorResource(R.color.customOrange);
                            }
                            chip2.setClickable(false);
                        }
                    });

                }
            }
        });
Run Code Online (Sandbox Code Playgroud)

java android android-layout android-chips material-components-android

4
推荐指数
1
解决办法
3093
查看次数

Flutter 自定义字体未应用

Text我正在尝试为我的in中设置自定义字体Flutter。我已经尝试了我所知道的一切,但没有成功。这是一个错误还是什么?

flutter:
  uses-material-design: true
  assets:
    - assets/images/onboarding1.png
    - assets/images/onboarding2.png
    - assets/images/onboarding3.png
  fonts:
    - family: Gilroy
      fonts:
        - asset: assets/fonts/gilroy_extrabold.otf
Run Code Online (Sandbox Code Playgroud)

飞镖文件

SizedBox(height: 30.0),
                            Text(
                              'Connect with Mentors',
                              style: TextStyle(
                                fontFamily: 'Gilroy',
                                fontSize: 35.0,
                              ),
                            ),
Run Code Online (Sandbox Code Playgroud)

custom-font flutter

4
推荐指数
1
解决办法
3343
查看次数

圆形进度指示器未居中颤振

我正在login我的应用程序中集成,其中在发出请求时应该出现一个循环进度指示器。我不知道为什么progressBar总是出现在顶部而不是中心。请帮忙。

FadeAnimation(
        1.8,
        Center(
            child: Container(
          height: double.infinity,
          child: SingleChildScrollView(
            physics: AlwaysScrollableScrollPhysics(),
            padding: EdgeInsets.symmetric(
              horizontal: 40.0,
              vertical: 120.0,

            ),
            child: _isLoading
                ? Center(child: CircularProgressIndicator())
                : Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text(
                        'Sign In',
                        style: TextStyle(
                          color: Colors.white,
                          fontFamily: 'OpenSans',
                          fontSize: 30.0,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      SizedBox(height: 30.0),
                      _buildEmailTF(),
                      SizedBox(
                        height: 30.0,
                      ),
                      _buildPasswordTF(),
                      _buildForgotPasswordBtn(),
                      _buildRememberMeCheckbox(),
                      _buildLoginBtn(),
                      _buildSignInWithText(),
                      _buildSocialBtnRow(),
                      _buildSignupBtn(),
                    ],
                  ),
          ),
        )),
      )
Run Code Online (Sandbox Code Playgroud)

progress-bar flutter

3
推荐指数
2
解决办法
2495
查看次数

如何从颤动飞镖中的单词中获取第一个字符?

假设我们将名称设置为“Ben Bright”。我想输出给用户“BB”,每个单词的第一个字符。我试过这个split()方法,但我用飞镖没能做到。

String getInitials(bank_account_name) {
  List<String> names = bank_account_name.split(" ");
  String initials;
  for (var i = 0; i < names.length; i++) {
    initials = '${names[i]}';
  }
  return initials;
}
Run Code Online (Sandbox Code Playgroud)

dart

3
推荐指数
3
解决办法
5334
查看次数

计时器未取消抖动

我需要在我的应用程序上运行一个计时器实例,以便我可以在需要时取消并重新初始化它。但是,调用该操作后计时器不会取消.cancel()。仅当我从默认构造函数调用它时它才有效,但我想要一个可以随时取消的全局计时器;

Timer timer;

  timer = Timer.periodic(Duration(seconds: 10), (Timer t) async {
         //cancelling timer only works here e.g (t.cancel)
  print("loop operation");
        });

timer.cancel(); // calling this method outside the constructor don't work.
Run Code Online (Sandbox Code Playgroud)

dart flutter

0
推荐指数
1
解决办法
4210
查看次数