Map marker click functionality

This commit is contained in:
Josh Deck 2024-05-13 13:59:51 -04:00
parent 65abab97b2
commit 48f6a54c6c
1 changed files with 54 additions and 27 deletions

View File

@ -188,9 +188,11 @@
public async void OnMarkerClick(MapMarkerClickEventArgs args)
{
var dataItem = args.DataItem as MarkerModel;
UpdateDrawer();
await ToggleDrawer();
CurrentSelection = dataItem.Title;
CurrentBlurb = dataItem.Blurb;
await ToggleModal();
Console.WriteLine(dataItem.Title);
}
@ -204,15 +206,15 @@
private void InitializeMapMarkers(double[] coords)
{
// Server call to load map markers into a list of tuples
// Server call to load map markers into a list of tuples
List<(double[], string)> localMarkers = MapDriver.InitializeMarkers(coords);
foreach (var current in localMarkers)
{
MapMarkers.Add(new MarkerModel()
{
MapMarkers.Add(new MarkerModel() {
LatLng = current.Item1,
Title = current.Item2
});
Title = current.Item2,
Blurb = string.Format("This is {0}'s blurb. This will be replaced when a lookup is created.", current.Item2)
});
}
}
@ -220,7 +222,9 @@
{
public double[] LatLng { get; set; } = [42.4649, -83.3684];
public string Title { get; set; } = "";
public string Blurb { get; set; } = "";
}
private class LocationDetails
{
public string ip { get; set; } = "";
@ -280,33 +284,56 @@
</div> <!-- Shop info pane-->
<div style="width: 1500px">
<TelerikDrawer @ref="@Drawer" Data="Data" MiniMode="false" Mode="@Mode" Position="@Position" Width="600px">
<DrawerContent>
</DrawerContent>
</TelerikDrawer>
<TelerikWindow Modal="true"
@bind-Visible="@isVisible"
CloseOnOverlayClick="true"
Width="600px"
Height="300px">
<WindowTitle>
@CurrentSelection
</WindowTitle>
<WindowContent>
@CurrentBlurb
<br /><br /><br />
<TelerikButton OnClick="@VisitClickHandler" Class="visit-button">
Visit Page
<style>
.visit-button {
position: absolute;
top: 75%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
margin: 0;
}
</style>
</TelerikButton>
</WindowContent>
<WindowActions>
<WindowAction Name="Close" />
</WindowActions>
</TelerikWindow>
</div>
<div> <!-- Shop info drawer C# -->
@code{
public TelerikDrawer<DrawerItem>? Drawer { get; set; }
public DrawerMode Mode { get; set; }
public IEnumerable<DrawerItem> Data { get; set; } = new List<DrawerItem>();
public DrawerPosition Position = DrawerPosition.End;
public class DrawerItem {
public string? Text { get; set; }
public ISvgIcon? Icon { get; set; }
public bool Separator { get; set; }
public TelerikPopover? Popover { get; set; }
public string CurrentSelection { get; set; } = "123412341234onetwothreefour";
public string CurrentBlurb { get; set; } = "This is a blurb for a shop. I believe it is rather dastardly.";
public bool isVisible = false;
public async Task ToggleModal()
{
if (isVisible)
isVisible = false;
else
isVisible = true;
await Task.Delay(1);
}
public void UpdateDrawer()
{
Data = new List<DrawerItem>
{
new DrawerItem { Text = "HelloWorld"},
new DrawerItem { Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
};
public void VisitClickHandler() {
Console.WriteLine("Visiting page" + CurrentSelection);
}
public async Task ToggleDrawer() => await Drawer.ToggleAsync();
}
</div>