diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c0d7503 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +publish: + dart pub publish + +.PHONY: publish \ No newline at end of file diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/lib/src/core/google_map.dart b/lib/src/core/google_map.dart index d944166..87b5f01 100644 --- a/lib/src/core/google_map.dart +++ b/lib/src/core/google_map.dart @@ -25,6 +25,7 @@ class GoogleMap extends StatefulWidget { this.maxZoom, this.mapStyle, this.markers = const {}, + this.polygons = const{}, this.onTap, this.onLongPress, this.interactive = true, @@ -80,6 +81,9 @@ class GoogleMap extends StatefulWidget { /// Markers to be placed on the map. final Set markers; + // Polygons to placed on the map. + final Set polygons; + /// Called every time a [GoogleMap] is long pressed. /// /// For `web` this will be called when `right mouse clicked`. diff --git a/lib/src/core/map_items.dart b/lib/src/core/map_items.dart index b57b1c4..c8d124e 100644 --- a/lib/src/core/map_items.dart +++ b/lib/src/core/map_items.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:flutter/foundation.dart' show ValueChanged, VoidCallback; +import 'package:flutter/material.dart'; import 'package:google_directions_api/google_directions_api.dart' show GeoCoord; @@ -48,3 +49,17 @@ class Marker { /// if [onInfoWindowTap] is set, it will be called once InfoWindow will be tapped. final VoidCallback onInfoWindowTap; } + +class Polygon { + final List points; + final Color strokeColor; + final double strokeWidth; + final Color fillColor; + + const Polygon({ + this.points, + this.strokeColor = Colors.lightBlue, + this.strokeWidth = 1, + this.fillColor = Colors.lightBlue, + }); +} \ No newline at end of file diff --git a/lib/src/mobile/google_map.state.dart b/lib/src/mobile/google_map.state.dart index 40afc56..c9f4045 100644 --- a/lib/src/mobile/google_map.state.dart +++ b/lib/src/mobile/google_map.state.dart @@ -3,7 +3,9 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; +import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flinq/flinq.dart'; @@ -191,13 +193,6 @@ class GoogleMapState extends gmap.GoogleMapStateBase { icon: icon == null ? BitmapDescriptor.defaultMarker : await _getBmpDesc('${fixAssetPath(icon)}$icon'), - infoWindow: info != null - ? InfoWindow( - title: info, - snippet: infoSnippet, - onTap: onInfoWindowTap, - ) - : null, ); _setState(() => _markers[key] = marker); @@ -571,6 +566,18 @@ class GoogleMapState extends gmap.GoogleMapStateBase { addMarker(marker); } } + + if (widget.polygons != null) { + for (var polygon in widget.polygons) { + addPolygon( + polygon.points.toString(), + polygon.points, + fillColor: polygon.fillColor, + strokeColor: polygon.strokeColor, + strokeWidth: polygon.strokeWidth, + ); + } + } } @override diff --git a/pubspec.yaml b/pubspec.yaml index 5014564..ab809de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ -name: flutter_google_maps -version: 4.0.0 -homepage: https://github.com/marchdev-tk/flutter_google_maps +name: crossplatform_google_maps +version: 4.1.0 +homepage: https://github.com/taskhunt/flutter_google_maps description: A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobile and google_maps for Web. environment: @@ -10,13 +10,13 @@ dependencies: flutter: sdk: flutter - google_polyline_algorithm: ^2.0.0 - google_maps_flutter: ^0.5.28+1 - google_directions_api: ^0.5.0 - google_maps: ^3.4.3 - http: ^0.12.1 - flinq: ^1.1.0 - uuid: ^2.1.0 + google_polyline_algorithm: ^3.1.0 + google_maps_flutter: ^2.0.6 + google_directions_api: ^0.9.0 + google_maps: ^5.1.0 + http: ^0.13.3 + flinq: ^2.0.2 + uuid: ^3.0.4 dev_dependencies: flutter_test: