Created
June 5, 2010 04:19
-
-
Save tf0054/426300 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // googleサービス | |
| directionsService.route(request, function(response, status) { | |
| // 正しく経路が得られているか確認 | |
| if (status == google.maps.DirectionsStatus.OK) { | |
| directionsDisplay.setMap(null); | |
| directionsDisplay.setMap(map); | |
| directionsDisplay.setDirections(response); | |
| // 距離をステップ合計から計算(ほんとうにこんな方法がよいのか。。) | |
| var intTmp = 0; | |
| for(var i in response.routes[0].legs[0].steps){ | |
| intTmp += response.routes[0].legs[0].steps[i].distance.value; | |
| } | |
| // 距離が1000mを超えたら単位を変更 | |
| if(intTmp > 1000){ | |
| document.getElementById('distance').innerHTML = '('+(intTmp/1000)+'km)'; | |
| }else{ | |
| document.getElementById('distance').innerHTML = '('+intTmp+'m)'; | |
| } | |
| // 経路上の距離を表示してみる From http://bit.ly/cKh1mU | |
| // document.getElementById('map_canvas').innerHtml = response.trips[0].routes[0].distance.value; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment