ThinkGeo.com    |     Documentation    |     Premium Support

Disable zoom on double click

 By default the map zooms in and recenters if a user double clicks, I want to use double click for something else.


 


How do I disable this functionality?


 


Thanks,


 


Eric



Hello Eric, 
  
 Thanks for your sample, you can override the clientside doubleclick function to did this. 
  
 Map1.OnClientDoubleClick = "alert(123);"; 
  
 Also there are two more property you may will use. 
  
 Map1.MapTools.MouseMapTool.IsMouseWheelDisabled = false; 
 Map1.MapTools.MouseMapTool.Enabled = false; 
  
 First one can disable the mouse wheel function and second one can disable all mouse function. 
  
 Any more questions please feel free to let us know. 
  
 Regards, 
  
 Gary

Thanks for your reply but you but I am still having problems. 
  
 I want to disable zoom on double click, not the scroll wheel, and not all mouse functions. 
  
 I am using Map1.OnClientDoubleClick = "MapDoubleClick" and this executes the client side function I have written, but the map still zooms as well. 
  
 I want to disable the zoom on double click. 
  
 Thank you, 
  
 Eric 


Hello Eric, 
  
 Thanks for your further information, I have tested  Map1.OnClientDoubleClick property in HowDoISamples, it works fine, double click didn’t raise the zoom funciton any more. 
  
  Map1.OnClientDoubleClick = “test();”;  
  
 and function test() {    } in the aspx page, it’s enough, could you please provide your sample, we can help you to reslove this problem. 
  
 Regards, 
  
 Gary

Hello Eric, 
  
 Thanks for your further information, I have tested Map1.OnClientDoubleClick property in HowDoISamples, it works fine, double click didn’t raise the zoom funciton any more. 
  
 Map1.OnClientDoubleClick = “test();”; 
  
 and function test() { } in the aspx page, it’s enough, could you please provide your sample, we can help you to reslove this problem. 
  
 Regards, 
  
 Gary

 





        protected void Page_Load(object sender, EventArgs e)
        {
            OverlayClass = new mapOverlays();

            string sessionidvar = "-1";
            string statepath = @"C:\Map_Data\CA\";
            if (!IsPostBack)
            {
                Map1.MapUnit = GeographyUnit.DecimalDegree;
                InMemoryFeatureLayer BaseFeatureLayer = new InMemoryFeatureLayer();
                Map1.StaticOverlay.Layers.Add(BaseFeatureLayer);

                GeoCollection<Overlay> MapOverlays = OverlayClass.GetOverlays(sessionidvar, "Empty", statepath);

                foreach (Overlay mapLOLs in MapOverlays)
                {
                    Map1.CustomOverlays.Add(mapLOLs);
                }

                Map1.MapTools.ScaleLine.Enabled = true;
                
                
                LoadingImageMapTool maploading = new LoadingImageMapTool();
                maploading.Enabled = true;
                Map1.MapTools.MouseMapTool.TrackZoomMaskType = TrackZoomMaskType.Alt;
                Map1.OnClientClick = "MapClientClick";
                Map1.OnClientDoubleClick = "MapClientDoubleClick";
                

                String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
                String callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}";
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
            }
        }



Also, could you please send me the link to the example you referenced in your last post?

Eric, 



Gary is out this week but I saw your post and recreated his sample and it stopped the map from zooming in on a double click. 



To recreate the sample I added the following line at the bottom of the Page_Load function in the "DisplayASimpleMap" How Do I Sample Applicaiton. 



Map1.OnClientDoubleClick = "test();"; 



Then in the markup on the client side i added the following javascript block: 


        function test() 
        {
        
        }
   Once I did that the sample app would no longer zoom in on a double click but I could still pan around and use the other tools. 



Thanks!



Your example does not zoom because it is bad code and throws a javascript error. 
  
 Map1.OnClientDoubleClick = "test();"; 
  
 should instead read 
  
 Map1.OnClientDoubleClick = "test"; 
  
 I need another way to disable the zoom on double click. 
  


Try it again but insert alert(‘TESTING’); into your js block.  You will see that it won’t execute the js properly. 
  
 Thanks

Hello Eric, 
  
 Thanks for your further information, actually I have tested this before, and it works fine, but I test today, it throw the exception, strange, I will dig deeper and let you know the result. 
  
 Regards, 
  
 Gary

Any Ideas, this is a problem for me.

Hello Eric, 



Thanks for your patience, we have fixed this problem, you can get the latest version 5.5.119.0 or later and use the code above to work. 



Please let us know if you still meet this problem. 



Regards, 



Gary



thanks 


Hello Eric, 
  
 You are welcome, please feel free to let us know your questions. 
  
 Regards, 
  
 Gary

Hi,
Is both OnDoubleClick(Server side Event) and OnClientDoubleClick(Client Side Event will work same time.

Code:
<Thinkgeo:Map ID=“wfMap” Height=“650px” Width=“100%” runat=“server” OnClick=“wfMap_Click”
OnDoubleClick=“wfMap_DoubleClick” OnExtentChanged=“wfMap_ExtentChanged” OnClientDoubleClick=“MapClientDoubleClick”>
</Thinkgeo:Map>

I want to execute double click function in server size but Zoom In operation(By Default) makes disable.
I don’t want to zoom in whenever double click on Map.

Please suggest me for fixing this issue.

Thanks,
Riyaz

Hi Riyaz,

The MapClientDoubleClick will be fired before the wfMap_DoubleClick. If it return false, then the server side event won’t be fired.

If you want to disable the mouse operate map(You cannot only handle double click), the code should like this:

<cc1:Map ID="Map1" runat="server" Height="600px" Width="800px" OnDoubleClick="Map1_DoubleClick"></cc1:Map>

 Map1.MapTools.MouseMapTool.Enabled = false;

    protected void Map1_DoubleClick(object sender, MapClickedEventArgs e)
    {
        throw new NotImplementedException();
    }

Regards,

Ethan