如何在谷歌地图API中为每条街道使用唯一的标识符 [英] How to get an use an unique identifier for each street in google maps api

查看:172
本文介绍了如何在谷歌地图API中为每条街道使用唯一的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在用户询问路线时确认,如果用户已经在Google Maps路线搜索的结果中提供的街道之一(即使没有完全相同的坐标) 。

发生这样的情况:

当用户刚刚浏览街道时,应用程序不时询问谷歌用户是,使用地理编码api。然后注册它(我仍然需要知道应该使用哪些信息)。



在未来的另一个时间,用户会询问指向特定位置的路线他想要去,该应用程序会要求谷歌地图的替代品,然后它会决定哪一条路径是使用考虑到,如果用户会尽可能识别他的进步或其他方式,根据配置。

问题是我不知道如何使用每条街道的唯一标识符。



注意:现在我不会把大街分成几个部门。这应该更容易。
Ofc,如果这比考虑整条街道更容易,我会把街道划分成部门。

我已经测试过我不能使用坐标用户是。为了不与街道重叠并提供良好的精确度,即使截断,我也无法使用坐标。

我还检查了使用地理编码返回的地点的名称当我要求指示时,似乎不可用。 api的说明并没有用相同的标识符命名街道。



请帮助



在此先感谢。

解决方案

我知道您现在可能已经提出或想通了,但我会告诉你我会做什么。

如果我想识别可能很熟悉的街道,我会将街道上的街区标识为一组开始和结束坐标。你可以检查块的末端附近。

您应该能够通过地理编码块上某一点的地址并将地址线字符串拆分为空格来查找块的结尾。将第一个数字解析为一个int,将街道数字的模数除以100,然后在开始时添加一个,结束时为99。

  String [] splitAddr = address.getAddressLine(0).toString()。split(\\s) ; 
houseNum = splitAddr [0];
street = address.getAddressLine(0).toString()。substring(houseNum.length());
blockNum = Integer.parseInt(houseNum);
blockNum =(blockNum - (blockNum%100));
blockstart = blockNum + 1;
blockEnd = blockNum + 99


My objective here is to identify while the user is asking for directions, if the user has already been in one of the streets (even if not in the exact same coordinates) that were given in the result of the google maps directions search.

It happens like this:
When the user is just browsing the streets, the app, from time to time, asks google where the user is, using the geocode api. And then it registers it (I still need to know which information should I use).

On another time in the future, the user will ask for directions to a specific place he wants to go, the app will ask for alternatives to google maps, then it will decide which path is the one to use having into account if the user will recognize as much as possible as he progresses or the other way around, according to a configuration.

The problem is that I have no clue what to use as the unique identifier for each street.

Note: For now I'm not dividing the big streets into sectors. It should be easier that way. Ofc, if that's easier than considering the whole street, I'll divide the streets into sectors.

I already tested that i cannot use the coordinates of where the user is. In order not to overlap with near streets and to give a good precision, I'm unable to use the coordinates, even if truncated.
I also checked that using the name of the place that the geocode returns does not seem usable when I'm asking for directions. The directions api does not name the streets with the same identifier...

Help please.

Thanks in advance.

解决方案

I know you've probably moved on or figured this out by now, but I'll tell you what I would do.

If I wanted to identify streets that might be familiar, I would identify blocks on the street as a set of start and end coordinates. You could check for proximity to the ends of the blocks.

You should be able to find the ends of a block by geocoding the address of a point on the block and split the address line string up by spaces. parse the first number into an int, subtract the modulus of the street number divided by 100, then add one for the beginning and 99 for the end.

String[] splitAddr  = address.getAddressLine(0).toString().split("\\s");        
    houseNum    = splitAddr[0];
    street      = address.getAddressLine(0).toString().substring(houseNum.length());        
    blockNum    = Integer.parseInt(houseNum);
    blockNum    = (blockNum - (blockNum % 100));
    blockstart  = blockNum + 1;
    blockEnd    = blockNum + 99

这篇关于如何在谷歌地图API中为每条街道使用唯一的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆