Ajax.aspx
上传用户:sex100000
上传日期:2013-11-09
资源大小:1377k
文件大小:2k
源码类别:

GIS编程

开发平台:

C#

  1. <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Ajax.aspx.cs" Inherits="Ajax" Title="AJAX map" %>
  2. <%@ Register TagPrefix="smap" Namespace="SharpMap.Web.UI.Ajax" Assembly="SharpMap.UI" %>
  3. <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
  4. <div style="background-color: #fff; color:#000;">
  5.     <asp:RadioButtonList ID="rblMapTools" runat="server" RepeatDirection="Horizontal">
  6. <asp:ListItem Value="0" onClick="ctl00_MainContent_ajaxMapObj.disableClickEvent(); ctl00_MainContent_ajaxMapObj.zoomAmount = 3;"  Selected="True">Zoom in</asp:ListItem>
  7. <asp:ListItem Value="1" onClick="ctl00_MainContent_ajaxMapObj.disableClickEvent(); ctl00_MainContent_ajaxMapObj.zoomAmount = 0.33333;" >Zoom out</asp:ListItem>
  8. <asp:ListItem Value="2" onClick="ctl00_MainContent_ajaxMapObj.enableClickEvent();">Query map</asp:ListItem>
  9. </asp:RadioButtonList>
  10. </div>
  11. <div style="background-color:#f1f1f1; border:solid 1px #000;">
  12. <smap:AjaxMapControl width="100%" height="400px" id="ajaxMap" runat="server"
  13. OnClickEvent="MapClicked" OnViewChange="ViewChanged" OnViewChanging="ViewChanging" />
  14. </div>
  15.  <div id="dataContents"></div> 
  16. <script type="text/javascript">
  17. //Fired when query is selected and map is clicked
  18. function MapClicked(event,obj)
  19. {
  20. var mousePos = SharpMap_GetRelativePosition(event.clientX,event.clientY,obj.container);
  21. var pnt = SharpMap_PixelToMap(mousePos.x,mousePos.y,obj);
  22. var field = document.getElementById('dataContents');
  23. field.innerHTML = "You clicked map at: " + pnt.x + "," + pnt.y;
  24. }
  25. //Fired when a new map starts to load
  26. function ViewChanging(obj)
  27. {
  28. var field = document.getElementById('dataContents');
  29. field.innerHTML = "Loading...";
  30. }
  31. //Fired when a map has loaded
  32. function ViewChanged(obj)
  33. {
  34. var field = document.getElementById('dataContents');
  35. field.innerHTML = "Current map center: " + obj.GetCenter().x + "," + obj.GetCenter().y;
  36. }
  37. </script>
  38. <p>
  39. <b>Navigation:</b>
  40. <ul>
  41. <li>Scroll-wheel: Zoom in/out</li>
  42. <li>Left-click'n'drag: Pan</li>
  43. <li>Left-click: Zoom in/out, query (select tool)</li>
  44. </ul>
  45. <b>Note:</b><br />
  46. In this demo querying it is only showed how you can catch the click-event.<br />
  47. Actual data-querying which would require ajax-style post-back is not implemented.
  48. </p>
  49. </asp:Content>