Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@iskakaushik
Copy link
Contributor

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

if (_nightMode) {
setState(() {
_nightMode = false;
_controller.setMapStyle(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can _controller be null here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is only called from _nightModeToggler where we first check for _isMapCreated which is set alongside with _controller.

}

- (BOOL)setMapStyle:(NSString*)mapStyle {
if (mapStyle == (id)[NSNull null] || mapStyle.length == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't seem to cast to (id) elsewhere, do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an IDE warning about comparison between incompatible pointer types, we could either cast it to (NSString*) or (id) to address that and I chose the latter. It shouldn't be a big deal if we choose to remove the cast but seems reasonable to leave it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally reasonable was just wondering why this is different from the other similar checks in this file. Taking another look I guess it's because the other instances here are access NSArray elements.

return YES;
}
NSError* error;
GMSMapStyle* style = [GMSMapStyle styleWithJSONString:mapStyle error:&error];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any useful information in error we should send back to Dart?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error has some more details about what the issue with the JSON is. Though it is useful to know what the error is for fixing the style, I don't think we can take any action based on the specifics of the error on the dart side in this case.

Typical action on error would be to keep the existing style (which is the default) or change to an empty/alternate style, which the user can currently do by checking the return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass back whatever information we have to the Dart side. e.g it's possible that I'm building an app for editing and previewing map styles, in which case I would even want to show the error to the user.

/// feature type, unrecognized element type, or invalid styler keys. If the return
/// value is `false`, the current style is left unchanged.
///
/// The style string can be generated using https://mapstyle.withgoogle.com/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any documentation for the json format we can refer to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @domesticmouse , will add these to the docs.

@iskakaushik
Copy link
Contributor Author

landing after a verbal LGTM from @amirh 👍

@iskakaushik iskakaushik merged commit 7c9e79d into flutter:master Jun 5, 2019
@iskakaushik iskakaushik deleted the feature/map-styles branch June 5, 2019 20:03
@pedromassango
Copy link
Member

Is there any date to publish a new version with this changes?

@iskakaushik
Copy link
Contributor Author

@pedromassango it's published 0.5.16

@loint
Copy link

loint commented Jun 8, 2019

Thanks for great improvement guys

@nephix
Copy link

nephix commented Jun 12, 2019

Is there any documentation on how to use this?

@iskakaushik
Copy link
Contributor Author

@nephix the dart docs on the method over at https://github.com/flutter/plugins/pull/1697/files#diff-41940e5867e958815f51ef18747727edR189 should answer most questions, also look at the example app for how this is used.

@BoLindJensen
Copy link

is it intended behavior that you can only style the "normal" map?

mapType: MapType.hybrid, // No styling applied. :(
mapType: MapType.satellite, // No labels or markers is used, no styling can be applied :(
mapType: MapType.normal, // Styling is used. :)
mapType: MapType.terrain, // No styling applied. :(

Or am I doing something wrong?

@ventr1x

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Google Map Plugin] Need to apply customized style

9 participants