简体   繁体   中英

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

I am using google autocomplete textbox and a map to show the place entered in the textbox. following code will work on button click to show map.

                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);                                
                        }
                    });
                }

When i navigate to another page and comes back, currently map not showing the place.Is there any way to keep the

place.geometry.location
and to show the place in map again with out triggering google maps textbox.

Store the textbox value in cookie and each time when your page gets loaded, just check for the cookie value and call the map function with that value if cookie is not null. Best way. Just try and let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM