我正在使用mapbox为客户创建一个示例应用程序,我需要庞大的数据集,这些数据集遍及整个世界的lt lng格式。
E.g。
var addressPoints = [
[-37.8210922667, 175.2209316333, "2"],
[-37.8210819833, 175.2213903167, "3"],
[-37.8210881833, 175.2215004833, "3A"],
];
我在考虑世界各地的酒店列表或其他什么?或者是一种在Javascript中动态创建位置的极其敏捷的方式,这种方式最终不会出现在海中?
任何帮助都将非常感谢!
感谢。
答案 0 :(得分:0)
这是一个有趣的问题 - 我不知道一个庞大的数据集,但我生成的一些想法是:
如果你有一个免费的API密钥,你可以查询Strava的段终点并给它一个lat / lng边界,这样你就可以获得这些边界内的起点和终点(但是限制为10个结果,所以你必须循环以获取足够的数据并可能超出您的API调用限制,但是如果您只是创建它可能不是那么糟糕)。你也可以从特定的自行车骑行/跑步中获得很多积分,但他们都很亲密,我认为你不想要。
http://strava.github.io/api/v3/segments/#explore例如
<强>节流强>
默认的速率限制允许每15分钟发出600个请求 每天30,000个请求。
API调用
curl -G https://www.strava.com/api/v3/segments/explore \
-H "Authorization: Bearer YOUR_TOKEN" \
-d bounds=37.821362,-122.505373,37.842038,-122.465977 \
<强>响应强>
{
"segments": [
{
"id": 229781,
"name": "Hawk Hill",
"climb_category": 1,
"climb_category_desc": "4",
"avg_grade": 5.7,
"start_latlng": [
37.8331119,
-122.4834356
],
"end_latlng": [
37.8280722,
-122.4981393
],
"elev_difference": 152.8,
"distance": 2684.8,
"points": "}g|eFnm@n@Op@VJr@"
},
{
"id": 632535,
"name": "Hawk Hill Upper Conzelman to Summit",
"climb_category": 0,
"climb_category_desc": "NC",
"avg_grade": 8.10913,
"start_latlng": [
37.8334451,
-122.4941994
],
"end_latlng": [
37.8281297,
-122.4980005
],
"elev_difference": 67.29200000000003,
"distance": 829.834,
"points": "_j|eFvc@p@SbAu@h@Qn@?RTDH"
}
]
}
此API将接受一个地址并为您提供一个lat / lng(以及更多),但会受到限制。你只需要一个很容易获得的地址列表。
API https://developers.google.com/maps/documentation/geocoding/
限制
免费API的用户:每24小时有2,500个请求。 5个要求 每秒。
API调用
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
<强>响应强>
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
},
{
"long_name" : "Amphitheatre Pkwy",
"short_name" : "Amphitheatre Pkwy",
"types" : [ "route" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santa Clara",
"short_name" : "Santa Clara",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "94043",
"short_name" : "94043",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"geometry" : {
"location" : {
"lat" : 37.42291810,
"lng" : -122.08542120
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 37.42426708029149,
"lng" : -122.0840722197085
},
"southwest" : {
"lat" : 37.42156911970850,
"lng" : -122.0867701802915
}
}
},
"types" : [ "street_address" ]
}
],
"status" : "OK"
}