简体   繁体   English

如何保持Google地图的缩放级别?

[英]How to keep Google maps Zoom level?

I have a asp website and it contains a street address field which will auto complete from Google maps.Near the textbox field there is a image button.A pop up window will show google maps with marker of the place in street address field when we click the button.Currently my zoom level is 15.The user may zoom in the map and close the window.Then he may return back to map again.Currently the zoom level will return to 15 again.How can i keep the zoom level selected by user? 我有一个ASP网站,它包含一个街道地址字段,该字段将根据Google地图自动完成。在文本框字段附近有一个图像按钮。当我们单击时,一个弹出窗口将显示带有街道地址字段位置标记的Google地图当前我的缩放级别是15.用户可以放大地图并关闭窗口。然后他可以再次返回地图。当前缩放级别将再次回到15.我如何保持由用户?

OnClientClick of imagebutton. 图像按钮的OnClientClick。

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

It depends what your architecture is and how you want to store this data. 这取决于您的体系结构以及存储数据的方式。 You may simply want to store the user details and map settings in your database or have it stored in a session variable. 您可能只是想将用户详细信息和地图设置存储在数据库中,或者将其存储在会话变量中。

This will not done by simply javascript , I think you should store the user's map settings in database by using $.ajax() . 这不能仅通过javascript来完成,我认为您应该使用$ .ajax()user's map settings存储在database So, next time when the user see the map then he will his last updated settings . 因此,下一次当user看到map时,他将last updated settings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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