Fix Function · 5ed9e593bd - SVN.BY: Go Git Service
British Petrolium пре 9 година
родитељ
комит
5ed9e593bd
1 измењених фајлова са 20 додато и 12 уклоњено
  1. 20 12
      YandexLocation.vb

+ 20 - 12
YandexLocation.vb

25
         End Function
25
         End Function
26
         Private Sub JSONDECODE()
26
         Private Sub JSONDECODE()
27
             Dim MyJson As JObject = Json.JsonConvert.DeserializeObject(respone)
27
             Dim MyJson As JObject = Json.JsonConvert.DeserializeObject(respone)
28
+            '[JSON].response.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData.results
28
             '[JSON].response.GeoObjectCollection.featureMember.[0].GeoObject.Point.pos
29
             '[JSON].response.GeoObjectCollection.featureMember.[0].GeoObject.Point.pos
29
-            Coordinates = MyJson("response")("GeoObjectCollection")("featureMember")(0)("GeoObject")("Point")("pos")
30
+            If MyJson("response")("GeoObjectCollection")("metaDataProperty")("GeocoderResponseMetaData")("results").ToString = "0" Then
31
+                Coordinates = Nothing
32
+            Else
33
+                Coordinates = MyJson("response")("GeoObjectCollection")("featureMember")(0)("GeoObject")("Point")("pos")
34
+            End If
30
         End Sub
35
         End Sub
31
 
36
 
32
         Public Function lat()
37
         Public Function lat()
33
-            Dim cord As Array = Split(Coordinates, " ")
34
-            Dim l1 As Double = Convert.ToDouble(cord(1))
35
-            Return l1
38
+            If Coordinates IsNot Nothing Then
39
+                Dim cord As Array = Split(Coordinates, " ")
40
+                Dim l1 As String = (cord(1))
41
+                Return l1
42
+            Else
43
+                Return ""
44
+            End If
36
         End Function
45
         End Function
37
 
46
 
38
         Public Function lng()
47
         Public Function lng()
39
-            Dim cord As Array = Split(Coordinates, " ")
40
-            Dim l1 As Double = Convert.ToDouble(cord(0))
41
-            Return l1
48
+            If Coordinates IsNot Nothing Then
49
+                Dim cord As Array = Split(Coordinates, " ")
50
+                Dim l1 As String = (cord(0))
51
+                Return l1
52
+            Else
53
+                Return ""
54
+            End If
42
         End Function
55
         End Function
43
     End Class
56
     End Class
44
-
45
-
46
-    Sub Main()
47
-        Dim loc As YandexLocatin = New YandexLocatin("4-ый Загородный переулок, дом 20, Минск, Беларусь")
48
-    End Sub
49
 End Module
57
 End Module