Skip to content
This repository was archived by the owner on Feb 22, 2023. 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# google_maps_flutter_platform_interface

A common platform interface for the [`google_maps_flutter`][1] plugin.

This interface allows platform-specific implementations of the `google_maps_flutter`
plugin, as well as the plugin itself, to ensure they are supporting the
same interface.

# Usage

To implement a new platform-specific implementation of `google_maps_flutter`, extend
[`GoogleMapsFlutterPlatform`][2] with an implementation that performs the
platform-specific behavior, and when you register your plugin, set the default
`GoogleMapsFlutterPlatform` by calling
`GoogleMapsFlutterPlatform.instance = MyPlatformGoogleMapsFlutter()`.

# Note on breaking changes

Strongly prefer non-breaking changes (such as adding a method to the interface)
over breaking changes for this package.

See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
on why a less-clean interface is preferable to a breaking change.

[1]: ../google_maps_flutter
[2]: lib/google_maps_flutter_platform_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/platform_interface/google_maps_flutter_platform.dart';
export 'src/types/types.dart';
export 'src/events/map_event.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Copyright 2018 The Chromium 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:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:google_maps_flutter_platform_interface/src/method_channel/method_channel_google_maps_flutter.dart';

/// Generic Event coming from the native side of Maps.
///
/// All MapEvents contain the `mapId` that originated the event. This should
/// never be `null`.
///
/// The `<T>` on this event represents the type of the `value` that is
/// contained within the event.
///
/// This class is used as a base class for all the events that might be
/// triggered from a Map, but it is never used directly as an event type.
///
/// Do NOT instantiate new events like `MapEvent<ValueType>(mapId, val)` directly,
/// use a specific class instead:
///
/// Do `class NewEvent extend MapEvent<ValueType>` when creating your own events.
/// See below for examples: `CameraMoveStartedEvent`, `MarkerDragEndEvent`...
/// These events are more semantic and pleasant to use than raw generics. They
/// can be (and in fact, are) filtered by the `instanceof`-operator.
///
/// (See [MethodChannelGoogleMapsFlutter.onCameraMoveStarted], for example)
///
/// If your event needs a `position`, alongside the `value`, do
/// `extends _PositionedMapEvent<ValueType>` instead. This adds a `LatLng position`
/// attribute.
///
/// If your event *only* needs a `position`, do `extend _PositionedMapEvent<void>`
/// do NOT `extend MapEvent<LatLng>`. The former lets consumers of these
/// events to access the `.position` property, rather than the more generic `.value`
/// yielded from the latter.
class MapEvent<T> {
/// The ID of the Map this event is associated to.
final int mapId;

/// The value wrapped by this event
final T value;

/// Build a Map Event, that relates a mapId with a given value.
///
/// The `mapId` is the id of the map that triggered the event.
/// `value` may be `null` in events that don't transport any meaningful data.
MapEvent(this.mapId, this.value);
}

/// A `MapEvent` associated to a `position`.
class _PositionedMapEvent<T> extends MapEvent<T> {
/// The position where this event happened.
final LatLng position;

/// Build a Positioned MapEvent, that relates a mapId and a position with a value.
///
/// The `mapId` is the id of the map that triggered the event.
/// `value` may be `null` in events that don't transport any meaningful data.
_PositionedMapEvent(int mapId, this.position, T value) : super(mapId, value);
}

// The following events are the ones exposed to the end user. They are semantic extensions
// of the two base classes above.
//
// These events are used to create the appropriate [Stream] objects, with information
// coming from the native side.

/// An event fired when the Camera of a [mapId] starts moving.
class CameraMoveStartedEvent extends MapEvent<void> {
/// Build a CameraMoveStarted Event triggered from the map represented by `mapId`.
CameraMoveStartedEvent(int mapId) : super(mapId, null);
}

/// An event fired while the Camera of a [mapId] moves.
class CameraMoveEvent extends MapEvent<CameraPosition> {
/// Build a CameraMove Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [CameraPosition] object with the current position of the Camera.
CameraMoveEvent(int mapId, CameraPosition position) : super(mapId, position);
}

/// An event fired when the Camera of a [mapId] becomes idle.
class CameraIdleEvent extends MapEvent<void> {
/// Build a CameraIdle Event triggered from the map represented by `mapId`.
CameraIdleEvent(int mapId) : super(mapId, null);
}

/// An event fired when a [Marker] is tapped.
class MarkerTapEvent extends MapEvent<MarkerId> {
/// Build a MarkerTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [MarkerId] object that represents the tapped Marker.
MarkerTapEvent(int mapId, MarkerId markerId) : super(mapId, markerId);
}

/// An event fired when an [InfoWindow] is tapped.
class InfoWindowTapEvent extends MapEvent<MarkerId> {
/// Build an InfoWindowTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [MarkerId] object that represents the tapped InfoWindow.
InfoWindowTapEvent(int mapId, MarkerId markerId) : super(mapId, markerId);
}

/// An event fired when a [Marker] is dragged to a new [LatLng].
class MarkerDragEndEvent extends _PositionedMapEvent<MarkerId> {
/// Build a MarkerDragEnd Event triggered from the map represented by `mapId`.
///
/// The `position` on this event is the [LatLng] on which the Marker was dropped.
/// The `value` of this event is a [MarkerId] object that represents the moved Marker.
MarkerDragEndEvent(int mapId, LatLng position, MarkerId markerId)
: super(mapId, position, markerId);
}

/// An event fired when a [Polyline] is tapped.
class PolylineTapEvent extends MapEvent<PolylineId> {
/// Build an PolylineTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [PolylineId] object that represents the tapped Polyline.
PolylineTapEvent(int mapId, PolylineId polylineId) : super(mapId, polylineId);
}

/// An event fired when a [Polygon] is tapped.
class PolygonTapEvent extends MapEvent<PolygonId> {
/// Build an PolygonTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [PolygonId] object that represents the tapped Polygon.
PolygonTapEvent(int mapId, PolygonId polygonId) : super(mapId, polygonId);
}

/// An event fired when a [Circle] is tapped.
class CircleTapEvent extends MapEvent<CircleId> {
/// Build an CircleTap Event triggered from the map represented by `mapId`.
///
/// The `value` of this event is a [CircleId] object that represents the tapped Circle.
CircleTapEvent(int mapId, CircleId circleId) : super(mapId, circleId);
}

/// An event fired when a Map is tapped.
class MapTapEvent extends _PositionedMapEvent<void> {
/// Build an MapTap Event triggered from the map represented by `mapId`.
///
/// The `position` of this event is the LatLng where the Map was tapped.
MapTapEvent(int mapId, LatLng position) : super(mapId, position, null);
}

/// An event fired when a Map is long pressed.
class MapLongPressEvent extends _PositionedMapEvent<void> {
/// Build an MapTap Event triggered from the map represented by `mapId`.
///
/// The `position` of this event is the LatLng where the Map was long pressed.
MapLongPressEvent(int mapId, LatLng position) : super(mapId, position, null);
}
Loading