簡體   English   中英

從另一個頁面回來后如何保留Google位置?

[英]How to keep the Google place after coming back from another page?

我正在使用Google自動填充文本框和地圖來顯示在文本框中輸入的位置。 以下代碼將在單擊按鈕以顯示地圖時起作用。

                function SetStreet() {
                    $('#map-canvas').fadeIn('slow', function() {
                        google.maps.event.trigger(map, 'resize');
                        if (checkPlace == "placeselected") {
                            map.setCenter(place.geometry.location);
                            map.setZoom(15);
                            marker.setPosition(place.geometry.location);
                            marker.setVisible(true);                                
                        }
                    });
                }

當我導航到另一個頁面並返回時,當前地圖未顯示該地點。有什么方法可以保持

place.geometry.location
並在不觸發Google Maps文本框的情況下再次顯示在地圖中的位置。

將文本框值存儲在cookie中,每次加載頁面時,只需檢查cookie值,如果cookie不為null,則使用該值調用map函數。 最好的辦法。 請嘗試讓我知道。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM