googlemaps api3, demogallery example “Custom Small Navigation Control”

不羁岁月 提交于 2019-12-31 05:18:12

问题


This may not be the best place for this question but here goes:

I'm a beginner in googlemaps and javascript and found this example for something I'm working on. http://search.missouristate.edu/map/mobile/examples/ZoomPanControl.htm I understand most of the code but I'm having a hard time finding out the meaning of the following lines of code at the end of this file ZoomPanControl.js

window["missouristate"] = window["missouristate"] || {};
window["missouristate"]["web"] = window["missouristate"]["web"] || {};
window["missouristate"]["web"]["ZoomPanControl"] = ZoomPanControl;

Edit: The original example is no longer available and redirects to a map that doesn't have the custom ZoomPanControl, here is an example that shows the custom zoom/pan control referenced


回答1:


It's appending the control to the global variable(or namespace?) 'window', so that you can instantiate it using:

 var ZoomPanControl = new missouristate.web.ZoomPanControl(map);

The Google Maps API loader does the same thing, namely:

window.google = window.google || {};
google.maps = google.maps || {};


来源:https://stackoverflow.com/questions/12149305/googlemaps-api3-demogallery-example-custom-small-navigation-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!