0

一部のユーザーがデータを入力するWebサイトがあります。アドレスはそれらのデータの1つです。このようなhtmlを取得したいです。

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=51.708931,101.425781&amp;t=m&amp;z=4&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=51.708931,101.425781&amp;t=m&amp;z=4&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>

入力したアドレスでWebリクエストを作成し、HTMLを解析して埋め込み用のHTMLを取得したいと思います。より良いアイデアはありますか?

4

1 に答える 1

1

これにはJQueryソリューションがあります。つまり、ユーザーがテキストボックスに住所を入力すると、住所がマップに動的に読み込まれます。

ここでデモを、ここでコードを試してください

$(document).ready(function(){
    var map = $('#map').acts_as_map_container();
    // params:
    // container is required
    // suggestion is the element which will contain the suggested address, default to #suggested
    // delay is the delay time for requesting google map api, default to 500ms
    var address = $('#address').acts_as_address({
        container: map,
        suggestion: '#suggestion',
        delay : 500
    });

})
于 2012-12-06T18:02:20.750 に答える