AjaxMapControl zoomout/zoomin

Aug 9, 2009 at 11:29 AM

Hi all

I run demo and it works well but when If I make new page that use ajaxmapcontrol I have problem in zoomout and when I select zoomout it works as zoomin and show this error:Microsoft JScript runtime error: 'ctl00_MainContent_ajaxMapObj' is undefined 


<asp:RadioButtonList ID="rblMapTools" runat="server" RepeatDirection="Horizontal">
  <asp:ListItem Value="0" onClick="ctl00_MainContent_ajaxMapObj.disableClickEvent(); ctl00_MainContent_ajaxMapObj.zoomAmount = 3;"  >Zoom in</asp:ListItem>
  <asp:ListItem Value="1" onClick="ctl00_MainContent_ajaxMapObj.disableClickEvent(); ctl00_MainContent_ajaxMapObj.zoomAmount = 0.3333;" Selected="True">Zoom out</asp:ListItem>
  <asp:ListItem Value="2" onClick="ctl00_MainContent_ajaxMapObj.enableClickEvent();">Query map</asp:ListItem>
<div style="background-color:#f1f1f1; border:solid 1px #000;">
 <smap:AjaxMapControl width="100%" height="400px" id="ajaxMap" runat="server"
 OnClickEvent="MapClicked" OnViewChange="ViewChanged" OnViewChanging="ViewChanging" UseCache="True" ResponseFormat="MapHandler.aspx?Width=[WIDTH]&Height=[HEIGHT]&Zoom=[ZOOM]&X=[X]&Y=[Y]" />
 <div id="dataContents"></div>

<script type="text/javascript">
function MapClicked(event,obj)
 var mousePos = SharpMap_GetRelativePosition(event.clientX,event.clientY,obj.container);
 var pnt = SharpMap_PixelToMap(mousePos.x,mousePos.y,obj);
 var field = document.getElementById('dataContents');
 field.innerHTML = "You clicked map at: " + pnt.x + "," + pnt.y;
function ViewChanging(obj)
 var field = document.getElementById('dataContents');
 field.innerHTML = "Loading...";
function ViewChanged(obj)
 var field = document.getElementById('dataContents');
 field.innerHTML = "Current map center: " + obj.GetCenter().x + "," + obj.GetCenter().y; 

<font size="2">



page_load (){

 ajaxMap.Map = MapHelper.InitializeMap(new System.Drawing.Size(10, 10));
        if (!Page.IsPostBack && !Page.IsCallback)
            ajaxMap.Map.Center = new SharpMap.Geometries.Point(0, 20);
            ajaxMap.FadeSpeed = 10;
            ajaxMap.ZoomSpeed = 10;
            ajaxMap.Map.Zoom = 360;

        ajaxMap.ResponseFormat = "maphandler.ashx?MAP=SimpleWorld&Width=[WIDTH]&Height=[HEIGHT]&Zoom=[ZOOM]&X=[X]&Y=[Y]";


Can any body help me ?

Aug 9, 2009 at 5:43 PM
Edited Aug 9, 2009 at 5:47 PM

Hi sa_84, ctl00_MainContent_ajaxMapObj represents the object id of the javascript map object as it is in the browser - the real id is generated dynamically from the control heirarchy that the control sits in (see INamingContainer). At a guess you copied the code from the demo but the ids are different because the control sits in a different heirarchy in your page. You will need to investigate the rendered source within the browser to find out what the real id is or consider using inline code blocks such as <%= ajaxMapObject.ClientID %> in your markup. hth jd

Aug 11, 2009 at 6:00 AM

Hi Jahndiss,thank u for your answer but <%= ajaxMapObject.ClientID %> return my ajaxobject Name,and I don't know how to use it to this problem 

Aug 11, 2009 at 11:48 AM

hi sa_84, something like:

<asp:RadioButtonList ID="rblMapTools" runat="server" RepeatDirection="Horizontal">
  <asp:ListItem Value="0" onClick="<%= ajaxMapObject.ClientID%>.disableClickEvent(); <%= ajaxMapObject.ClientID%>.zoomAmount = 3;"  >Zoom in</asp:ListItem>
  <asp:ListItem Value="1" onClick="<%= ajaxMapObject.ClientID%>.disableClickEvent(); <%= ajaxMapObject.ClientID%>.zoomAmount = 0.3333;" Selected="True">Zoom out</asp:ListItem>
  <asp:ListItem Value="2" onClick="<%= ajaxMapObject.ClientID%>.enableClickEvent();">Query map</asp:ListItem>
Aug 11, 2009 at 11:49 AM

Hi, when I run ajaxMapcontrol,it will lock in IE and does not work after min zoomout and max zoomin ,Can you help me,plz?     

Aug 11, 2009 at 11:52 AM

Hi Johndiss ,Thank you  for your help,It was useful and my zoomout problem solved 

Aug 11, 2009 at 11:56 AM

But another problem is: when I run ajaxMapcontrol,it will lock in IE and does not work after min zoomout and max zoomin ,Can you help me,plz?

Aug 11, 2009 at 12:27 PM

Hi sa_84, unfortunately I do not use the ajax control.. cheers jd