0

私が取り組んでいるサイトのホームページで、実際の場所の写真とその上に「もっと見る」という名前のボタンを配置したい

このボタンをクリックすると、ユーザーは別のページに移動し、その場所の空間ポイントがマップ上に既にレンダリングされている openlayers マップを見つけることができます。

さて、これを実装するには、場所の名前をホームページから地図ページに転送する必要があります。ボタンがクリックされたとき、すぐに JavaScript 関数を呼び出して、openlayers に地図上のポイントをレンダリングさせます。

どうすればいいですか?

データを転送し、すぐに JavaScript 関数を呼び出しますか?

前もって感謝します

4

1 に答える 1

2

The classic way to do this would be to add a query parameter to the galleries page URL before you open it like this:

/galleries?placeID=3456

Then, you can access that placeID either on the server or in the galleries page javascript (whichever you want).


In the galleries page, you would then have some javascript that runs when the page is initialized. That javascript would examine the query parameters on the URL and act accordingly.

$(document).ready(function() {
    // examine window.location.search here to look at the query parameters
    var matches = window.location.search.match(/placeID=(.*?)(&|$)/);
    if (matches) {
        var placeID = matches[1];
        // do whatever you want with placeID here
    }
});
于 2013-10-21T00:39:52.407 に答える