-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGpsWidget.bbj
147 lines (114 loc) · 4.26 KB
/
GpsWidget.bbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
use ::BBjWidget/BBjWidget.bbj::BBjWidget
use com.basiscomponents.db.constants.SimpleConstantsResolver
use java.io.File
use java.util.HashMap
class public GpsWidget extends BBjWidget
field public BBjString GoogleApiKey$
field private Double lat!
field private Double long!
field private Double centerLat!
field private Double centerLong!
field public BBjString message! = ""
field private BBjString pushUrl!
field private BBjString url!
field private BBjChildWindow window!
field private BBjHtmlView htmlView!
method public GpsWidget(BBjWindow wnd!)
#super!.create(wnd!, wnd!.getAvailableControlID())
methodend
method public void redraw(Boolean init!)
if !init! then methodret
#window! = #getCanvas()
#htmlView! = #window!.addHtmlView(#window!.getAvailableControlID(),0,0,0,0,"")
#htmlView!.setAttribute("gpsid","1421515")
#htmlView!.setCallback(BBjAPI.ON_NATIVE_JAVASCRIPT,#this!,"onHTMLJavaScript")
methodend
method public void loadMap()
declare SimpleConstantsResolver resolver!
centerLatString! = "null"
if #centerLat! = null() then
#centerLat! = #lat!
endif
centerLatString! = str(#centerLat!:"-##.#################")
centerLongString! = "null"
if #centerLong! = null() then
#centerLong! = #long!
endif
centerLongString! = str(#centerLong!:"-##.#################")
latitudeString! = "null"
if #lat! <> null() then
latitudeString! = str(#lat!:"-##.#################")
endif
longitudeString! = "null"
if #long! <> null() then
longitudeString! = str(#long!:"-##.#################")
endif
if #GoogleApiKey$>"" then
apikey$="key="+#GoogleApiKey$+"&"
fi
resolver! = new SimpleConstantsResolver()
resolver!.put("centerLatString",centerLatString!)
resolver!.put("centerLongString",centerLongString!)
resolver!.put("latitudeString",latitudeString!)
resolver!.put("longitudeString",longitudeString!)
resolver!.put("message",#message!)
resolver!.put("apikey",apikey$)
#pushUrl! = ::BBUtils.bbj::BBUtils.copyFileToWebServer("BBjGpsLocation/src/push.js","","",0)
ch = unt
open(ch)"BBjGpsLocation/res/maps.html"
while 1
read record (ch,siz=1024,err=*break) line$
html$ = html$ + line$
wend
close(ch)
resolver!.put("path",#pushUrl!)
html$ = resolver!.resolveConstants(html$)
file!=java.io.File.createTempFile("temp-file-name", ".html", new File(System.getProperty("java.io.tmpdir")))
file$ = file!.getAbsolutePath()
file!.delete()
open (ch,mode="O_CREATE,O_TRUNC")file$
write (ch)html$
close (ch)
#url! = ::BBUtils.bbj::BBUtils.copyFileToWebServer(file$,"","",0)
#htmlView!.setUrl(#url!)
#htmlView!.setStyle("width","100%")
#htmlView!.setStyle("height","100%")
methodend
method public void cleanUp()
utils! = new ::BBUtils.bbj::BBUtils()
utils!.deleteFromWebServer(#url!)
utils!.deleteFromWebServer(#pushUrl!)
methodend
method public void onHTMLJavaScript(BBjNativeJavaScriptEvent ev!)
declare HashMap buffer!
buffer! = ev!.getEventMap()
#lat! = Double.valueOf(str(buffer!.get("lat")))
#long! = Double.valueOf(str(buffer!.get("long")))
methodend
method public void setLocation(Double lat!, Double long!)
#lat! = lat!
#long! = long!
methodend
method public void setCenter(Double lat!, Double long!)
#centerLat! = lat!
#centerLong! = long!
methodend
method public void setMessage(String message!)
#message! = message!
methodend
method public void setIcon(BBjImage image!)
#windowIcon! = image!
methodend
method public void setIcon(String path!)
#windowIconPath! = path!
methodend
method public Double getLatitude()
methodret #lat!
methodend
method public Double getLongitude()
methodret #long!
methodend
method public BBjChildWindow getCanvas()
methodret #super!.getCanvas()
methodend
classend