📄 atlasuimap.js
字号:
this.stopContinuousPanBy =function(){_map.StopContinuousPan();}this.setViewport =function(lat1,lon1,lat2,lon2){_map.SetViewport(lat1,lon1,lat2,lon2);}this.setBestMapView =function(locations){_map.SetBestMapView(locations);}this.includePointInViewport =function(latitude,longitude){_map.IncludePointInViewport(latitude,longitude);}this.zoomIn =function(){_map.ZoomIn();}this.zoomOut =function(){_map.ZoomOut();}this._ensureMap =function(){if (!_map){if (!_width){if (this.element.offsetWidth >0){_width =this.element.offsetWidth;} else {_width =400;}}if (!_height){if (this.element.offsetHeight >0){_height =this.element.offsetHeight;} else {_height =400;}}_map =new VE_MapControl(_latitude,_longitude,_zoomLevel,this._parseMapStyle(_mapStyle),"relative",0,0,_width,_height);_endContinuousPanHandler =Function.createDelegate(this,endContinuousPanHandler);_map.onEndContinuousPan =_endContinuousPanHandler;_activatePushpinHandler =Function.createDelegate(this,activatePushpinHandler);this.endContinuousPan.add(_activatePushpinHandler);this.element.innerHTML ='';this.element.appendChild(_map.element);}}function endContinuousPanHandler(){this.endContinuousPan.invoke(this,Web.EventArgs.Empty);}this.render =function(){if (!this.get_isInitialized()){return;}this._ensureMap();var i,element;if (_pushpins){for (i =_pushpins.length -1;i >=0;i--){element =_pushpins[i]._popupTemplate;if (_pushpins[i]._isDataItem &&element){Web.UI.ITemplate.disposeInstance(element);_map.RemovePushpin(_pushpins[i].get_value());_pushpins.removeAt(i);}}}var pushpins =this.get_pushpins();var items =this.get_data();var itemLength =items ?items.get_length():0;if (itemLength >0){for (i =0;i <itemLength;i++){var item =items.getItem(i);var pushpin =this._createPushpin(item.get__rowObject());pushpin._isDataItem =true;this._addPushpin(pushpin,item);pushpins.add(pushpin);}}}this._parseMapStyle =function(value){switch (value){case Web.UI.MapStyle.Aerial:return "a";case Web.UI.MapStyle.Hybrid:return "h";default:return "r";}}this._createActivationBehavior =function(popupBehavior){var showHandler;var hideHandler =function(){popupBehavior.hide();}var behavior;if (_pushpinActivation ==Web.UI.ActivationType.Hover){showHandler =function(){popupBehavior.show();}behavior =new Web.UI.HoverBehavior();behavior.set_unhoverDelay(500);behavior.set_hoverElement(popupBehavior.control.element);behavior.hover.add(showHandler);behavior.unhover.add(hideHandler);}else {showHandler =function(){if (popupBehavior.control.get_visible()){popupBehavior.hide();}else {popupBehavior.show();}}behavior =new Web.UI.ClickBehavior();behavior.click.add(showHandler);}return behavior;}this._addPushpin =function(pushpin,dataItem){if (_map ==null){return;}var latitude =pushpin.get_latitude();if (!latitude){latitude =this.get_latitude();}var longitude =pushpin.get_longitude();if (!longitude){longitude =this.get_longitude();}var width =pushpin.get_imageWidth();if (!width){width =_pushpinImageWidth;}var height =pushpin.get_imageHeight();if (!height){height =_pushpinImageHeight;}if (!pushpin.get_imageURL()){pushpin.set_imageURL(_pushpinImageURL);}var pushpinElement =_map.AddPushpin(pushpin.get_value(),latitude,longitude,width,height,_pushpinCssClass,pushpin.get_innerHtml(),1000);var popupBehavior,popupContentElement;if (_pushpinActivation !=Web.UI.ActivationType.None){var popupElement =document.createElement("div");popupElement.className =_popupCssClass;this.element.appendChild(popupElement);var popupControl =new Web.UI.Control(popupElement);popupBehavior =new Web.UI.PopupBehavior();popupBehavior.set_parentElement(pushpinElement);popupBehavior.set_positioningMode(_popupPositioningMode);popupControl.get_behaviors().add(popupBehavior);popupBehavior.initialize();popupControl.initialize();popupContentElement =_popupTemplate.createInstance(popupElement,dataItem).instanceElement;var pushpinControl =new Web.UI.Control(pushpinElement);pushpinControl.initialize();var behavior =this._createActivationBehavior(popupBehavior);pushpinControl.get_behaviors().add(behavior);behavior.initialize();}pushpin._popup =popupBehavior;pushpin._popupTemplate =popupContentElement;}this._createPushpin =function(dataItem){var innerHtml;var id;var imageURL;var imageWidth;var imageHeight;var text ="";if (_dataValueField){id =dataItem[_dataValueField];}if (_dataImageURLField){imageURL =String.format(_dataImageURLFormatString,dataItem[_dataImageURLField]);}if (!imageURL ||imageURL.length ==0){imageURL =_pushpinImageURL;imageWidth =_pushpinImageWidth;imageHeight =_pushpinImageHeight;}else {if (_dataImageWidthField){imageWidth =dataItem[_dataImageWidthField];}if (_dataImageHeightField){imageHeight =dataItem[_dataImageHeightField];}}if (_dataTextField){text =String.format(_dataTextFormatString,dataItem[_dataTextField]);}var pushpin =new Web.UI.Pushpin();pushpin.set_value(id);pushpin.set_imageURL(imageURL);pushpin.set_imageWidth(imageWidth);pushpin.set_imageHeight(imageHeight);pushpin.set_text(text);pushpin.set_latitude(dataItem[_dataLatitudeField]);pushpin.set_longitude(dataItem[_dataLongitudeField]);pushpin.initialize();return pushpin;}}Type.registerSealedClass('Web.UI.VirtualEarthMap',Web.UI.Control);Web.TypeDescriptor.addType('script','virtualEarthMap',Web.UI.VirtualEarthMap);Web.UI.Pushpin =function(){Web.UI.Pushpin.initializeBase(this,[true]);var _map;var _value;var _latitude;var _longitude;var _imageURL;var _imageWidth;var _imageHeight;var _text;this.get_value =function(){return _value;}this.set_value =function(value){_value =value;}this.get_latitude =function(){return _latitude;}this.set_latitude =function(value){_latitude =value;}this.get_longitude =function(){return _longitude;}this.set_longitude =function(value){_longitude =value;}this.get_imageURL =function(){return _imageURL;}this.set_imageURL =function(value){_imageURL =value;}this.get_imageWidth =function(){return _imageWidth;}this.set_imageWidth =function(value){_imageWidth =value;}this.get_imageHeight =function(){return _imageHeight;}this.set_imageHeight =function(value){_imageHeight =value;}this.get_text =function(){return _text;}this.set_text =function(value){_text =value;}this.get_innerHtml =function(){if (_imageURL &&_imageURL.length >0){return String.format("<img src=\"{0}\" alt=\"{1}\" title=\"{2}\" />",_imageURL,_text,_text);}else {return _text;}}this.initialize =function(){Web.UI.Pushpin.callBaseMethod(this,'initialize');if (_map){_map._addPushpin(this);}}this.getDescriptor =function(){var td =Web.UI.Pushpin.callBaseMethod(this,'getDescriptor');td.addProperty('value',String);td.addProperty('latitude',Number);td.addProperty('longitude',Number);td.addProperty('imageURL',String);td.addProperty('imageWidth',Number);td.addProperty('imageHeight',Number);td.addProperty('text',String);return td;}this.setOwner =function(map){_map =map;}}Type.registerSealedClass('Web.UI.Pushpin',Web.Component);Web.TypeDescriptor.addType('script','pushpin',Web.UI.Pushpin);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -