google-map icon indicating copy to clipboard operation
google-map copied to clipboard

Allow search with lat/lon null

Open tst-dhudlow opened this issue 9 years ago • 6 comments

See #284

tst-dhudlow avatar Apr 28 '16 19:04 tst-dhudlow

LGTM. Mind writing a test?

ebidel avatar Apr 28 '16 20:04 ebidel

I think it would be better if the code never throws. It should just ignore invalid values (maybe output something in the console).

ukabu avatar Jun 10 '16 00:06 ukabu

@ukabu While outputting something in the console would be okay, I think throwing is a better way to ensure clarity upon failure and allow an application to catch and deal with the error, which could go back to user input, without having to test for the problem.

Regardless, I'm not going to change the precedent here.

tst-dhudlow avatar Jun 20 '16 20:06 tst-dhudlow

The problem is that the throw happens for the wrong reason. If the longitude is not set (initial state) and then you set the latitude, it is going to throw with invalid longitude (it's still null).

This happens if you set the lat and lon using the geo-location web component. Initially, the lat and lon are null. When you get the geo-location, the latitude is set first which cause the throw before the longitude has any chance of being set.

If any throw should occur, it should be in the setter of the specific property instead and validate only that property. It should not be in the _updateLocation function.

ukabu avatar Jun 20 '16 22:06 ukabu

The location is set via a single lat/lon object and the listener for that object doesn't look at the fields. As such, it shouldn't be hard to avoid a state where latitude is set and longitude isn't.

EDIT: I take it back, the location field can't be used for setting, so yeah, having it throw because you trigger a binding with this.latitude = value.y; this.longitude = value.x; is super annoying. Perhaps the && should simply be changed to an ||? I still don't think we should allow any falsey value.

tst-dhudlow avatar Jun 21 '16 11:06 tst-dhudlow

Hmm, I'm trying to write tests for this, but it seems tests that do certain processing trip the new key requirement and fail on an InvalidKeyMapError. Any suggestions on that?

tst-dhudlow avatar Jun 29 '16 20:06 tst-dhudlow