渲染与方向服务的JSON [英] rendering a json with direction service

查看:83
本文介绍了渲染与方向服务的JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用相同的json请求特定的拉特朗方向服务响应时。所以不是总是做同样的请求,我想以某种方式存储json。我尝试解析json并发送到我提供响应的函数,但它不起作用。是甚至可能这样的东西?

  var direction = JSON.parse('{routes:[{bounds: ......}'); 
directionRenderer.setDirections(direction);


解决方案

使用 directionRenderer.setDirections(),因为并不是所有的directionsResult属性都可以存储在JSON中。



但是你当然可以绘制路径你可以从方向结果中获取重要细节(LatLng的,描述等),并使用它们来绘制折线和提供路线细节。

when i make a request for a specific latlang direction service responses with the same json. so instead of making the same requests always, i want to store the json somehow.i tried parsing the json and sent to my function which i render the responses, but it didn't work. is something like this even possible?

var direction = JSON.parse('{"routes":[{"bounds":......}');
directionRenderer.setDirections(direction);

解决方案

It's not possible by using directionRenderer.setDirections() , because not all properties of a directionsResult may be stored in JSON.

But you may of course draw the route on your own, fetch the important details (LatLng's, descriptions etc. out of the directionsResult and use them to 1. draw a polyline and 2. providing route-details)

这篇关于渲染与方向服务的JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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