Skip to content

Issue when using this for Flutter Web #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
publish:
dart pub publish

.PHONY: publish
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
41 changes: 41 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions lib/src/core/google_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class GoogleMap extends StatefulWidget {
this.maxZoom,
this.mapStyle,
this.markers = const <Marker>{},
this.polygons = const<Polygon>{},
this.onTap,
this.onLongPress,
this.interactive = true,
Expand Down Expand Up @@ -80,6 +81,9 @@ class GoogleMap extends StatefulWidget {
/// Markers to be placed on the map.
final Set<Marker> markers;

// Polygons to placed on the map.
final Set<Polygon> polygons;

/// Called every time a [GoogleMap] is long pressed.
///
/// For `web` this will be called when `right mouse clicked`.
Expand Down
15 changes: 15 additions & 0 deletions lib/src/core/map_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<GeoCoord> 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,
});
}
21 changes: 14 additions & 7 deletions lib/src/mobile/google_map.state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down