我的应用程序允许用户在地图上选择两个点,并使用Google地图Apiv3的路线服务查找它们之间的路线.然后必须将沿此路线的坐标保存到数据库中.我可以成功编写所有代码来完成此任务.但是我被遗漏了一个问题.
我知道在StackOverflow中还有其他一些问题 - 一,二,同时,但我认为他们或我在这里错过了一些东西.
示例代码:
function getCoordinates(result) {
var currentRouteArray = result.routes[0]; //Returns a complex object containing the results of the current route
var currentRoute = currentRouteArray.overview_path; //Returns a simplified version of all the coordinates on the path
obj_newPolyline = new google.maps.Polyline({ map: map }); //a polyline just to verify my code is fetching the coordinates
var path = obj_newPolyline.getPath();
for (var x = 0; x < currentRoute.length; x++) {
var pos = new google.maps.LatLng(currentRoute[x].kb, currentRoute[x].lb)
latArray[x] …
Run Code Online (Sandbox Code Playgroud) 我发现Google Maps API支持路线:
var map;
var directionsPanel;
var directions;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
directionsPanel = document.getElementById("my_textual_div");
map.setCenter(new GLatLng(49.496675,-102.65625), 3);
directions = new GDirections(map, directionsPanel);
directions.load("from: 500 Memorial Drive, Cambridge, MA to: 4 Yawkey Way, Boston, MA 02215 (Fenway Park)");
}
Run Code Online (Sandbox Code Playgroud)
那么如何将其转换为Objective-C,以便iPhone可以检索它?我知道如何在MKMapView上画一条线我只需要路线的地理位置.
或者也许有一种不同的方式来获得两个地理位置点之间的路线.
请告诉我,
提前致谢.
有没有人想用iPhone找到真正的方向?我想实现这样的应用程序,其中我需要找到iPhone指向的方向,并希望使应用程序与iphone 3GS中的指南针应用程序相同.
iPhone 3G是否支持罗盘功能?并且任何人都可以告诉我罗盘应用程序如何像真正的磁罗盘那样准确地找到方向吗?
请帮帮我.我处于危急的境地.
提前致谢.
iphone direction cllocationmanager map-directions compass-geolocation
有没有办法从html页面链接到iPhone地图应用程序中的路线?
我们正在添加一个iPhone应用程序,该应用程序将链接到我们网站上的移动页面 - 我们想添加一个方向链接,到目前为止谷歌搜索一直没有发现.
这是一个有一定程度细节的问题,所以让我首先解释一下情况,然后我的实现和最后的问题让你最了解.
截至4月4日,已添加更新,问题范围缩小为一个待处理问题,请参阅此问题的底部以获取最新信息.
TLDR;
我有一条很长的路线从谷歌地图方向API返回,并希望该路线的高程图表.太糟糕了它不起作用,因为它是通过GET请求的,并且URL最大长度是超过2.048个字符.我分开了请求; 使用Promises保证正确的处理顺序; 但是,对于完整路线,Evelation数据并不总是完整的,并不总是按照正确的顺序显示,并不总是遵循给定的路径,并且有时会跨越几公里的高程间隔.
介绍;
尝试为Google Maps DirectionsService响应创建高程图我遇到了路线太长的问题(这似乎与距离无关,而不是每个overview_path的LatLng数量).这是由于通过请求ElevationService GET
并且URL的最大长度为2048个字符的事实引起的.这里也描述了这个问题.
实施;
我想我会比谷歌更聪明(不是真的,但至少试图找到一种方法来解决它),分裂由为DirectionsService(返回的路径overview_path
属性)为批次,连接结果(elevations
通过ElevationService方法返回getElevationsAlongPath
) .
LatLng
每批的最大数量,并检查处理完整路径所需的批次数(totalBatches
= overview_path.length / maxBatchSize
);batchSize =
Math.ceil(overview_path.length / totalBatches)
).当ElevationService异步工作时,我确保在其他SO用户的帮助下,首先使用setTimout并使用Promises,以正确的顺序处理所有请求.
我的代码
var maxBatchSize = 200;
var currentBatch = 0;
var promise = Promise.resolve();
var totalElevationBatches = Math.ceil(directions.routes[0].overview_path.length / maxBatchSize);
var batchSize = Math.ceil(directions.routes[0].overview_path.length / totalElevationBatches);
while(currentBatch < totalElevationBatches) {
promise = addToChain(promise, currentBatch, batchSize);
currentBatch++;
}
promise.then(function() {
drawRouteElevationChart(); …
Run Code Online (Sandbox Code Playgroud) javascript batch-processing google-maps-api-3 map-directions google-elevation-api
任何人都可以分享 Flutter 谷歌地图插件的文档/代码示例,我可以在其中根据行驶方向旋转标记(例如:汽车图标)。我看到这可以通过旋转标记在本机库上实现。但是在 Flutter 中找不到任何旋转标记的选项。
我想我们在旋转标记时需要考虑以下几点。也请添加您对此的看法。
地图北方向。设备从罗盘旋转。
谢谢
是否可以仅使用HTTP来使用Google Maps API路由器?像http://maps.google.com?from=blah?to=blah这样的东西
并让它返回某种代表方向的XML或JSON吗?
截至目前,我已使用以下代码从我的应用中使用地图应用成功生成路线:
NSString *formattedGroceryAddress = [[NSString stringWithFormat:@"%@",((EnhancedUIActionSheet *)actionSheet).grocery.address] stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSString *routeString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",localDataHelper.userLocation.coordinate.latitude,localDataHelper.userLocation.coordinate.longitude,formattedGroceryAddress];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:routeString]];
Run Code Online (Sandbox Code Playgroud)
它会打开具有相应行车路线的地图应用.问题是,我想默认打开带有步行路线的地图.也许我可以在我的请求中传递另一个参数来做到这一点.
谁知道怎么样?
谢谢 !
我正在使用下面的代码来获取两点之间的路线:
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我不想在绘制路线时更改我的地图位置和缩放级别.因此,当我使用不同的纬度和经度值调用上面的代码时,我希望保持我的地图位置和缩放级别.任何的想法?
我正在尝试为路线上的每个航路点添加一个标签,但我不太确定应该如何处理它.在做了一些研究之后,我知道你可以添加带标签的自定义引脚,但是当我手动丢弃每个引脚时.我怎么能这样做方向?
javascript label google-maps-api-3 google-maps-markers map-directions
map-directions ×10
google-maps ×4
iphone ×3
javascript ×3
direction ×2
dart ×1
flutter ×1
html ×1
http ×1
ios ×1
json ×1
label ×1
mkmapview ×1
mobile ×1