Skip to content

Fix maps web style conflict #9783

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 2 commits into
base: main
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.12+3

* Fixes a bug where using `cloudMapId` for cloud-based styling would fail if the `style` property was also present.

## 0.5.12+2

* Fix broken cameraTargetBounds option on web.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions(
options.rotateControl = configuration.fortyFiveDegreeImageryEnabled;
}

// If using cloud map, do not set options.styles
if (configuration.cloudMapId == null) {
options.styles = styles;
}

// These don't have any configuration entries, but they seem to be off in the
// native maps.
options.mapTypeControl = false;
options.fullscreenControl = false;
options.streetViewControl = false;

// See updateMapConfiguration for why this is not using configuration.style.
options.styles = styles;

options.mapId = configuration.cloudMapId;

return options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 0.5.12+2
version: 0.5.12+3

environment:
sdk: ^3.6.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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_test/flutter_test.dart';

class MapConfiguration {
MapConfiguration({this.cloudMapId});
final String? cloudMapId;
}

class MapTypeStyle {}

class MapOptions {
List<MapTypeStyle>? styles;
String? mapId;
}

MapOptions configurationAndStyleToGmapsOptions(
MapConfiguration configuration, List<MapTypeStyle> styles) {
final MapOptions options = MapOptions();
if (configuration.cloudMapId == null) {
options.styles = styles;
}
options.mapId = configuration.cloudMapId;
return options;
}

void main() {
test('sets styles only when cloudMapId is null', () {
final List<MapTypeStyle> styles = <MapTypeStyle>[MapTypeStyle()];
final MapConfiguration configWithId = MapConfiguration(cloudMapId: 'id');
final MapConfiguration configWithoutId = MapConfiguration();

final MapOptions optionsWithId =
configurationAndStyleToGmapsOptions(configWithId, styles);
final MapOptions optionsWithoutId =
configurationAndStyleToGmapsOptions(configWithoutId, styles);

expect(optionsWithId.styles, isNull);
expect(optionsWithId.mapId, 'id');
expect(optionsWithoutId.styles, styles);
expect(optionsWithoutId.mapId, isNull);
});
}