Closed natopotato34 closed 3 weeks ago
@natopotato34 Hmm this shouldn't be happening. You can fix that by setting animateDraw: true
when using addPointConnection
.
E.g.
import 'package:flutter/material.dart';
import 'package:flutter_earth_globe/flutter_earth_globe.dart';
import 'package:flutter_earth_globe/flutter_earth_globe_controller.dart';
import 'package:flutter_earth_globe/globe_coordinates.dart';
import 'package:flutter_earth_globe/point.dart';
import 'package:flutter_earth_globe/point_connection.dart';
import 'package:flutter_earth_globe/point_connection_style.dart';
void main() {
runApp(MaterialApp(
title: 'Flutter Earth Globe Example',
theme: ThemeData(primarySwatch: Colors.blue),
debugShowCheckedModeBanner: false,
home: const SinglePlayerScreen(),
));
}
class SinglePlayerScreen extends StatefulWidget {
const SinglePlayerScreen({Key? key}) : super(key: key);
@override
_SinglePlayerScreenState createState() => _SinglePlayerScreenState();
}
class _SinglePlayerScreenState extends State with TickerProviderStateMixin {
late FlutterEarthGlobeController _controller;
@override
void initState() {
super.initState();
_controller = FlutterEarthGlobeController(
rotationSpeed: 0.05,
zoom: 0.5,
isRotating: false,
isBackgroundFollowingSphereRotation: true,
background: Image.asset('assets/2k_stars.jpg').image,
surface: Image.asset('assets/2k_earth-day.jpg').image,
);
_controller.onLoaded = () {
setState(() {
print('Globe Loaded');
addPointsAndConnection();
});
};
}
void addPointsAndConnection() {
// Adding points
_controller.addPoint(Point(
id: '1',
coordinates: const GlobeCoordinates(51.5072, 0.1276),
label: 'Point 1',
isLabelVisible: true,
style: const PointStyle(color: Colors.red, size: 6),
));
_controller.addPoint(Point(
id: '2',
coordinates: const GlobeCoordinates(40.7128, -74.0060),
label: 'Point 2',
isLabelVisible: true,
style: const PointStyle(color: Colors.green, size: 6),
));
// Adding connection
print('Adding Connection from Point 1 to Point 2:');
print('Point 1: 51.5072, 0.1276');
print('Point 2: 40.7128, -74.0060');
_controller.addPointConnection(
PointConnection(
id: 'connection',
start: const GlobeCoordinates(51.5072, 0.1276),
end: const GlobeCoordinates(40.7128, -74.0060),
label: 'Connection 1-2',
isLabelVisible: true,
style: const PointConnectionStyle(
type: PointConnectionType.solid,
color: Colors.yellow,
lineWidth: 2,
),
),
// add this line here to fix it
animateDraw: true);
print('Connection Added: connection');
// Check connections in the controller
final connections = _controller.connections;
print('Controller Connections: ${connections.length}');
for (var connection in connections) {
print(
'Connection ID: ${connection.id}, Start: (${connection.start.latitude}, ${connection.start.longitude}), End: (${connection.end.latitude}, ${connection.end.longitude})');
}
}
@override
@override
Widget build(BuildContext context) {
double radius = MediaQuery.of(context).size.width < 500
? ((MediaQuery.of(context).size.width / 3.8) - 20)
: 120;
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Earth Globe Example'),
),
body: SafeArea(
child: Stack(
children: [
FlutterEarthGlobe(
controller: _controller,
radius: radius,
),
],
),
),
);
}
}
Awesome, I'll give that a try tonight! I'm trying to add some functionality to do region shading. It's early on but it's coming along. Thanks so much for making this library! I had tried doing an app with a globe last year and I didn't want to go through mapbox. This is exactly what I needed.
Yeah your fix did it! Thanks!
Hello,
I'm encountering an issue where point connections on the globe do not render as expected. I've followed the documentation and attempted to add connections between points, but they do not appear on the globe. I have tried the example in the repo and that works just fine for me but like anything else does not at all and I am so confused
Steps to Reproduce:
Use the provided main.dart script.
Ensure the required assets (2k_stars.jpg and 2k_earth-day.jpg) are present in the assets directory.
Run the application.
Observe that while points are visible, the connections between them do not render.
Expected Behavior: Connections between points should be visible on the globe.
Actual Behavior: Connections do not render, although the points themselves are visible.
Environment: Flutter version: [Provide your Flutter version] flutter_earth_globe version: [Provide the version you're using] Additional Context: Here is a simple main.dart script that demonstrates the issue: import 'package:flutter/material.dart'; import 'package:flutter_earth_globe/flutter_earth_globe.dart'; import 'package:flutter_earth_globe/flutter_earth_globe_controller.dart'; import 'package:flutter_earth_globe/globe_coordinates.dart'; import 'package:flutter_earth_globe/point.dart'; import 'package:flutter_earth_globe/point_connection.dart'; import 'package:flutter_earth_globe/point_connection_style.dart';
void main() { runApp(MaterialApp( title: 'Flutter Earth Globe Example', theme: ThemeData(primarySwatch: Colors.blue), debugShowCheckedModeBanner: false, home: const SinglePlayerScreen(), )); }
class SinglePlayerScreen extends StatefulWidget { const SinglePlayerScreen({Key? key}) : super(key: key);
@override _SinglePlayerScreenState createState() => _SinglePlayerScreenState(); }
class _SinglePlayerScreenState extends State with TickerProviderStateMixin {
late FlutterEarthGlobeController _controller;
@override void initState() { super.initState(); _controller = FlutterEarthGlobeController( rotationSpeed: 0.05, zoom: 0.5, isRotating: false, isBackgroundFollowingSphereRotation: true, background: Image.asset('assets/2k_stars.jpg').image, surface: Image.asset('assets/2k_earth-day.jpg').image, );
}
void addPointsAndConnection() { // Adding points _controller.addPoint(Point( id: '1', coordinates: const GlobeCoordinates(51.5072, 0.1276), label: 'Point 1', isLabelVisible: true, style: const PointStyle(color: Colors.red, size: 6), ));
}
@override Widget build(BuildContext context) { double radius = MediaQuery.of(context).size.width < 500 ? ((MediaQuery.of(context).size.width / 3.8) - 20) : 120;
} }