diff --git a/lib/kino/maplibre.ex b/lib/kino/maplibre.ex index 5a85484..47a4289 100644 --- a/lib/kino/maplibre.ex +++ b/lib/kino/maplibre.ex @@ -198,11 +198,11 @@ defmodule Kino.MapLibre do ## Examples - Kino.MapLibre.add_locate(map) - Kino.MapLibre.add_locate(map, high_accuracy: true, track_user_location: true) + Kino.MapLibre.add_locate_control(map) + Kino.MapLibre.add_locate_control(map, high_accuracy: true, track_user_location: true) """ - @spec add_locate(maplibre(), keyword()) :: :ok | %__MODULE__{} - def add_locate(map, opts \\ []) do + @spec add_locate_control(maplibre(), keyword()) :: :ok | %__MODULE__{} + def add_locate_control(map, opts \\ []) do {high_accuracy, opts} = Keyword.pop(opts, :high_accuracy, false) locate = %{high_accuracy: high_accuracy, options: normalize_opts(opts)} update_events(map, :locate, locate) @@ -213,10 +213,10 @@ defmodule Kino.MapLibre do ## Examples - Kino.MapLibre.add_terrain(map) + Kino.MapLibre.add_terrain_control(map) """ - @spec add_terrain(maplibre()) :: :ok | %__MODULE__{} - def add_terrain(map) do + @spec add_terrain_control(maplibre()) :: :ok | %__MODULE__{} + def add_terrain_control(map) do update_events(map, :terrain, %{}) end @@ -225,10 +225,10 @@ defmodule Kino.MapLibre do ## Examples - Kino.MapLibre.add_geocode(map) + Kino.MapLibre.add_geocode_control(map) """ - @spec add_geocode(maplibre()) :: :ok | %__MODULE__{} - def add_geocode(map) do + @spec add_geocode_control(maplibre()) :: :ok | %__MODULE__{} + def add_geocode_control(map) do update_events(map, :geocode, %{}) end diff --git a/test/kino/maplibre_test.exs b/test/kino/maplibre_test.exs index eba1d46..af86de1 100644 --- a/test/kino/maplibre_test.exs +++ b/test/kino/maplibre_test.exs @@ -184,15 +184,15 @@ defmodule Kino.MapLibreTest do end end - describe "add_locate/2" do + describe "add_locate_control/2" do test "adds a geolocate control to a static map" do - ml = Ml.new() |> Kino.MapLibre.add_locate() + ml = Ml.new() |> Kino.MapLibre.add_locate_control() assert ml.events.locate == [%{options: %{}, high_accuracy: false}] end test "adds a geolocate control to a dynamic map" do ml = Ml.new() |> Kino.MapLibre.new() - Kino.MapLibre.add_locate(ml, high_accuracy: true) + Kino.MapLibre.add_locate_control(ml, high_accuracy: true) data = connect(ml) assert data.events.locate == [%{high_accuracy: true, options: %{}}] @@ -201,8 +201,10 @@ defmodule Kino.MapLibreTest do end test "adds a geolocate control to a converted map" do - ml = Ml.new() |> Kino.MapLibre.add_locate(high_accuracy: true) |> Kino.MapLibre.new() - Kino.MapLibre.add_locate(ml, track_user_location: true) + ml = + Ml.new() |> Kino.MapLibre.add_locate_control(high_accuracy: true) |> Kino.MapLibre.new() + + Kino.MapLibre.add_locate_control(ml, track_user_location: true) data = connect(ml) assert data.events.locate == [ @@ -217,15 +219,15 @@ defmodule Kino.MapLibreTest do end end - describe "add_terrain/1" do + describe "add_terrain_control/1" do test "adds a terrain control to a static map" do - ml = Ml.new() |> Kino.MapLibre.add_terrain() + ml = Ml.new() |> Kino.MapLibre.add_terrain_control() assert ml.events.terrain == [%{}] end test "adds a terrain control to a dynamic map" do ml = Ml.new() |> Kino.MapLibre.new() - Kino.MapLibre.add_terrain(ml) + Kino.MapLibre.add_terrain_control(ml) data = connect(ml) assert data.events.terrain == [%{}] @@ -234,8 +236,8 @@ defmodule Kino.MapLibreTest do end test "adds a terrain control to a converted map" do - ml = Ml.new() |> Kino.MapLibre.add_terrain() |> Kino.MapLibre.new() - Kino.MapLibre.add_terrain(ml) + ml = Ml.new() |> Kino.MapLibre.add_terrain_control() |> Kino.MapLibre.new() + Kino.MapLibre.add_terrain_control(ml) data = connect(ml) assert data.events.terrain == [%{}, %{}] @@ -244,15 +246,15 @@ defmodule Kino.MapLibreTest do end end - describe "add_geocode/1" do + describe "add_geocode_control/1" do test "adds a geocode control to a static map" do - ml = Ml.new() |> Kino.MapLibre.add_geocode() + ml = Ml.new() |> Kino.MapLibre.add_geocode_control() assert ml.events.geocode == [%{}] end test "adds a geocode control to a dynamic map" do ml = Ml.new() |> Kino.MapLibre.new() - Kino.MapLibre.add_geocode(ml) + Kino.MapLibre.add_geocode_control(ml) data = connect(ml) assert data.events.geocode == [%{}] @@ -261,8 +263,8 @@ defmodule Kino.MapLibreTest do end test "adds a geocode control to a converted map" do - ml = Ml.new() |> Kino.MapLibre.add_geocode() |> Kino.MapLibre.new() - Kino.MapLibre.add_geocode(ml) + ml = Ml.new() |> Kino.MapLibre.add_geocode_control() |> Kino.MapLibre.new() + Kino.MapLibre.add_geocode_control(ml) data = connect(ml) assert data.events.geocode == [%{}, %{}]