繁体   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