mapbox-search-android icon indicating copy to clipboard operation
mapbox-search-android copied to clipboard

Offline Search did not support coordinates form HK, Japan, China mainland.

Open gongdao123 opened this issue 8 months ago • 0 comments

Environment

  • Search SDK Component (check at least one)
    • [ ] Core Search SDK (SearchEngine class, and etc.)
    • [X] Offline Search SDK (OfflineSearchEngine class, and etc.)
    • [ ] Address Autofill SDK
    • [ ] Search UI SDK
  • Android OS version: Android 14
  • Devices affected: All
  • Search SDK Version: 2.1.0
  • Included in project Maps SDK, Nav SDK versions if available:

Code examples

private val tileRegionId = "Washington DC"
private val tileStore = TileStore.create()
private val descriptors = listOf(OfflineSearchEngine.createTilesetDescriptor())
// Working if coordinates are in US, UK, Mexico, e.g:
// private val dcLocation Point.fromLngLat(-77.0339911055176, 38.899920004207516)

// Not working if coordinates are in HK, Japan, China Mainland
private val dcLocation = Point.fromLngLat(127.024612, 37.532600) 

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    searchEngine = OfflineSearchEngine.create(
        OfflineSearchEngineSettings(
            tileStore = tileStore
        )
    )

    searchEngine.addEngineReadyCallback(engineReadyCallback)

    searchEngine.addOnIndexChangeListener(object : OfflineSearchEngine.OnIndexChangeListener {
        override fun onIndexChange(event: OfflineIndexChangeEvent) {
            if (event.regionId == tileRegionId && (event.type == EventType.ADD || event.type == EventType.UPDATE)) {
                logI("SearchApiExample", "$tileRegionId was successfully added or updated")

                searchRequestTask = searchEngine.reverseGeocoding(
                    OfflineReverseGeoOptions(center = dcLocation),
                    searchCallback
                )
            }
        }

        override fun onError(event: OfflineIndexErrorEvent) {
            logI("SearchApiExample", "Offline index error:", event)
            onFinished()
        }
    })
}

Observed behavior and steps

In OfflineSearchKotlinExampleActivity.kt the IndexChangeListener will not be invoked if change the coordinates to HK, Japan, China Mainland, e.g:

private val dcLocation = Point.fromLngLat(114.1547347, 22.2846202) <== HK private val dcLocation = Point.fromLngLat(127.024612, 37.532600) <== Japan

https://github.com/mapbox/mapbox-search-android/assets/18628246/034aaeb5-93ba-45fe-a248-bd467cea9bd8

But the orginal coordinates provided by sample works, and tried GPS in Maxico and UK also works.

Expected behavior

The IndexChangeListener should be invoked, and tile should be able to load, and then can perform offline search.

gongdao123 avatar May 31 '24 07:05 gongdao123