简体   繁体   English

Android:按名称搜索位置,无需使用 Google 地方信息或地图 SDK

[英]Android: Search location by Name without using Google Places or Maps SDK

I'm looking for a way to search a location using name.我正在寻找一种使用名称搜索位置的方法。 The location being an object with longitude and latitude data.该位置是具有经度和纬度数据的 object。

I want to achieve this without using Places SDK or Maps SDK, as they are paid services in the long run (if I'm not mistaken)我想在不使用 Places SDK 或 Maps SDK 的情况下实现这一目标,因为从长远来看它们是付费服务(如果我没记错的话)

I've tried using Geocoder, but it seems like it only works if you are searching for a country.我试过使用地理编码器,但它似乎只在你搜索一个国家时才有效。 Ideally, I would like to be able to search for city as well.理想情况下,我也希望能够搜索城市。 GeoCoder returns an empty list for this usecase. GeoCoder 为此用例返回一个空列表。 Using LocationManager only allows me to get the last known location of the user, so that's not it either.使用 LocationManager 只允许我获取用户的最后一个已知位置,所以也不是这样。

Is there such a way to achieve this?有没有这样的方法来实现这一目标?

I tried Geocoder again, and it seems my first take wasn't accurate.我再次尝试了 Geocoder,似乎我的第一次拍摄并不准确。 The requirement for Geocoder seems to be that you need to provide an actual name that matches any entry, otherwise it's gonna be null. Geocoder 的要求似乎是您需要提供与任何条目匹配的实际名称,否则它将是 null。

For the meantime, I think this should work for me.与此同时,我认为这应该对我有用。 But if there's any other way that allows me to search for any location without complete name would be better但是,如果有任何其他方式可以让我搜索没有完整名称的任何位置会更好

You can use a few open-source maps for achieving this like OpenStreetMaps or HereMaps.您可以使用一些开源地图来实现此目的,例如 OpenStreetMaps 或 HereMaps。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有适用于Android的地点SDK的情况下实现谷歌地点自动完成搜索框? - how to implement google places autocomplete search box without places SDK for android? 使用Android中的Google Maps API显示当前位置和附近地点以及两个地点之间的路线 - Show Current Location and Nearby Places and Route between two places using Google Maps API in Android Android地图和地点位置 - Android Maps and Places Location Android 谷歌地图:哪个 API 用于搜索您当前位置附近的地方? - Android Google Maps: which API used to search places nearby your current location? 使用我当前的位置在Google地图中实现Google地方信息 - Implement Google Places into Google Maps Using My Current Location 使用 Android 中的 Google Maps API 从用户位置获取附近地点的结果 - Getting results of nearby places from User's Location using Google Maps API in Android 适用于Android的Google Maps and Places SDK在发行版APK中不起作用 - Google maps and Places SDK for android not working in release APK 在Google Maps Android中搜索特定位置 - Search specific location in Google Maps Android 获取我当前位置的Google Places API(位置搜索)的名称 - Getting name of google places API (Place Search) for my current location Android Google相机中心名称的地图位置 - android google maps center of the camera location name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM