w3c / geolocation

W3C Geolocation API
https://www.w3.org/TR/geolocation/
81 stars 56 forks source link

Add support for converting Geolocation Position+Coordinates to JSON (object) #145

Closed marcoscaceres closed 5 months ago

marcoscaceres commented 6 months ago

Given GeolocationCoordinates are just nullable doubles, it would be nice if GeolocationCoordinates exposed a (WebIDL) default .toJSON() method.

reillyeon commented 6 months ago

That would be nice given that JSON.stringify() does not work on GeolocationCoordinates.

marcoscaceres commented 5 months ago

Another question is if we should also add a toJSON() method on GeolocationPosition? I don't know if there is much value to getting the timestamp...

reillyeon commented 5 months ago

Less value but it would still feel weird if you could stringify the coordinates but not the full object passed to your callback so I say yes, let's add a toJSON() method to both interfaces.

marcoscaceres commented 5 months ago

Sounds good.