ThinkGeo.com    |     Documentation    |     Premium Support

OnClientExtentChanged not triggered


Hi


When the extent is changed I do a lot of server side processing that I need to fetch from the client when the map has finished rendering. First I have an ExtentChanged event that is triggered server side. I store the result in a session variable which I want to retrieve afterwards wtrouh a web service. I have tried the following:


<cc1:Map ID="Map1" runat="server" Width="100%" Height="100%" OnClientExtentChanged="alert('show me the money');" OnExtentChanged="Map1_ExtentChanged">



The alert is however only shown the first time the map is shown. Is this a bug or am I mising something out?


In case this can not be acomplished here is what I try to achieve. The information retrieved through the web service is a series of urls and screen coordinates where iframes showing the urls in these "mini browsers". Is there another way of generating this "html" type overlay? Server side rendering of this is not an option.


Best Regrads


   Franz Thomsen


 


 


 


 


 



Hi Franz, "OnClientExtentChanged" here only supports js function delegate, not a js code directly, so please defined a js method, and pass its method delegate to this property, I hope the following code may help, thanks. 










<script type="text/javascript">

     var MapExtentChanged = function(map){


         alert("show me the money");
     }
</script>
     
<cc1:Map ID="Map2" runat="server" Width="100%" Height="100%" OnClientExtentChanged="MapExtentChanged" />






Hi Godspeed 
  
 You are absolutely right, that works. It does however not solve my problem as this event is triggered immediately clientside when the user changes extent. The server hasn’t sone anything yet so the data I want to retrieve isn’t created yet. I can do it by using  
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest) 
 Which isn’t thr prettiest way of doing it. Shouldn’t the method OnClientExtentChanged be called OnClientExtentChanging and then another one OnClientExtentChanged that is triggered after the extent has been changed? Well … I can solve it by using the method above, but it would be nice though with a clientside event after an update has occurred. 
  
 Best Regards  
   Franz Thomsen

Franz,


Let’s say we have had the OnClientExtentChanging client event, then after this event is raised, it will cause a post back to refresh the server side status / raise the server side event. After that post back, client side status will all be cleared up and I’m not sure the other client method OnClientExtentChanged can be called or not. It’s similar as an ASP button, its OnClientClick event will be raised first and then it’s the server side click event, after that page is refreshed and status is cleared up.


Your solution works fine but whenever you pan or zoom in/out the map, it’ll trigger an unnecessary post-back, which will slow down the performance.


I think what you want to achieve is collecting data, saving it into sessions and then calling a client-side method. That seems a typical scenario for a callback and here is my suggestion: use method OnClientExtentChanged only and do the client logic in the callback. Here is a sample for you hope it helps.

Thanks,


Ben

 



373-Post5239.zip (95.1 KB)