OpenLayers + OpenStreetMaps を使用してオンライン マッピング アプリケーションを開発しています。
緯度と経度を受け取って住所を返す単純なリバース ジオコーディング関数を javascript (または php) で実装するのに助けが必要です。
可能であれば、ノミナティムと一緒に働きたいです。Google、Bing、CloudMade、またはその他の独自のソリューションを使用したくありません。
このリンクは合理的な応答を返し、simple_html_dom.php を使用して結果を分析しましたが、これは一種の醜い解決策です。
<?php
include('simple_html_dom.php');
$url = "http://nominatim.openstreetmap.org/reverse?format=xml&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1";
$html = file_get_html($url);
foreach ($html->find('road') as $element ) {
echo $element;
}
?>
よりエレガントなソリューションの提案はありますか?
注: 2015 年 10 月現在、 「アプリケーションの十分な識別を提供する」ために 、要求には有効な電子メールを含める必要があります。
メールがない場合、戻りコードは xml または json 形式ではなく、エラー 509 "Bandwidth Exceeded"として返されます。スクレイピングに html_dom ライブラリを使用してみてください。
$url = "http://nominatim.openstreetmap.org/reverse?email=myemail@myserver.com&format=xml&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1";