map change to naver

main
syneffort 2 years ago
parent 46000134f6
commit 10bf898496
  1. 19
      PacticeSolution/MapFinder/MainWindow.xaml
  2. 40
      PacticeSolution/MapFinder/MainWindow.xaml.cs
  3. 1
      PacticeSolution/MapFinder/MapFinder.csproj

@ -5,16 +5,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MapFinder" xmlns:local="clr-namespace:MapFinder"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="Map Finder" Height="450" Width="800"
Loaded="Window_Loaded">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="150"/>
<ColumnDefinition Width="8*"/> <ColumnDefinition Width="300"/>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" <TextBlock Grid.Column="0"
@ -37,10 +38,14 @@
Background="Cyan" Background="Cyan"
Grid.Row="1" Grid.Row="1"
SelectionChanged="lbxFound_SelectionChanged"/> SelectionChanged="lbxFound_SelectionChanged"/>
<WebBrowser x:Name="wbMain" <!--<WebBrowser x:Name="wbMain"
Source="https://map.kakao.com" Source="https://map.kakao.com"
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Grid.ColumnSpan="3"/> Grid.ColumnSpan="3"/>-->
<WindowsFormsHost Name="wfhWebBrowser"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="3"/>
</Grid> </Grid>
</Window> </Window>

@ -1,5 +1,6 @@
using MapFinder.Data; using MapFinder.Data;
using MapFinder.Utility; using MapFinder.Utility;
using Microsoft.VisualBasic.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -9,7 +10,9 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
@ -22,10 +25,28 @@ namespace MapFinder
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
System.Windows.Forms.WebBrowser _webBrowser;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
InitInstance();
}
private void InitInstance()
{
_webBrowser = new System.Windows.Forms.WebBrowser();
wfhWebBrowser.Child = _webBrowser;
_webBrowser.ScriptErrorsSuppressed = true;
_webBrowser.Navigate("https://map.naver.com/");
}
private double[] ConvertToEPSG3857(double lat, double lng)
{
var x = (lng * 20037508.34) / 180;
var y = Math.Log(Math.Tan(((90 + lat) * Math.PI) / 360)) / (Math.PI / 180);
y = (y * 20037508.34) / 180;
return new double[] { x, y };
} }
private void btnFind_Click(object sender, RoutedEventArgs e) private void btnFind_Click(object sender, RoutedEventArgs e)
@ -43,8 +64,23 @@ namespace MapFinder
if (selected == null) if (selected == null)
return; return;
Uri uri = new Uri($"https://map.kakao.com/link/map/{selected.Name},{selected.Lat},{selected.Lng}"); double[] epsg3857 = ConvertToEPSG3857(selected.Lat, selected.Lng);
wbMain.Source = uri; string url = $"http://map.naver.com/v5/search?c={epsg3857[0]},{epsg3857[1]},{18},0,0,0,dh";
//string url = $"https://google.co.kr/maps/@{selected.Lat},{selected.Lng},11z";
//string url = $"https://map.kakao.com/link/map/{selected.Name},{selected.Lat},{selected.Lng}";
//Uri uri = new Uri(url);
//wbMain.Source = uri;
_webBrowser.Navigate(url);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//System.Windows.Forms.WebBrowser webBrowser = new System.Windows.Forms.WebBrowser();
//webBrowser.ScriptErrorsSuppressed = true;
//wfhWebBrowser.Child = webBrowser;
//webBrowser.Navigate("https://map.kakao.com");
} }
} }
} }

@ -5,6 +5,7 @@
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Loading…
Cancel
Save