diff --git a/lib/src/web/interop/interop.dart b/lib/src/web/interop/interop.dart index b5b373f9..b3256af3 100644 --- a/lib/src/web/interop/interop.dart +++ b/lib/src/web/interop/interop.dart @@ -6,10 +6,10 @@ import 'dart:js_interop'; import 'package:maplibre/maplibre.dart'; import 'package:web/web.dart'; -part 'annotations.dart'; part 'camera.dart'; part 'controls.dart'; part 'events.dart'; +part 'marker.dart'; part 'map.dart'; /// A simple x/y [Point] class for JavaScript. @@ -22,3 +22,40 @@ extension type Point._(JSObject _) implements JSObject { external num x; external num y; } + +/// A coordinate object +@anonymous +@JS() +extension type LngLat._(JSObject _) implements JSObject { + /// Create a new [LngLat] coordinates object. + external factory LngLat({ + required num lng, + required num lat, + }); + + /// Create a new JS [LngLat] object from a [Position]. + factory LngLat.fromPosition(Position p) => LngLat(lng: p.lng, lat: p.lat); + + external num lng; + external num lat; + + /// Convert the JS [LngLat] object to a dart [Position] object. + Position toPosition() => Position(lng, lat); +} + +/// A [LngLatBounds] object represents a geographical bounding box, +/// defined by its southwest and northeast points in longitude and latitude. +@JS() +extension type LngLatBounds._(JSObject _) implements JSObject { + /// Returns the west edge of the bounding box. + external num getWest(); + + /// Returns the south edge of the bounding box. + external num getSouth(); + + /// Returns the east edge of the bounding box. + external num getEast(); + + /// Returns the north edge of the bounding box. + external num getNorth(); +} \ No newline at end of file diff --git a/lib/src/web/interop/map.dart b/lib/src/web/interop/map.dart index d382bd45..6e16d5f5 100644 --- a/lib/src/web/interop/map.dart +++ b/lib/src/web/interop/map.dart @@ -79,43 +79,6 @@ extension type MapOptions._(JSObject _) implements JSObject { }); } -/// A coordinate object -@anonymous -@JS() -extension type LngLat._(JSObject _) implements JSObject { - /// Create a new [LngLat] coordinates object. - external factory LngLat({ - required num lng, - required num lat, - }); - - /// Create a new JS [LngLat] object from a [Position]. - factory LngLat.fromPosition(Position p) => LngLat(lng: p.lng, lat: p.lat); - - external num lng; - external num lat; - - /// Convert the JS [LngLat] object to a dart [Position] object. - Position toPosition() => Position(lng, lat); -} - -/// A [LngLatBounds] object represents a geographical bounding box, -/// defined by its southwest and northeast points in longitude and latitude. -@JS() -extension type LngLatBounds._(JSObject _) implements JSObject { - /// Returns the west edge of the bounding box. - external num getWest(); - - /// Returns the south edge of the bounding box. - external num getSouth(); - - /// Returns the east edge of the bounding box. - external num getEast(); - - /// Returns the north edge of the bounding box. - external num getNorth(); -} - /// Options to specify the map bounds. @anonymous @JS() diff --git a/lib/src/web/interop/annotations.dart b/lib/src/web/interop/marker.dart similarity index 92% rename from lib/src/web/interop/annotations.dart rename to lib/src/web/interop/marker.dart index 1e292525..6a511a1b 100644 --- a/lib/src/web/interop/annotations.dart +++ b/lib/src/web/interop/marker.dart @@ -2,7 +2,7 @@ part of 'interop.dart'; /// https://maplibre.org/maplibre-gl-js/docs/API/classes/Marker/ @JS() -extension type Marker._(IControl _) implements IControl { +extension type Marker._(JSObject _) implements JSObject { /// Create a new JS [Marker] object. external Marker([MarkerOptions? options]);