Skip to content

Commit aa81d55

Browse files
committed
Adjust heights of map to different watches
1 parent 3a9d8a4 commit aa81d55

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

service/assistant/query/query.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ func ScreenWidthFromContext(ctx context.Context) int {
137137
return ctx.Value(queryContextKey).(queryContext).screenWidth
138138
}
139139

140+
func ScreenHeightFromContext(ctx context.Context) int {
141+
return ctx.Value(queryContextKey).(queryContext).screenHeight
142+
}
143+
140144
func ContextWithThread(ctx context.Context, threadContext *persistence.ThreadContext) context.Context {
141145
qc := ctx.Value(queryContextKey).(queryContext)
142146
qc.threadContext = threadContext

service/assistant/widgets/map.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,22 @@ func generateMap(ctx context.Context, markers map[string]util.Coords, userLocati
233233
}
234234

235235
screenWidth := query.ScreenWidthFromContext(ctx)
236+
screenHeight := query.ScreenHeightFromContext(ctx)
236237
if screenWidth == 0 {
237238
screenWidth = 144
238239
}
240+
241+
widgetHeight := 100
242+
if screenWidth >= 168 {
243+
widgetHeight = 140
244+
}
245+
// Assuming that screen with equal width and height is round
246+
if screenWidth == screenHeight {
247+
widgetHeight = screenHeight
248+
}
249+
239250
request := gmaps.StaticMapRequest{
240-
Size: fmt.Sprintf("%dx100", screenWidth),
251+
Size: fmt.Sprintf("%dx%d", screenWidth, widgetHeight),
241252
Format: "png8",
242253
MapType: "roadmap",
243254
MapId: config.GetConfig().GoogleMapsStaticMapId,

0 commit comments

Comments
 (0)