[英]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.