Common_MapTips_VBNet\StickyMapTips.aspx.vb
' Copyright 2011 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports Microsoft.VisualBasic Imports System Partial Public Class StickyMapTips Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Register script to pass the MapTips' graphics layer client ID to the client-side ' setupStickyMapTips function and to wire onMapZoom to the zoomStart event. This ' script will execute when the AJAX load event is fired. Dim setupStickyMapTipsScript As String = String.Format("" & ControlChars.CrLf & " function stickyMapTipsInit() {{" & ControlChars.CrLf & " // Put the logic in a timeout to ensure that the Web ADF JavaScript MapTips " & ControlChars.CrLf & " // control is initialized first" & ControlChars.CrLf & " window.setTimeout(""setupStickyMapTips('{0}');"" + " & ControlChars.CrLf & " ""var map = $find('{1}');"" +" & ControlChars.CrLf & " ""map.add_zoomStart(onMapZoom);"", 0); " & ControlChars.CrLf & " }}" & ControlChars.CrLf & " Sys.Application.add_load(stickyMapTipsInit);", MapTips1.GraphicsLayerClientID, Map1.ClientID) System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "setupStickyMapTips", setupStickyMapTipsScript, True) AddHandler Map1.ExtentChanged, AddressOf Map1_ExtentChanged End Sub Private Sub Map1_ExtentChanged(ByVal sender As Object, ByVal args As ESRI.ArcGIS.ADF.Web.UI.WebControls.ExtentEventArgs) ' Create JavaScript needed to re-wire the MapTip anchoring logic to the MapTips' graphics ' layer and bring any open MapTips to the front. This is necessary because the MapTips ' graphics layer is re-created when the extent is changed to update the features currently ' shown. Note that we have to put this logic in a timeout for it to execute after graphics ' layer recreation. Dim addHandlerScript As String = String.Format("" & ControlChars.CrLf & " window.setTimeout(""$find('{0}').add_mouseOver(anchorMapTip);"" +" & ControlChars.CrLf & " ""bringMapTipsToFront()"", 0);", MapTips1.GraphicsLayerClientID) ' Package the JavaScript in a callback result and add it to the Map's collection Dim addHandlerCallbackResult As ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(addHandlerScript) Map1.CallbackResults.Add(addHandlerCallbackResult) End Sub End Class