Skip to content

Commit 81fcaa7

Browse files
committed
initial commit
0 parents  commit 81fcaa7

13 files changed

+701
-0
lines changed

.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.packages
28+
.pub-cache/
29+
.pub/
30+
build/
31+
32+
# Android related
33+
**/android/**/gradle-wrapper.jar
34+
**/android/.gradle
35+
**/android/captures/
36+
**/android/gradlew
37+
**/android/gradlew.bat
38+
**/android/local.properties
39+
**/android/**/GeneratedPluginRegistrant.java
40+
41+
# iOS/XCode related
42+
**/ios/**/*.mode1v3
43+
**/ios/**/*.mode2v3
44+
**/ios/**/*.moved-aside
45+
**/ios/**/*.pbxuser
46+
**/ios/**/*.perspectivev3
47+
**/ios/**/*sync/
48+
**/ios/**/.sconsign.dblite
49+
**/ios/**/.tags*
50+
**/ios/**/.vagrant/
51+
**/ios/**/DerivedData/
52+
**/ios/**/Icon?
53+
**/ios/**/Pods/
54+
**/ios/**/.symlinks/
55+
**/ios/**/profile
56+
**/ios/**/xcuserdata
57+
**/ios/.generated/
58+
**/ios/Flutter/App.framework
59+
**/ios/Flutter/Flutter.framework
60+
**/ios/Flutter/Generated.xcconfig
61+
**/ios/Flutter/app.flx
62+
**/ios/Flutter/app.zip
63+
**/ios/Flutter/flutter_assets/
64+
**/ios/Flutter/flutter_export_environment.sh
65+
**/ios/ServiceDefinitions.json
66+
**/ios/Runner/GeneratedPluginRegistrant.*
67+
68+
# Exceptions to above rules.
69+
!**/ios/**/default.mode1v3
70+
!**/ios/**/default.mode2v3
71+
!**/ios/**/default.pbxuser
72+
!**/ios/**/default.perspectivev3
73+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f
8+
channel: stable
9+
10+
project_type: package

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Flutter",
9+
"request": "launch",
10+
"type": "dart"
11+
}
12+
]
13+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## [0.0.1] - TODO: Add release date.
2+
3+
* TODO: Describe initial release.

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# flutter_platform_maps
2+
3+
A new Flutter package project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Dart
8+
[package](https://flutter.dev/developing-packages/),
9+
a library module containing code that can be shared easily across
10+
multiple Flutter or Dart projects.
11+
12+
For help getting started with Flutter, view our
13+
[online documentation](https://flutter.dev/docs), which offers tutorials,
14+
samples, guidance on mobile development, and a full API reference.

lib/platform_maps_flutter.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library flutter_platform_maps;
2+
3+
import 'dart:io';
4+
5+
import 'package:flutter/cupertino.dart';
6+
import 'package:flutter/foundation.dart';
7+
import 'package:flutter/gestures.dart';
8+
import 'package:google_maps_flutter/google_maps_flutter.dart' as googleMaps;
9+
import 'package:apple_maps_flutter/apple_maps_flutter.dart' as appleMaps;
10+
11+
part 'src/camera.dart';
12+
part 'src/platform_maps.dart';
13+
part 'src/location.dart';

lib/src/camera.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2018 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
part of flutter_platform_maps;
6+
7+
/// The position of the map "camera", the view point from which the world is
8+
/// shown in the map view. Aggregates the camera's [target] geographical
9+
/// location, its [zoom] level, [pitch] angle, and [heading].
10+
class CameraPosition
11+
implements googleMaps.CameraPosition, appleMaps.CameraPosition {
12+
const CameraPosition({
13+
@required this.target,
14+
this.heading = 0.0,
15+
this.pitch = 0.0,
16+
this.zoom = 0,
17+
}) : assert(target != null),
18+
assert(heading != null),
19+
assert(pitch != null),
20+
assert(zoom != null);
21+
22+
/// The camera's bearing in degrees, measured clockwise from north.
23+
///
24+
/// A bearing of 0.0, the default, means the camera points north.
25+
/// A bearing of 90.0 means the camera points east.
26+
final double heading;
27+
28+
/// The geographical location that the camera is pointing at.
29+
final LatLng target;
30+
31+
// In degrees where 0 is looking straight down. Pitch may be clamped to an appropriate value.
32+
final double pitch;
33+
34+
/// The zoom level of the camera.
35+
///
36+
/// A zoom of 0.0, the default, means the screen width of the world is 256.
37+
/// Adding 1.0 to the zoom level doubles the screen width of the map. So at
38+
/// zoom level 3.0, the screen width of the world is 2³x256=2048.
39+
///
40+
/// Larger zoom levels thus means the camera is placed closer to the surface
41+
/// of the Earth, revealing more detail in a narrower geographical region.
42+
///
43+
/// The supported zoom level range depends on the map data and device. Values
44+
/// beyond the supported range are allowed, but on applying them to a map they
45+
/// will be silently clamped to the supported range.
46+
final double zoom;
47+
48+
@override
49+
String toString() =>
50+
'CameraPosition(bearing: $heading, target: $target, tilt: $pitch, zoom: $zoom)';
51+
52+
@override
53+
// TODO: implement bearing
54+
double get bearing => null;
55+
56+
@override
57+
// TODO: implement tilt
58+
double get tilt => null;
59+
60+
@override
61+
toMap() {
62+
// TODO: implement toMap
63+
return null;
64+
}
65+
}

lib/src/location.dart

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright 2018 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
part of flutter_platform_maps;
6+
7+
/// A pair of latitude and longitude coordinates, stored as degrees.
8+
class LatLng implements googleMaps.LatLng, appleMaps.LatLng {
9+
/// Creates a geographical location specified in degrees [latitude] and
10+
/// [longitude].
11+
///
12+
/// The latitude is clamped to the inclusive interval from -90.0 to +90.0.
13+
///
14+
/// The longitude is normalized to the half-open interval from -180.0
15+
/// (inclusive) to +180.0 (exclusive)
16+
const LatLng(double latitude, double longitude)
17+
: assert(latitude != null),
18+
assert(longitude != null),
19+
latitude =
20+
(latitude < -90.0 ? -90.0 : (90.0 < latitude ? 90.0 : latitude)),
21+
longitude = (longitude + 180.0) % 360.0 - 180.0;
22+
23+
/// The latitude in degrees between -90.0 and 90.0, both inclusive.
24+
final double latitude;
25+
26+
/// The longitude in degrees between -180.0 (inclusive) and 180.0 (exclusive).
27+
final double longitude;
28+
29+
dynamic _toJson() {
30+
return <double>[latitude, longitude];
31+
}
32+
33+
static LatLng _fromJson(dynamic json) {
34+
if (json == null) {
35+
return null;
36+
}
37+
return LatLng(json[0], json[1]);
38+
}
39+
40+
@override
41+
String toString() => '$runtimeType($latitude, $longitude)';
42+
43+
@override
44+
bool operator ==(Object o) {
45+
return o is LatLng && o.latitude == latitude && o.longitude == longitude;
46+
}
47+
48+
@override
49+
int get hashCode => hashValues(latitude, longitude);
50+
}
51+
52+
/// A latitude/longitude aligned rectangle.
53+
///
54+
/// The rectangle conceptually includes all points (lat, lng) where
55+
/// * lat ∈ [`southwest.latitude`, `northeast.latitude`]
56+
/// * lng ∈ [`southwest.longitude`, `northeast.longitude`],
57+
/// if `southwest.longitude``northeast.longitude`,
58+
/// * lng ∈ [-180, `northeast.longitude`] ∪ [`southwest.longitude`, 180[,
59+
/// if `northeast.longitude` < `southwest.longitude`
60+
class LatLngBounds {
61+
/// Creates geographical bounding box with the specified corners.
62+
///
63+
/// The latitude of the southwest corner cannot be larger than the
64+
/// latitude of the northeast corner.
65+
LatLngBounds({@required this.southwest, @required this.northeast})
66+
: assert(southwest != null),
67+
assert(northeast != null),
68+
assert(southwest.latitude <= northeast.latitude);
69+
70+
/// The southwest corner of the rectangle.
71+
final LatLng southwest;
72+
73+
/// The northeast corner of the rectangle.
74+
final LatLng northeast;
75+
76+
dynamic _toList() {
77+
return <dynamic>[southwest._toJson(), northeast._toJson()];
78+
}
79+
80+
/// Returns whether this rectangle contains the given [LatLng].
81+
bool contains(LatLng point) {
82+
return _containsLatitude(point.latitude) &&
83+
_containsLongitude(point.longitude);
84+
}
85+
86+
bool _containsLatitude(double lat) {
87+
return (southwest.latitude <= lat) && (lat <= northeast.latitude);
88+
}
89+
90+
bool _containsLongitude(double lng) {
91+
if (southwest.longitude <= northeast.longitude) {
92+
return southwest.longitude <= lng && lng <= northeast.longitude;
93+
} else {
94+
return southwest.longitude <= lng || lng <= northeast.longitude;
95+
}
96+
}
97+
98+
@visibleForTesting
99+
static LatLngBounds fromList(dynamic json) {
100+
if (json == null) {
101+
return null;
102+
}
103+
return LatLngBounds(
104+
southwest: LatLng._fromJson(json[0]),
105+
northeast: LatLng._fromJson(json[1]),
106+
);
107+
}
108+
109+
@override
110+
String toString() {
111+
return '$runtimeType($southwest, $northeast)';
112+
}
113+
114+
@override
115+
bool operator ==(Object o) {
116+
return o is LatLngBounds &&
117+
o.southwest == southwest &&
118+
o.northeast == northeast;
119+
}
120+
121+
@override
122+
int get hashCode => hashValues(southwest, northeast);
123+
}

0 commit comments

Comments
 (0)