Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MainUI] Map picker should center on location set in regional settings #2999

Open
rkoshak opened this issue Jan 9, 2025 · 12 comments · May be fixed by #3047
Open

[MainUI] Map picker should center on location set in regional settings #2999

rkoshak opened this issue Jan 9, 2025 · 12 comments · May be fixed by #3047
Labels
enhancement New feature or request main ui Main UI

Comments

@rkoshak
Copy link

rkoshak commented Jan 9, 2025

The problem

When the map picker first comes up to choose a lat/lon, it is fully zoomed out centered over Europe.

Your suggestion

It would be more user-friendly if the map picker used the location set in the regional settings (if it's set, current behavior is fine if not) and use a lot more zoomed in level. If a user is choosing a location for their home automation, they are likely wanting something reasonably close to home so something showing 100 mi/200 km (I know that's not the same) or so would be about right.

As a bonus, if it can remember where it was the last time it was used that would be nice. I just created a rule template that uses a location context. It's great that it lets users use the map picker but they need to pick two points and when opening the new map one needs to zoom and scroll all over again.

Your environment

runtimeInfo:
  version: 4.3.1
  buildString: Release Build
locale: en-US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 17.0.13
  javaVendor: Debian
  osName: Linux
  osVersion: 6.8.0-51-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 76209400
  totalMemory: 489684992
  uptime: 2746
  startLevel: 70
addons:
  - automation-jsscripting
  - automation-pidcontroller
  - binding-amazonechocontrol
  - binding-astro
  - binding-chromecast
  - binding-http
  - binding-ipcamera
  - binding-mail
  - binding-mqtt
  - binding-network
  - binding-networkupstools
  - binding-openweathermap
  - binding-shelly
  - binding-vesync
  - binding-zigbee
  - binding-zwave
  - misc-openhabcloud
  - persistence-mapdb
  - persistence-rrd4j
  - transformation-basicprofiles
  - transformation-jinja
  - transformation-jsonpath
  - transformation-map
  - transformation-regex
  - ui-basic
  - ui-habot
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    pixelRatio: 0.8999999761581421
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 16
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: Linux x86_64
  screen:
    width: 2560
    height: 1600
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
    blocklyRenderer: null
  userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
    Gecko) Chrome/131.0.0.0 Safari/537.36
timestamp: 2025-01-09T23:36:44.489Z

Additional information

@rkoshak rkoshak added enhancement New feature or request main ui Main UI labels Jan 9, 2025
@jimtng
Copy link
Contributor

jimtng commented Jan 29, 2025

Which map picker are you referring to? Can you show some screenshots + code to create/open the map picker?

@rkoshak
Copy link
Author

rkoshak commented Jan 29, 2025

If you create a widget, rule template, or any other config for a binding or a Channel with a property that has "location" as the context it brings up a Map to drop a pin at the location you want.

  - description: Starting point latitude,longitude 
    label: Start
    name: startPoint
    required: true
    type: TEXT
    context: location

A few examples from the marketplace:

When presented on the form it appears as:

Image

Clicking on "Map" on the right side brings up the following on a desktop:

Image

Interestingly, when I opened this issue the map was more zoomed out than shown so something must have changed, or I'm completely remembering wrong. But the issue still remains that I need to zoom back out, recenter, then zoom back in recentering on each zoom to get the map scaled and centered on a region I actually care about..

And then if you have two locations you have to do it all over again because the map doesn't remember what you did when you picked the first location.

We set a location for our home in the regional settings so theoretically that information should be available to center these maps on instead of centering on northeast France. It can come up zoomed in more too because most users are probably not going to care about seeing the whole continent for what ever they are doing. they probably care most about the city, maybe the region/provence/state.

Does this make sense? I can try to capture a video if it helps, but you should be able to test it yourself by installing one of the above from the marketplace and setting an instance of the rule/widget up.

@jimtng
Copy link
Contributor

jimtng commented Jan 29, 2025

I'll study this more closely tomorrow, but ideally the initial zoom, given no available position data, should be worldwide, don't you agree?

And yes, I agree, if we have the position (e.g. from the regional settings or something else), then center in on that instead of worldwide.

@rkoshak
Copy link
Author

rkoshak commented Jan 29, 2025

should be worldwide, don't you agree?

Yes.

I seem to remember it used to be worldwide when I wrote this issue, but now I'm doubting my memory.

@jimtng
Copy link
Contributor

jimtng commented Jan 30, 2025

And then if you have two locations you have to do it all over again because the map doesn't remember what you did when you picked the first location.

This part is a bit tricky. I'm not familiar with widget design, but afaik, you can't add some javascript in there to manipulate other component properties, e.g. to give the "destination" map input the location of the "source" input in order for it to go there as the initial location.

The next best (and easiest) to do is to use system location as the initial location, but this won't relate to the first input. Only by virtue that most people would probably enter something near their system location and not on the other side of the globe.

@rkoshak are you running 4.3.x or 5.0? I have a webui jar for you to test.

@rkoshak
Copy link
Author

rkoshak commented Jan 30, 2025

but afaik, you can't add some javascript in there to manipulate other component properties

My thought was that the same map widget would be reused or something like that instead of somehow passing the location chosen the first time to the second map.

But I agree, if the map starts closer to home, it's not that annoying if it's always centered on home instead of centered where ever it was last.

I'm on 4.3 but can update to 5 if that's easier.

@jimtng
Copy link
Contributor

jimtng commented Jan 30, 2025

My thought was that the same map widget would be reused or something like that instead of somehow passing the location chosen the first time to the second map.

I am not aware of such mechanism. The next best thing is to save the last location of the map to be reused by the next (indeterminate) map picker, but that might have some undesired side effects, so I'm not sure it's a good idea.

I'm on 4.3 but can update to 5 if that's easier.

I'll build a 4.3 one, give me 10-15 minutes.

@jimtng
Copy link
Contributor

jimtng commented Jan 30, 2025

OOops, I uploaded the wrong jar (sources) sorry. This is the right one

Try this jar. You can drop it into the addons folder, disable the built in one (stop <org_bundle_#>) and restart the new id (restart <new_bundle_#>). I had to add .txt so github would let me upload it.

org.openhab.ui-5.0.0-SNAPSHOT.jar.txt

@jimtng
Copy link
Contributor

jimtng commented Jan 30, 2025

And this is the 4.3 version

org.openhab.ui-4.3.3-SNAPSHOT.jar.txt

@rkoshak
Copy link
Author

rkoshak commented Jan 30, 2025

I had to restart OH to get it to work. Not sure why but it came up with a blank map.

Once I restarted it appears to work. My only request would be to set the initial zoom at two to three levels further out. But that's mainly for my personal use cases. I can see other use cases where zooming in that far makes sense too so don't let this request block anything.

Is it possible to drop the pin (i.e. default the selected location) to the home lat/lon? I imagine it will frequently be the case where a user will want to choose their home location. Defaulting that could save them a step in those cases.

@jimtng
Copy link
Contributor

jimtng commented Jan 31, 2025

Is it possible to drop the pin (i.e. default the selected location) to the home lat/lon? I imagine it will frequently be the case where a user will want to choose their home location. Defaulting that could save them a step in those cases.

Personally, I'd prefer not to automatically drop a pin, because it would be annoying in the case when you have an empty input field, and someone clicked it just to "see" and want to back out without changing anything. By dropping a pin, now the field has changed.

What would be great though is to have the ability to specify some defaults. I may create a separate PR to do that.

@rkoshak
Copy link
Author

rkoshak commented Jan 31, 2025

By dropping a pin, now the field has changed.

If it's a required field it's going to have to change anyway.

But that's an angle I didn't think of. If there is already something in the field, the map should center on that I would think. That's what I would expect.

Regardless, these changes address my major concerns.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
2 participants