ThinkGeo.com    |     Documentation    |     Premium Support

Map click after move doesn't resolve properly

I’m displaying a map within a KendoUI popup window. My understanding of this is that it basically emulates a separate window via dynamic insertion of a div onto the existing page.



When the map first displays, everything is fine. I display a popup with some information about what was clicked via



function OnClientClickMap(e) {
     popup.lonlat = e.worldXY;
     Map.ajaxCallAction(‘Controller’, ‘ClickOnMap’, { ‘x’: e.worldXY.lon, ‘y’: e.worldXY.lat }, function (result) {
         popup.setContentHTML(result.get_responseData());
        popup.show();
    });




However, if I then move that window about the page, say up and to the left, and then click on the map in the same spot, the worldXY seems to have shifted by the same amount that I moved the window. That is, rather than the popup displaying from where I clicked, it is now offset by the window moved amount.



Looking at the event details, I see that layerX and layerY remain with the same values as before the move, but clientX/Y, pageX/Y, screenX/Y are all shifted by an amount similar to the move, as are of course worldXY and xy.



And interestingly enough, it seems to be determined from the first cilck. If I move the window immediately, then click, that is resolved properly, but a subsequent move and click exhibits the offset behavior.

Hi Jay, 
  
 Thanks for your question, I am sorry we don’t have more experiences about put our map on a movable div which implemented by 3rd part library like KendoUI. But I think this problem should because the client side calculate didn’t find correct left-top corner. 
  
 It looks I hadn’t find the event OnClientClickMap in MVC edition today, so if possible, could you please upload the sample which can reproduce the issue? It should be very helpful to see whether it can be fixed or whether is there any workaround. 
  
 Regards, 
  
 Don

Hi Don. I’ve attached a sample that lets you reproduce the problem, more or less.It’s not exactly what I’m seeing, but it’s very close. You’ll need to update the references.

MovingDivBug.zip (51.5 KB)

Hi Jay, 
  
 Thanks for you project, today I tried to make it run but failed because some reason, I think I can update the progress tomorrow. 
  
 Regards, 
  
 Don

Hi Jay,  
  
 We still work for it. 
  
 Regards, 
  
 Don

Hi Don. Does that mean you were able to get the solution to run? I downloaded what I had uploaded, and of course it works for me.

Hi Jay, 
  
 Yes we have make your sample run, thanks for your sample. 
  
 It looks we calculate the world coordinates based on the value ViewPortPx which provided by OpenLayers’ parameters. One of our developer is looking into it and see whether it can be solved. 
  
 Thanks, 
  
 Tang

Hi Jay,



In the mouseup event, please call the updateSize method to re-calculate the map size, it works fine for me:


$(document.body).on("mouseup"function (e) {
            $dragging.removeClass("draggable");
            $dragging = null;
 
            Map1.getOpenLayersMap().updateSize();
        });

Please let us know if any other questions.



Thanks,



Troy