Have you ever seen the high technology in movies? When the military is searching for terrorists, it often uses satellite positioning or mobile phone signals to locate their precise geographic location. Now it uses interfaces provided by Google Earth and Google Maps, you can also implement this function. The error distance is no more than 20 meters (depending on the GPS level)
First, you need to install Google Earth and ensure that the network is smooth. To ensure that the refresh frequency is not too high, we use timer to regularly refresh the page for 10 s.
The final result is displayed. For details about GPS instructions, refer to relevant information.
Public class form1
Dim Buf as string
Dim txtbuf (15) as string
Dim nsew as string
Dim appge as new earthlib. applicationge
Dim SGE as new earthlib. searchcontrollerge
Private sub form=formclosed (byval sender as object, byval e as system. Windows. Forms. formclosedeventargs) handles me. formclosed
End sub
Private sub form1_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
Me. serialport1.open ()
Me. checkforillegalcrossthreadcils = false
Buf = ""
Me. Show ()
Getgooglesnaphost ()
End sub
Private sub serialportincludatareceived (byval sender as object, byval e as system. Io. Ports. serialdatareceivedeventargs) handles serialport1.datareceived
On Error resume next
Me.txt Buf = nothing
Buf = Buf & CHR (Me. serialport1.readbyte)
If strings. Right (BUF, 2) = CHR (13) & CHR (10) then
If strings. Left (BUF, 6) = "$ gpgga" then
Txtbuf = strings. Split (BUF ,",")
Me. textbox1.text = me.txt Buf (1)
Me. textbox2.text = me.txt Buf (2)
Me. textbox3.text = me.txt Buf (3)
Me. textbox4.text = me.txt Buf (4)
Me. textbox5.text = me.txt Buf (5)
Me. textbox6.text = me.txt Buf (6)
Me. textbox7.text = me.txt Buf (7)
Me. textbox8.text = me.txt Buf (8)
Me. textbox9.text = me.txt Buf (9) & me.txt Buf (10)
Me. textbox10.text = me.txt Buf (11) & me.txt Buf (12)
If txtbuf (6) = "1" then
Nsew = me.getgoogleeartaddr(me.txt Buf (2), me.txt Buf (4 ))
Me. textbox11.text = nsew
End if
End if
Me. axiledroundx1.active = Not me. axiledroundx1.active
Buf = ""
Me. serialport1.close ()
Me. serialport1.open ()
End if
End sub
Public Function getgoogleeartaddr (byval opt1 as string, byval opt2 as string) as string
Dim dtmp (4) as double
Dtmp (0) = int (Val (OPS T1)/100)
Dtmp (1) = (Val (opt1)/100-dtmp (0) * 100/60
Dtmp (2) = int (Val (OPS 2)/100)
Dtmp (3) = (Val (opt2)/100-dtmp (2) * 100/60
Return dtmp (0) + dtmp (1) & "," & dtmp (2) + dtmp (3)
End Function
Public sub getgooglesnaphost ()
Me. appge. savescreenshot ("F:/googlemapstmp.jpg", 100)
While not Io. file. exists ("F:/googlemapstmp.jpg ")
Application. doevents ()
End while
For I = 0 to 1000
Application. doevents ()
Next
Dim IMG as image
Dim bufdata () as byte
Bufdata = fileio. filesystem. readallbytes ("F:/googlemapstmp.jpg ")
Dim wo as new IO. memorystream (bufdata)
IMG = image. fromstream (WO)
Me. panel1.backgroundimage = img
End sub
Private sub timereffectick (byval sender as system. Object, byval e as system. eventargs) handles timer1.tick
Getgooglesnaphost ()
SGE. Search (Me. nsew)
Me. webbrowser1.navigate ("")
For I = 0 to 100
Application. doevents ()
Next
Me. webbrowser1.document. Write (Me. textbox12.text. Replace ("31.8063916666667, 121.660626666667", me. nsew ))
For I = 0 to 100
Application. doevents ()
Next
Me. webbrowser1.refresh ()
End sub
Private sub webbrowserappsdocumentcompleted (byval sender as system. Object, byval e as system. Windows. Forms. webbrowserdocumentcompletedeventargs)
End sub
Private sub timer2_tick (byval sender as system. Object, byval e as system. eventargs) handles timer2.tick
Me. progressbar1.value + = 10
If me. progressbar1.value = 100 then me. progressbar1.value = 0
End sub
End Class