This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Add heatmap support #5274
Closed
Closed
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit
Hold shift + click to select a range
f2e9806
Worked on platform interface
Rexios80 2203401
Added heatmap layer code to web
Rexios80 bcc8f07
Added web target to example
Rexios80 b179c93
Worked on interface
Rexios80 6ee7ae8
Worked on Android implementation
Rexios80 7f78965
Refactoring
Rexios80 09c1fab
Android works
Rexios80 d5d0726
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 cf29213
Java formatting
Rexios80 b2436f5
Fixed dart analysis
Rexios80 37c58ad
Added copyright text
Rexios80 789cd9a
Web tests
Rexios80 977dfd4
Heatmap updates test
Rexios80 d27c28c
Gradient works
Rexios80 2df83b5
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 efb432a
Example app now launches with Google-Maps-iOS-Utils included
Rexios80 5703eeb
Worked on ios implementation
Rexios80 c47d213
iOS kind of works; the gradient is being weird
Rexios80 2361e47
Merge branch 'flutter:main' into feature/google-maps-heatmap
Rexios80 72dd326
Merge remote-tracking branch 'origin/feature/google-maps-heatmap' int…
Rexios80 bc27137
Fixed gradient issue
Rexios80 146ea54
Only use 0 alpha gradient first color on web
Rexios80 5ed26a8
Ran clang-format
Rexios80 bd51355
Ran flutter format
Rexios80 876998f
iOS heatmap rendering is a lot better
Rexios80 d4b3524
Formatting
Rexios80 f6d3050
Merge branch 'flutter:main' into feature/google-maps-heatmap
Rexios80 8415953
Made WeightedLatLng extend LatLng
Rexios80 0a9495c
Resolved issues
Rexios80 65bad90
Fixed web code issue
Rexios80 319f84e
Resolved issues
Rexios80 b2e7e5e
Added heatmap controller to umbrella header
Rexios80 9cb30af
Made min/max zoom intensity configurable from flutter
Rexios80 5039dd1
Made start points and color map size configurable from flutter
Rexios80 177def0
dart formatting
Rexios80 ca94502
Fixed test code
Rexios80 6ee5fed
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 d341949
Better use of null safety
Rexios80 c3e904f
Added web heatmaps tests
Rexios80 5cd2524
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 7ad6e7b
Fixed web tests
Rexios80 7978892
Fixed another web test issue
Rexios80 d76e161
Got NSAssert working
Rexios80 dd3c82f
Removed incorrect doc comment
Rexios80 f89a3f4
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 994fd1f
Fixed analysis issues with HeatmapPage in example
Rexios80 f96f844
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 3c6c7cd
Fixed analysis issues
Rexios80 f63af88
Formatting
Rexios80 1160e32
Fixed issues
Rexios80 c41b00a
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 ead58b8
Added license text to example/web/index.html
Rexios80 d1a8856
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 5c78283
Merge branch 'google_map_clean_up' into feature/google-maps-heatmap
Rexios80 b9dd462
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 d1daad1
Formatting
Rexios80 35d8715
Don't know where that came from but okay
Rexios80 ccc9ca2
iOS example changes
Rexios80 ea1975b
Added iOS JSON conversion tests
Rexios80 d39a901
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 89239ab
Fixed issues
Rexios80 e5b4943
Refactored heatmap controllers
Rexios80 3c7d7dc
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 011828d
Added swift version to podspec for CI
Rexios80 c39446b
Removed `use_modular_headers!` from Podfile
Rexios80 4999d14
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 681eae8
Fixed missing things
Rexios80 0bf8dd2
Fixed issues
Rexios80 d011011
Xcode project file changes
Rexios80 b7f4f72
Formatting
Rexios80 906c3f0
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 09467d1
Reverted changes to other packages
Rexios80 a5e1e5f
Fixed umbrella header
Rexios80 686b60a
Formatting
Rexios80 70c8dbe
Fixed issues
Rexios80 4eaa5d3
Reverted changes to pbxproj file
Rexios80 b9d33cd
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 882d3b4
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 9005231
Fixes
Rexios80 0c03dad
Fixes
Rexios80 6d69bed
Fixes
Rexios80 edcede1
Fixes
Rexios80 cd24b9e
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 e67b408
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 f4d5c86
Fixed build issues
Rexios80 2f745ab
Fixed web test issues
Rexios80 1ce1595
Fixed analysis issues
Rexios80 b2be041
iOS build changes
Rexios80 60e15ea
Updated example
Rexios80 612e5be
Updated documentation
Rexios80 7c22792
Removed assertion for radius value
Rexios80 1d212eb
Fixed building in google_maps_flutter_ios/example
Rexios80 f1105ad
Formatting
Rexios80 ef7a9d4
Fixed android build issue
Rexios80 8c7c8f0
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 43ba954
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 3928a72
Assert that heatmap data is not empty
Rexios80 4d6392b
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 5c8839e
Revert "Assert that heatmap data is not empty"
Rexios80 c187469
Working on testing
Rexios80 feeed2c
Refactoring
Rexios80 e7471ea
Wrote some dart code
Rexios80 e779c77
Working on integration tests
Rexios80 aab722a
Fixing things
Rexios80 e08a292
Test passes
Rexios80 20591b0
Working on test
Rexios80 5235dad
Added heatmaps update test
Rexios80 55988cc
Added remove heatmaps test
Rexios80 e6e1af2
Working on Android tests
Rexios80 28468b2
Android tests work
Rexios80 35d12bd
Formatting
Rexios80 5c8ce27
Uncommented other tests
Rexios80 597d065
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 115ed7f
Undoing unnecessary changes to example
Rexios80 b3e1d4a
Rewrite tests using `moreOrLessEquals`
Rexios80 38ec627
Fixing issues
Rexios80 3639957
Updated documentation
Rexios80 89a0e20
Platform-specific serialization
Rexios80 88db9ca
...
Rexios80 34deb7d
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Worked on platform interface
- Loading branch information
commit f2e9806c6b70a499db08a8a9ca72a59afa7586eb
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
128 changes: 128 additions & 0 deletions
128
...ogle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_layer.dart
This file contains hidden or 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,128 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/foundation.dart' show listEquals; | ||
| import 'package:flutter/material.dart' show Color; | ||
| import 'package:flutter/foundation.dart' show immutable; | ||
|
|
||
| import 'types.dart'; | ||
|
|
||
| /// Uniquely identifies a [HeatmapLayer] among [GoogleMap] heatmap layers. | ||
| /// | ||
| /// This does not have to be globally unique, only unique among the list. | ||
| @immutable | ||
| class HeatmapLayerId extends MapsObjectId<HeatmapLayer> { | ||
| /// Creates an immutable identifier for a [HeatmapLayer]. | ||
| const HeatmapLayerId(String value) : super(value); | ||
| } | ||
|
|
||
| /// Draws a heatmap layer on the map. | ||
| @immutable | ||
| class HeatmapLayer implements MapsObject<HeatmapLayer> { | ||
| /// Creates an immutable representation of a [HeatmapLayer] to draw on | ||
| /// [GoogleMap]. | ||
| const HeatmapLayer({ | ||
| required this.heatmapLayerId, | ||
| this.data = const [], | ||
| this.dissipating = true, | ||
| this.gradient, | ||
| this.maxIntensity, | ||
| this.opacity = 0.6, | ||
| this.radius, | ||
| }); | ||
|
|
||
| /// Uniquely identifies a [HeatmapLayer]. | ||
| final HeatmapLayerId heatmapLayerId; | ||
|
|
||
| @override | ||
| HeatmapLayerId get mapsId => heatmapLayerId; | ||
|
|
||
| /// The data points to display. | ||
| final List<WeightedLatLng> data; | ||
|
|
||
| /// Specifies whether heatmaps dissipate on zoom. By default, the radius of | ||
| /// influence of a data point is specified by the radius option only. When | ||
| /// dissipating is disabled, the radius option is interpreted as a radius at | ||
| /// zoom level 0. | ||
| final bool dissipating; | ||
|
|
||
| /// The color gradient of the heatmap | ||
| final List<Color>? gradient; | ||
|
|
||
| /// The maximum intensity of the heatmap. By default, heatmap colors are | ||
| /// dynamically scaled according to the greatest concentration of points at | ||
| /// any particular pixel on the map. This property allows you to specify a | ||
| /// fixed maximum. | ||
| final double? maxIntensity; | ||
|
|
||
| /// The opacity of the heatmap, expressed as a number between 0 and 1. | ||
| /// Defaults to 0.6. | ||
| final double opacity; | ||
|
|
||
| /// The radius of influence for each data point, in pixels. | ||
| final double? radius; | ||
|
|
||
| /// Creates a new [HeatmapLayer] object whose values are the same as this | ||
| /// instance, unless overwritten by the specified parameters. | ||
| HeatmapLayer copyWith({ | ||
| List<WeightedLatLng>? dataParam, | ||
| bool? dissipatingParam, | ||
| List<Color>? gradientParam, | ||
| double? maxIntensityParam, | ||
| double? opacityParam, | ||
| double? radiusParam, | ||
| }) { | ||
| return HeatmapLayer( | ||
| heatmapLayerId: heatmapLayerId, | ||
| data: dataParam ?? data, | ||
| dissipating: dissipatingParam ?? dissipating, | ||
| gradient: gradientParam ?? gradient, | ||
| maxIntensity: maxIntensityParam ?? maxIntensity, | ||
| opacity: opacityParam ?? opacity, | ||
| radius: radiusParam ?? radius, | ||
| ); | ||
| } | ||
|
|
||
| /// Creates a new [HeatmapLayer] object whose values are the same as this | ||
| /// instance. | ||
| HeatmapLayer clone() => copyWith(); | ||
|
|
||
| /// Converts this object to something serializable in JSON. | ||
| Object toJson() { | ||
| final Map<String, Object> json = <String, Object>{}; | ||
|
|
||
| void addIfPresent(String fieldName, Object? value) { | ||
| if (value != null) { | ||
| json[fieldName] = value; | ||
| } | ||
| } | ||
|
|
||
| addIfPresent('heatmapLayerId', heatmapLayerId.value); | ||
| addIfPresent('data', data.map((e) => e.toJson())); | ||
| addIfPresent('dissipating', dissipating); | ||
| addIfPresent('gradient', gradient?.map((e) => e.value)); | ||
| addIfPresent('maxIntensity', maxIntensity); | ||
| addIfPresent('opacity', opacity); | ||
| addIfPresent('radius', radius); | ||
|
|
||
| return json; | ||
| } | ||
|
|
||
| @override | ||
| bool operator ==(Object other) { | ||
| if (identical(this, other)) return true; | ||
| if (other.runtimeType != runtimeType) return false; | ||
| final HeatmapLayer typedOther = other as HeatmapLayer; | ||
| return heatmapLayerId == typedOther.heatmapLayerId && | ||
| listEquals(data, typedOther.data) && | ||
| dissipating == typedOther.dissipating && | ||
| listEquals(gradient, typedOther.gradient) && | ||
| maxIntensity == typedOther.maxIntensity && | ||
| opacity == typedOther.opacity && | ||
| radius == typedOther.radius; | ||
| } | ||
|
|
||
| @override | ||
| int get hashCode => heatmapLayerId.hashCode; | ||
| } |
27 changes: 27 additions & 0 deletions
27
...s_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_layer_updates.dart
This file contains hidden or 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,27 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'types.dart'; | ||
|
|
||
| /// [HeatmapLayer] update events to be applied to the [GoogleMap]. | ||
| /// | ||
| /// Used in [GoogleMapController] when the map is updated. | ||
| // (Do not re-export) | ||
| class HeatmapLayerUpdates extends MapsObjectUpdates<HeatmapLayer> { | ||
| /// Computes [HeatmapLayerUpdates] given previous and current [HeatmapLayer]s. | ||
| HeatmapLayerUpdates.from( | ||
| Set<HeatmapLayer> previous, | ||
| Set<HeatmapLayer> current, | ||
| ) : super.from(previous, current, objectName: 'heatmapLayer'); | ||
|
|
||
| /// Set of HeatmapLayers to be added in this update. | ||
| Set<HeatmapLayer> get heatmapLayersToAdd => objectsToAdd; | ||
|
|
||
| /// Set of HeatmapLayers to be removed in this update. | ||
| Set<HeatmapLayerId> get heatmapLayerIdsToRemove => | ||
| objectIdsToRemove.cast<HeatmapLayerId>(); | ||
|
|
||
| /// Set of HeatmapLayers to be changed in this update. | ||
| Set<HeatmapLayer> get heatmapLayersToChange => objectsToChange; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -132,3 +132,45 @@ class LatLngBounds { | |
| @override | ||
| int get hashCode => Object.hash(southwest, northeast); | ||
| } | ||
|
|
||
| /// A data point entry for a heatmap. | ||
| /// This is a geographical data point with a weight attribute. | ||
| class WeightedLatLng { | ||
| /// The location of the data point. | ||
| final LatLng location; | ||
|
|
||
| /// The weighting value of the data point. | ||
| final double weight; | ||
|
|
||
| /// Creates a [WeightedLatLng] with the specified [weight] | ||
| WeightedLatLng(this.location, {this.weight = 1.0}); | ||
|
|
||
| /// Converts this object to something serializable in JSON. | ||
| Object toJson() { | ||
|
||
| return <Object>[location.toJson(), weight]; | ||
| } | ||
|
|
||
| /// Initialize a [WeightedLatLng] from an \[location, weight\] array. | ||
| static WeightedLatLng? fromJson(Object? json) { | ||
| if (json == null) { | ||
| return null; | ||
| } | ||
| assert(json is List && json.length == 2); | ||
| final list = json as List; | ||
| return WeightedLatLng( | ||
| LatLng.fromJson(list[0])!, | ||
| weight: list[1], | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| String toString() => '$runtimeType($location, $weight)'; | ||
|
|
||
| @override | ||
| bool operator ==(Object o) { | ||
| return o is WeightedLatLng && o.location == location && o.weight == weight; | ||
| } | ||
|
|
||
| @override | ||
| int get hashCode => Object.hash(location, weight); | ||
| } | ||
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
...aps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/heatmap_layer.dart
This file contains hidden or 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,20 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import '../types.dart'; | ||
| import 'maps_object.dart'; | ||
|
|
||
| /// Converts an [Iterable] of HeatmapLayers in a Map of | ||
| /// HeatmapLayerId -> HeatmapLayer. | ||
| Map<HeatmapLayerId, HeatmapLayer> keyByHeatmapLayerId( | ||
| Iterable<HeatmapLayer> heatmapLayers, | ||
| ) { | ||
| return keyByMapsObjectId<HeatmapLayer>(heatmapLayers) | ||
| .cast<HeatmapLayerId, HeatmapLayer>(); | ||
| } | ||
|
|
||
| /// Converts a Set of HeatmapLayers into something serializable in JSON. | ||
| Object serializeHeatmapLayerSet(Set<HeatmapLayer> heatmapLayers) { | ||
| return serializeMapsObjectSet(heatmapLayers); | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.