- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在我的 FLutter 应用程序中实现了一个 PageController,它工作正常。所以我可以滑动和改变屏幕/页面。我在我的应用程序中添加了一个谷歌地图,我无法在 map 内向左/向右滚动。当我试图向左滚动时.. 应用程序正在更改屏幕。如何使用 PageController 在 Google Map 上通过 ontap 在应用程序内滚动。谢谢。
这是我的 BubbleBottomNav 类(class)。
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart';
import 'package:bubbled_navigation_bar/bubbled_navigation_bar.dart';
import 'package:tasky/Map/mapClass.dart';
class BubbleBottomNav extends StatefulWidget {
final titles = ['Home', 'Map', 'Page1', 'Page2', 'Page3'];
final colors =[Colors.red,Colors.purple,Colors.teal,Colors.green,Colors.cyan];
final icons = [
CupertinoIcons.home,
CupertinoIcons.location,
CupertinoIcons.padlock,
Icons.assignment,
CupertinoIcons.profile_circled
];
@override
_BubbleBottomNavState createState() => _BubbleBottomNavState();
}
class _BubbleBottomNavState extends State<BubbleBottomNav> {
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
PageController _pageController;
MenuPositionController _menuPositionController;
bool userPageDragging = false;
@override
void initState() {
_menuPositionController = MenuPositionController(initPosition: 0);
_pageController = PageController(
initialPage: 0,
keepPage: false,
viewportFraction: 1.0
);
_pageController.addListener(handlePageChange);
super.initState();
}
void handlePageChange() {
_menuPositionController.absolutePosition = _pageController.page;
}
void checkUserDragging(ScrollNotification scrollNotification) {
if (scrollNotification is UserScrollNotification && scrollNotification.direction != ScrollDirection.idle) {
userPageDragging = true;
} else if (scrollNotification is ScrollEndNotification) {
userPageDragging = false;
}
if (userPageDragging) {
_menuPositionController.findNearestTarget(_pageController.page);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BubbledNavigationBar(
controller: _menuPositionController,
initialIndex: 0,
itemMargin: EdgeInsets.symmetric(horizontal: 8),
backgroundColor: Colors.white,
defaultBubbleColor: Colors.blue,
onTap: (index) {
_pageController.animateToPage(
index,
curve: Curves.easeInOutQuad,
duration: Duration(milliseconds: 500)
);
},
items: widget.titles.map((title) {
var index = widget.titles.indexOf(title);
var color = widget.colors[index];
return BubbledNavigationBarItem(
icon: getIcon(index, color),
activeIcon: getIcon(index, Colors.white),
bubbleColor: color,
title: Text(
title,
style: TextStyle(color: Colors.white, fontSize: 12),
),
);
}).toList(),
),
body: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
checkUserDragging(scrollNotification);
},
child: PageView(
controller: _pageController,
children:[
Container(color: Colors.cyan),
Mapclass(),
Container(color: Colors.redAccent),
Container(color: Colors.lightGreenAccent),
Container(color: Colors.blueGrey),
],
//widget.pages.toList(),
onPageChanged: (page) {
},
),
),
);
}
Padding getIcon(int index, Color color) {
return Padding(
padding: const EdgeInsets.only(bottom: 3),
child: Icon(widget.icons[index], size: 30, color: color),
);
}
}
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'dart:async';
class GoogleMapDemo extends StatefulWidget {
@override
_GoogleMapDemoState createState() => _GoogleMapDemoState();
}
class _GoogleMapDemoState extends State<GoogleMapDemo>
with SingleTickerProviderStateMixin {
Completer<GoogleMapController> _controller = Completer();
final islocationpermission = false;
static const LatLng _center = const LatLng(21.234685, 72.8832501);
MapType _currentMapType = MapType.normal;
final Set<Marker> _markers = {};
LatLng _lastMapPosition = _center;
@override
void initState() {
super.initState();
}
void _onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
}
void _onCameraMove(CameraPosition position) {
_lastMapPosition = position.target;
}
void _onAddMarkerButtonPressed() {
setState(() {
_markers.add(Marker(
// This marker id can be anything that uniquely identifies each marker.
markerId: MarkerId(_lastMapPosition.toString()),
position: _lastMapPosition,
infoWindow: InfoWindow(
title: 'Checkout this Place',
snippet: 'Rate now',
),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet)));
});
}
void showMenuSelection(String value) {
setState(() {
switch (value) {
case 'normal':
{
_currentMapType = MapType.normal;
}
break;
case 'hybrid':
{
_currentMapType = MapType.hybrid;
}
break;
case 'satellite':
{
_currentMapType = MapType.satellite;
}
break;
case 'terrain':
{
_currentMapType = MapType.terrain;
}
break;
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Map Feed"),backgroundColor: Color(0XFF2193b0),
actions: <Widget>[
PopupMenuButton<String>(
onSelected: showMenuSelection,
tooltip: "Choose MapType",
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
const PopupMenuItem<String>(
value: 'normal',
child: Text('Normal'),
),
const PopupMenuItem<String>(
value: 'hybrid',
child: Text('HyBrid'),
),
const PopupMenuItem<String>(
value: 'satellite',
child: Text('Satellite'),
),
const PopupMenuItem<String>(
value: 'terrain',
child: Text('Terrain'),
)
],
),
],
),
body: Stack(
children: <Widget>[
GoogleMap(
myLocationEnabled: true,
mapType: _currentMapType,
onMapCreated: _onMapCreated,
scrollGesturesEnabled: true,
tiltGesturesEnabled: true,
rotateGesturesEnabled: true,
compassEnabled: true,
onCameraMove: _onCameraMove,
markers: _markers,
// trackCameraPosition: true,
zoomGesturesEnabled: true,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 10.0,
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Align(
alignment: Alignment.topRight,
child: Column(
children: <Widget>[
FloatingActionButton(
onPressed: _onAddMarkerButtonPressed,
materialTapTargetSize: MaterialTapTargetSize.padded,
backgroundColor: Colors.green,
child: const Icon(Icons.add_location, size: 36.0),
),
],
),
),
),
],
),
);
}
}
最佳答案
要解决此问题,只需将以下代码添加到谷歌地图小部件:
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
new Factory<OneSequenceGestureRecognizer>(
() => new EagerGestureRecognizer(),
),
].toSet(),
关于android - 在 Flutter 中使用 Map 的 PageController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61642414/
在 Flutter 中,我无法将相同的 PageController 分配给多个 PageView。所以需要使用两个或多个 PageController。 我需要同步我的 ViewPage,这样当我互
在我的应用程序中,我想将 pagecontrol 可选页面(点)颜色更改为棕色而不是白色。 我知道可以更改页面控件的背景颜色。但是如何将可选页面(点)颜色更改为其他颜色? 最佳答案 UIPageCon
我想以编程方式将 UIPageControl 项添加到我的 View Controller 中。 self.view 属性包含一个具有以下属性的 UIScrollView: scrollView =
是否可以水平方向左对齐选项卡标题? 最佳答案 不确定您到底想要什么,但您可以将 OwnerDraw 属性设置为 True。并使用OnDrawTab事件自己绘制。 关于delphi - PageCont
我正在尝试将当前页面的点缩放为大于未“选择”的点。 我正在使用 ScrollView 委托(delegate)来确定哪个页面是当前的。 目前点的大小没有变化。 我将如何实现这一目标? func scr
http://apptech.next-munich.com/2010/04/customizing-uipagecontrols-looks.html 上面的网址中有一些用于自定义 UIPageCo
Delphi 7,带有选项卡的 TPageControl。如果我单击选项卡标题,它就会成为焦点(绘制虚线框)。这里不需要,我想始终保持选项卡内容的焦点(在页面控件内)。如何禁用选项卡标题上的焦点? 例
我的表单上有一个 PageControl,我希望检测用户何时选择另一个选项卡。 我该怎么做?我使用的是 Delphi 7。 我没有找到任何事件,浪费时间开发自己的页面控件并不完全是我打算做的。 最佳答
我正在寻找(我认为)可以在 TPageControl 组件的 OnDrawTab 事件中使用的 Windows API,以在我选择的选项卡上显示灰色文本。我过去曾经这样做过,根据内存,这就是我所做的(
Storyboard和 pageControl 作为页面 Controller 也呈现 View Controller 的序列有什么区别? 最佳答案 页面控件在 ScrollView 中添加多个 Vi
我正在尝试为 iOS Developer PageControl Sample 实现建议的优化。 .这是我在 PhoneContentController 中使用的代码: // A possible
我尝试在viewController中添加pageControl以显示当前页和总页。 我在viewController内有collectionView。但是如果我在 viewController 中添
我正在使用scrollview和pagecontroll来滚动某些内容。我使用了下面的代码,但我希望页面 Controller 的点显示在 View 上。我尝试将其放在所有 View 和 Scroll
我已经使用界面生成器向 titleView 添加了一个 pageControl。问题是它根本不居中。实际上,我可以在 leftBarButton 文本之后做很多空白,但这并不理想。解决方案是什么? 最
如果 pageControl.numberOfPages > 15 ,我想让我的 PageControl 显示两行 我已经搜索了pageContro 的所有功能,但没有找到任何功能可以处理这种情况。如
我正在尝试将当前页面的点缩放为大于未“选中”的点。 我正在使用 ScrollView 委托(delegate)来确定哪个页面是当前页面。 目前点的大小没有变化。 我将如何实现这一目标? func sc
我有 3 个页面 - A ViewController、B ViewController 和 C ViewController。 还有一个 PageViewController 控制水平滚动。 Pag
我正在使用 UIPageViewController 来显示其他 4 个 ViewController。所以我的 RootViewController 是一个 PageViewController ,
我似乎在 1 个屏幕上显示 2 个 PageView 时遇到问题。下面是我的应用程序:日历周时间轴是 PageView,它下面的内容也需要是 PageView。 现在两个 PageViews 都需要相
我目前使用的是 Delphi 7。 我有一个主表单,它有一个带有 5 个选项卡的 PageControl。我正在寻找一种方法将这些选项卡从页面控件中“分离”,并将它们单独移动到一个新的表单(即运行时创
我是一名优秀的程序员,十分优秀!