-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: standalone classic mapview (#181)
* feat: implementing separate google map view on flutter side wip * feat: map view ios separation and example app page wip * feat: map view android separation wip * fix: fix tests and format * fix: flutter analyze fix * feature: example app multiple map page supports now non-navigation map * docs: update readme for non-navigation map view * fix: remove navigation variables and references from map view files * docs: update dart doc * refactor: listener and map view refactoring * refactor: navigation viewcontroller now extends map viewcontroller in flutter * refactor: android redundant function removal * fix: general fixes and refactoring * refactor: android base map view refactoring * test: update integration tests for regular google map view * refactor: refactor tests and view handling * refactor: refactoring and minor fixes * test: refactor integration tests
- Loading branch information
1 parent
8f0283f
commit e85f590
Showing
53 changed files
with
5,338 additions
and
4,247 deletions.
There are no files selected for viewing
This file contains 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
83 changes: 83 additions & 0 deletions
83
android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt
This file contains 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,83 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.maps.flutter.navigation | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import com.google.android.gms.maps.GoogleMapOptions | ||
import com.google.android.gms.maps.MapView | ||
import io.flutter.plugin.platform.PlatformView | ||
|
||
class GoogleMapView | ||
internal constructor( | ||
context: Context, | ||
mapOptions: GoogleMapOptions, | ||
viewId: Int, | ||
viewEventApi: ViewEventApi, | ||
private val viewRegistry: GoogleMapsViewRegistry, | ||
imageRegistry: ImageRegistry | ||
) : PlatformView, GoogleMapsBaseMapView(viewId, mapOptions, viewEventApi, imageRegistry) { | ||
private val _mapView: MapView = MapView(context, mapOptions) | ||
|
||
override fun getView(): View { | ||
return _mapView | ||
} | ||
|
||
init { | ||
// Call all of these three lifecycle functions in sequence to fully | ||
// initialize the map view. | ||
_mapView.onCreate(context.applicationInfo.metaData) | ||
_mapView.onStart() | ||
_mapView.onResume() | ||
|
||
_mapView.getMapAsync { map -> | ||
setMap(map) | ||
initListeners() | ||
imageRegistry.mapViewInitializationComplete() | ||
mapReady() | ||
invalidateViewAfterMapLoad() | ||
} | ||
|
||
viewRegistry.registerMapView(viewId, this) | ||
} | ||
|
||
override fun dispose() { | ||
// When view is disposed, all of these lifecycle functions must be | ||
// called to properly dispose navigation view and prevent leaks. | ||
_mapView.onPause() | ||
_mapView.onStop() | ||
_mapView.onDestroy() | ||
|
||
viewRegistry.unregisterMapView(viewId) | ||
} | ||
|
||
override fun onStart() { | ||
_mapView.onStart() | ||
} | ||
|
||
override fun onResume() { | ||
_mapView.onResume() | ||
} | ||
|
||
override fun onStop() { | ||
_mapView.onStop() | ||
} | ||
|
||
override fun onPause() { | ||
_mapView.onPause() | ||
} | ||
} |
Oops, something went wrong.