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

Viewport not correct when starting Map from search results (basic member) #7584

Closed
jonas-koeritz opened this issue Apr 29, 2019 · 7 comments
Closed

Comments

@jonas-koeritz
Copy link
Member

Detailed steps causing the problem:
  • Search for address
  • Select search result
  • View cache list
  • Select "Map" Icon in the Action Bar to map those results
Actual behavior after performing these steps:

The map is (most of the time) zoomed out to zoom level 0.

Expected behavior after performing these steps:

The map is somewhat centered on the found caches and appropriately zoomed.

Version of c:geo used:

master

Is the problem reproducible for you?

Yes

Other comments and remarks:

This is caused by the code performing the search by center. The results most of the time do not contain reliable coordinates or don't contain any coordinates at all. The layer can not be zoomed to.

I already tested a workaround that creats a Viewport of 1.0x1.0 degrees around the center and invokes the new live map search. The search result contains the necessary coordinates to correctly show the map.

The optimal solution would get the bounding box for the given address (e.g. city/state limits) and search within that box. The live map code could be easily extended to handle the paging.

@jonas-koeritz
Copy link
Member Author

jonas-koeritz commented Apr 29, 2019

Geocoding with Polygon output, just for my own reference:

https://nominatim.openstreetmap.org/search.php?q=query&polygon_geojson=1&format=json&addressdetails=1

@Lineflyer
Copy link
Member

You are refering to a basic member scenario, are you?

@jonas-koeritz
Copy link
Member Author

Yes, this is a basic member scenario.

@moving-bits
Copy link
Member

additional information: This seems to happen only if

  • you are a GC basic member
  • and have GC as your only enabled service

(because as soon as you enable a different service which returns reliable results (eg.: oc.de), map will have something to determine the bounding box)

@moving-bits
Copy link
Member

@jonas-koeritz

Have a look at main/src/cgeo/geocaching/address/AddressListAdapter.java: When searching for an address like "Köln" the result lists has geo location information. This is already used for the icon beside the found addresses (which opens a map centered to the address found).

This works by transferring the address to the click listener

viewHolder.mapIcon.setOnClickListener(v -> clickListener.onClickMapIcon(addresses.get(viewHolder.getAdapterPosition())));

which is implemented in main/src/cgeo/geocaching/address/AddressListActivity.java, and there the coordinates of the address are used to center the map:

public void onClickMapIcon(final Address address) {
    DefaultMap.startActivityGeoCode(this, new Geopoint(address.getLatitude(), address.getLongitude()));
    finish();
}

Maybe this principle can be reused by preserving the location info during the search steps, promoting it to the cache list and using it there for centering the map, if there is no cache in the list with reliable coordinates?

@jonas-koeritz
Copy link
Member Author

This looks like a feasible idea. I will give it a shot.

@Lineflyer Lineflyer changed the title Viewport not correct when starting Map from search results list Viewport not correct when starting Map from search results (basic member) Nov 20, 2019
@Lineflyer
Copy link
Member

This should be outdated as we now utilize the new search which returns coords also to basic members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants