Skip to content
This repository was archived by the owner on Jun 25, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 103 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,13 @@ You can refer to the [example](https://github.com/apptreesoftware/flutter_google
- [X] Receive camera change callbacks
- [X] Zoom to a set of annotations
- [X] Customize Pin color
- [X] Polyline support
- [X] Polygon support

### Upcoming
- [ ] Customize pin image
- [ ] Remove markers
- [ ] Bounds geometry functions
- [ ] Polyline support

## Usage examples

Expand All @@ -171,14 +172,15 @@ mapView.show(
title: "Recently Visited"),
toolbarActions: [new ToolbarAction("Close", 1)]);
```

#### Get notified when the map is ready
```dart
mapView.onMapReady.listen((_) {
print("Map ready");
});
```
#### Add multiple pins to the map
```dart
```dart
mapView.setMarkers(<Marker>[
new Marker("1", "Work", 45.523970, -122.663081, color: Colors.blue),
new Marker("2", "Nossa Familia Coffee", 45.528788, -122.684633),
Expand All @@ -190,7 +192,98 @@ mapView.setMarkers(<Marker>[
mapView.addMarker(new Marker("3", "10 Barrel", 45.5259467, -122.687747,
color: Colors.purple));
```

#### Add multiple polylines to the map
```dart
mapView.setPolylines(<Polyline>[
new Polyline(
"11",
<Location>[
new Location(45.523970, -122.663081),
new Location(45.528788, -122.684633),
new Location(45.528864, -122.667195),
],
jointType: FigureJointType.round,
width: 15.0,
color: Colors.orangeAccent,
),
new Polyline(
"12",
<Location>[
new Location(45.519698, -122.674932),
new Location(45.516687, -122.667014),
],
width: 15.0,
),
]);
```

#### Add a single polyline to the map
```dart
mapView.addPolyline(new Polyline(
"12",
<Location>[
new Location(45.519698, -122.674932),
new Location(45.516687, -122.667014),
],
width: 15.0));
```
#### Add multiple polygons to the map
```dart
mapView.setPolygons(<Polygon>[
new Polygon(
"111",
<Location>[
new Location(42.9274334, -72.2811234),
new Location(42.9258230, -72.2808444),
new Location(42.9261294, -72.2779906),
new Location(42.9275120, -72.2779155),
],
//you can add a hole inside the polygon
holes: <Hole>[
new Hole(
<Location>[
new Location(42.9270721, -72.2797287),
new Location(42.9266400, -72.2796750),
new Location(42.9267186, -72.2790956),
new Location(42.9270014, -72.2790956),
],
),
],
jointType: FigureJointType.round,
strokeWidth: 5.0,
strokeColor: Colors.red,
fillColor: Color.fromARGB(75, 255, 0, 0)),
new Polygon(
"111",
<Location>[
new Location(45.5231233, -122.6733130),
new Location(45.5233225, -122.6732969),
new Location(45.5232398, -122.6733506),
new Location(45.5231233, -122.6733130),
],
jointType: FigureJointType.round,
strokeWidth: 5.0,
strokeColor: Colors.red,
fillColor: Color.fromARGB(75, 255, 0, 0)),
]);
```

#### Add a single polygon to the map
```dart
mapView.addPolygon(new Polygon(
"111",
<Location>[
new Location(45.5231233, -122.6733130),
new Location(45.5233225, -122.6732969),
new Location(45.5232398, -122.6733506),
new Location(45.5231233, -122.6733130),
],
jointType: FigureJointType.round,
strokeWidth: 5.0,
strokeColor: Colors.red,
fillColor: Color.fromARGB(75, 255, 0, 0),
));
```
#### Zoom to fit all the pins on the map
```dart
mapView.zoomToFit(padding: 100);
Expand All @@ -202,9 +295,14 @@ mapView.onLocationUpdated
.listen((location) => print("Location updated $location"));
```

#### Receive marker touches
#### Receive marker, polyline & polygon touches
```dart
mapView.onTouchAnnotation.listen((marker) => print("marker tapped"));
//Marker
mapView.onTouchAnnotation.listen((annotation) => print("annotation ${annotation.id} tapped"));
//Polyline
mapView.onTouchPolyline.listen((polyline) => print("polyline ${polyline.id} tapped"));
//Polygon
mapView.onTouchPolygon.listen((polygon) => print("polygon ${polygon.id} tapped"));
```

#### Receive map touches
Expand Down
21 changes: 9 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ group 'com.apptreesoftware.mapview'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}

Expand All @@ -36,7 +33,7 @@ android {
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -47,7 +44,7 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2'
compile 'com.google.android.gms:play-services-maps:11.+'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Loading