|
@@ -1,7 +1,49 @@
|
1
|
|
-Module YandexLocation
|
|
1
|
+Imports System.Net
|
|
2
|
+Imports Newtonsoft
|
|
3
|
+Imports Newtonsoft.Json.Linq
|
2
|
4
|
|
3
|
|
- Sub Main()
|
|
5
|
+Module YandexLocation
|
4
|
6
|
|
5
|
|
- End Sub
|
|
7
|
+ Public Class YandexLocatin
|
|
8
|
+
|
|
9
|
+ Dim adres As String
|
|
10
|
+ Dim respone As String
|
|
11
|
+ Dim Coordinates As String
|
|
12
|
+
|
|
13
|
+ Sub New(adres As String)
|
|
14
|
+ Me.adres = adres
|
|
15
|
+ Using WebClient = New WebClient
|
|
16
|
+ WebClient.Encoding = System.Text.Encoding.UTF8
|
|
17
|
+ Me.respone = WebClient.DownloadString("https://geocode-maps.yandex.ru/1.x/?format=json&geocode=" + Replace_Adres())
|
|
18
|
+ End Using
|
|
19
|
+ JSONDECODE()
|
|
20
|
+ End Sub
|
|
21
|
+
|
|
22
|
+ Private Function Replace_Adres()
|
|
23
|
+ Dim url_adres As String = Replace(adres, " ", "+")
|
|
24
|
+ Return url_adres
|
|
25
|
+ End Function
|
|
26
|
+ Private Sub JSONDECODE()
|
|
27
|
+ Dim MyJson As JObject = Json.JsonConvert.DeserializeObject(respone)
|
|
28
|
+ '[JSON].response.GeoObjectCollection.featureMember.[0].GeoObject.Point.pos
|
|
29
|
+ Coordinates = MyJson("response")("GeoObjectCollection")("featureMember")(0)("GeoObject")("Point")("pos")
|
|
30
|
+ End Sub
|
6
|
31
|
|
|
32
|
+ Public Function lat()
|
|
33
|
+ Dim cord As Array = Split(Coordinates, " ")
|
|
34
|
+ Dim l1 As Double = Convert.ToDouble(cord(1))
|
|
35
|
+ Return l1
|
|
36
|
+ End Function
|
|
37
|
+
|
|
38
|
+ Public Function lng()
|
|
39
|
+ Dim cord As Array = Split(Coordinates, " ")
|
|
40
|
+ Dim l1 As Double = Convert.ToDouble(cord(0))
|
|
41
|
+ Return l1
|
|
42
|
+ End Function
|
|
43
|
+ End Class
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+ Sub Main()
|
|
47
|
+ Dim loc As YandexLocatin = New YandexLocatin("4-ый Загородный переулок, дом 20, Минск, Беларусь")
|
|
48
|
+ End Sub
|
7
|
49
|
End Module
|