ただし件数が多く、50箇所程度の住所全ての相互の距離を
知りたいです(道路上の距離)。
mapfanなどで調べられるのは知っていますが、
50×50=2500の経路全部をいちいち手入力で調べるのは
時間が掛かりすぎるのでもっと手早い方法を探しています。
google map apiを使うとできそうです。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>GoogleMapsAPI</title> <script src="http://maps.google.com/maps?file=api&v=2.55&key=★GoogleMapsAPIキー" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map = null; var direction = null; var fr = 0; var to = 1; var rootMapTimer = null; var addressArray = new Array( // 住所を配列で "東京都千代田区丸の内1", "東京都新宿区新宿三丁目38-1", "東京都港区高輪三丁目26-27"); // 初期処理 function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); direction = new GDirections(map, document.getElementById("direction")); GEvent.addListener(direction, "load", onGDirectionsLoad); rootMap(fr,to); // 最初の検索 } } // 次の検索 function nextMap() { to += 1; if ( to == addressArray.length ) { fr += 1; if ( fr == addressArray.length - 1 ) { document.getElementById("status").innerHTML = "終了"; return; } to = fr + 1; } rootMap(fr,to); } // 経路の検索 function rootMap(fr,to) { document.getElementById("status").innerHTML = "検索中:" + fr + "→" + to ; direction.load("from: " + addressArray[fr] + " to: " + addressArray[to],{ "locale": "ja_JP" }); } // 経路の検索完了 function onGDirectionsLoad() { var distance = direction.getDistance(); document.getElementById("result").innerHTML += addressArray[fr] + "→" + addressArray[to] + ":" + distance.meters + "m," + distance.html + "<br/>"; rootMapTimer = setTimeout("nextMap()",100); // 次の検索をタイマでセット } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <span id="status"></span> <div id="direction" style="width: 275px"></div><br> <div id="map" style="width: 400px; height: 400px"></div><br/> <span id="result"></span> </body> </html>
経路を計算した結果
東京都千代田区丸の内1→東京都新宿区新宿三丁目38-1:9389m,9.4 km
東京都千代田区丸の内1→東京都港区高輪三丁目26-27:8369m,8.4 km
東京都新宿区新宿三丁目38-1→東京都港区高輪三丁目26-27:11588m,11.6 km
【★GoogleMapsAPIキー】
GoogleMapsAPIキーは、以下で取得します。
http://code.google.com/intl/ja/apis/maps/index.html
【参考】
http://www.ajaxtower.jp/googlemaps/route/index9.html
http://code.google.com/intl/ja/apis/maps/documentation/javascrip...
Google Maps APIのジオコーディングを使って、住所を緯度・経度に変換。
あとは、Hubenyの公式を使って、2点間の距離を計算すればいいでしょう。
プログラミング環境としては、Ajaxでも、ExcelVBAでもできると思いますよ。
質問文にも書いていますが、「道路上の距離」を知りたいのです。
http://www.geoap.jp/service/trial/trial1-3.htm
GeOAPというASPですが、経路距離、直線距離の両方を算出できます。
体験版もあります。
「ExcelでGeoAPを体験する」でしたら多分、2500回の操作ではなく、
50回の操作で完了できると思いますが。。
いかがでしょうか?
EXCEL2002以降でないと使えないらしく、
私のEXCELのバージョンは2000のため、検証できませんでした。
残念です。
アドバンスド・コア・テクノロジー株式会社のプラグイン「ACT距離計算パッケージ」を使うことで対応できます。
「複数地点間の所要時間・距離のマトリクスを作成」機能があります。
http://www.act-inc.jp/information/press/press100118.html
ただし、MapInfoやSuper Mapple Digital などを持っていれば、なのですが。
ちなみに、50地点間の距離の組み合わせ数は、25×49=1225通りですみます。
残念ながらMapInfoやSuper Mapple Digitalなどを持っていません。
google map apiを使うとできそうです。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>GoogleMapsAPI</title> <script src="http://maps.google.com/maps?file=api&v=2.55&key=★GoogleMapsAPIキー" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map = null; var direction = null; var fr = 0; var to = 1; var rootMapTimer = null; var addressArray = new Array( // 住所を配列で "東京都千代田区丸の内1", "東京都新宿区新宿三丁目38-1", "東京都港区高輪三丁目26-27"); // 初期処理 function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); direction = new GDirections(map, document.getElementById("direction")); GEvent.addListener(direction, "load", onGDirectionsLoad); rootMap(fr,to); // 最初の検索 } } // 次の検索 function nextMap() { to += 1; if ( to == addressArray.length ) { fr += 1; if ( fr == addressArray.length - 1 ) { document.getElementById("status").innerHTML = "終了"; return; } to = fr + 1; } rootMap(fr,to); } // 経路の検索 function rootMap(fr,to) { document.getElementById("status").innerHTML = "検索中:" + fr + "→" + to ; direction.load("from: " + addressArray[fr] + " to: " + addressArray[to],{ "locale": "ja_JP" }); } // 経路の検索完了 function onGDirectionsLoad() { var distance = direction.getDistance(); document.getElementById("result").innerHTML += addressArray[fr] + "→" + addressArray[to] + ":" + distance.meters + "m," + distance.html + "<br/>"; rootMapTimer = setTimeout("nextMap()",100); // 次の検索をタイマでセット } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <span id="status"></span> <div id="direction" style="width: 275px"></div><br> <div id="map" style="width: 400px; height: 400px"></div><br/> <span id="result"></span> </body> </html>
経路を計算した結果
東京都千代田区丸の内1→東京都新宿区新宿三丁目38-1:9389m,9.4 km
東京都千代田区丸の内1→東京都港区高輪三丁目26-27:8369m,8.4 km
東京都新宿区新宿三丁目38-1→東京都港区高輪三丁目26-27:11588m,11.6 km
【★GoogleMapsAPIキー】
GoogleMapsAPIキーは、以下で取得します。
http://code.google.com/intl/ja/apis/maps/index.html
【参考】
http://www.ajaxtower.jp/googlemaps/route/index9.html
http://code.google.com/intl/ja/apis/maps/documentation/javascrip...
素晴らしいです!
ばっちりできました。
以下のようにほんの少しだけ変更しました。
1.一方通行を考慮すると、A地点→B地点の距離と、B地点→A地点の距離は
必ずしも等しくならないのでA地点→B地点とB地点→A地点の検索を
別に扱うようにしました。
2.高速道路を使わない距離を知りたかったので少しオプションを追加
しました。
// 次の検索
function nextMap() {
to += 1;
if (to==fr){
to += 1;
}
if ( to == addressArray.length ) {
fr += 1;
if ( fr == addressArray.length - 1 ) {
document.getElementById("status").innerHTML = "終了";
return;
}
to = 0;
}
rootMap(fr,to);
}
// 経路の検索
function rootMap(fr,to) {
document.getElementById("status").innerHTML = "検索中:" + fr + "→" + to ;
direction.load("from: " + addressArray[fr] + " to: " + addressArray[to],{
locale: "ja_JP",
avoidHighways: true
});
}
そのほか、参考まで。
エリア作成、配達・ルート作成でブックマークしていたものですが・・・。補足程度でよろしければ・・・。
-----------------
http://www.jrs.co.jp/article.php/products_plan_drive
http://www.geoap.jp/service/index_b.html
------------------
対象が北海道のときに、北海道たび教導隊さんの地図をみていました。
http://north.fromc.com/kyodotai/flashkyo/asettime.html
投稿数が多いので範囲が50km圏内でしたら、ひょっとしたら作成しなくても
同様のものが見つかるということもありましたので。希望的観測。
http://www.jognote.com/jogmaps
その後の編集を考えた場合は、やはりグーグルが便利となっていきますね。
http://maps.google.co.jp/help/maps/tour/#walking_direction
-----------------
また、ユーザーの声を商品へとあたらしい技術が発表されるのではと
期待している秋のイベントです。
http://www.g-expo.jp/index.html
-----------------
http://www.mapion.co.jp/route/
http://blogs.yahoo.co.jp/yjmapstaff/MYBLOG/yblog.html
分岐が多い距離の測定は、ほんとうにたいへんですよね・・・。比較一覧・・・。(^^;)
おじゃましました。
既出のものを除くと、
多少参考になりましたが問題解決には至りませんでした。
参考にはなりましたが、
できれば他に仕事を依頼するのは避けたいです。
素晴らしいです!
ばっちりできました。
以下のようにほんの少しだけ変更しました。
1.一方通行を考慮すると、A地点→B地点の距離と、B地点→A地点の距離は
必ずしも等しくならないのでA地点→B地点とB地点→A地点の検索を
別に扱うようにしました。
2.高速道路を使わない距離を知りたかったので少しオプションを追加
しました。
// 次の検索
function nextMap() {
to += 1;
if (to==fr){
to += 1;
}
if ( to == addressArray.length ) {
fr += 1;
if ( fr == addressArray.length - 1 ) {
document.getElementById("status").innerHTML = "終了";
return;
}
to = 0;
}
rootMap(fr,to);
}
// 経路の検索
function rootMap(fr,to) {
document.getElementById("status").innerHTML = "検索中:" + fr + "→" + to ;
direction.load("from: " + addressArray[fr] + " to: " + addressArray[to],{
locale: "ja_JP",
avoidHighways: true
});
}