-
-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from apptreesoftware/master
Merge upstream
- Loading branch information
Showing
7 changed files
with
167 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
## [0.0.1] - 2/5/2018 | ||
|
||
- inital release | ||
|
||
## [0.0.2] - 2/21/2018 | ||
|
||
- subdomain support | ||
- move gesture detection into map widget | ||
- improved tile layer support | ||
- improved examples | ||
- Polyline layers | ||
- fix marker redraw on map rotation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:latlong/latlong.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'dart:ui'; | ||
|
||
class PolylineLayerOptions extends LayerOptions { | ||
final List<Polyline> polylines; | ||
PolylineLayerOptions({this.polylines = const []}); | ||
} | ||
|
||
class Polyline { | ||
final List<LatLng> points; | ||
final List<Offset> offsets = []; | ||
final double strokeWidth; | ||
final Color color; | ||
Polyline({ | ||
this.points, | ||
this.strokeWidth = 1.0, | ||
this.color = const Color(0xFF00FF00), | ||
}); | ||
} | ||
|
||
class PolylineLayer extends StatelessWidget { | ||
final PolylineLayerOptions polylineOpts; | ||
final MapState map; | ||
PolylineLayer(this.polylineOpts, this.map); | ||
|
||
Widget build(BuildContext context) { | ||
return new StreamBuilder<int>( | ||
stream: map.onMoved, // a Stream<int> or null | ||
builder: (BuildContext context, _) { | ||
for (var polylineOpt in polylineOpts.polylines) { | ||
polylineOpt.offsets.clear(); | ||
var i = 0; | ||
for (var point in polylineOpt.points) { | ||
var pos = map.project(point); | ||
pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - | ||
map.getPixelOrigin(); | ||
polylineOpt.offsets.add(new Offset(pos.x, pos.y)); | ||
if (i > 0 && i < polylineOpt.points.length) { | ||
polylineOpt.offsets.add(new Offset(pos.x, pos.y)); | ||
} | ||
i++; | ||
} | ||
} | ||
|
||
var polylines = <Widget>[]; | ||
for (var polylineOpt in this.polylineOpts.polylines) { | ||
polylines.add( | ||
new CustomPaint( | ||
painter: new PolylinePainter(polylineOpt), | ||
), | ||
); | ||
} | ||
|
||
return new Container( | ||
child: new Stack( | ||
children: polylines, | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
class PolylinePainter extends CustomPainter { | ||
final Polyline polylineOpt; | ||
PolylinePainter(this.polylineOpt); | ||
|
||
@override | ||
void paint(Canvas canvas, Size size) { | ||
if (polylineOpt.offsets.isEmpty) { | ||
return; | ||
} | ||
var paint = new Paint()..color = polylineOpt.color; | ||
paint.strokeWidth = polylineOpt.strokeWidth; | ||
canvas.drawPoints(PointMode.lines, polylineOpt.offsets, paint); | ||
} | ||
|
||
@override | ||
bool shouldRepaint(PolylinePainter other) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: flutter_map | ||
description: A flutter implementation of Leaflet | ||
version: 0.0.2+2 | ||
version: 0.0.2+4 | ||
authors: | ||
- John Ryan <[email protected]> | ||
homepage: https://github.com/apptreesoftware/flutter_map | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters