# Map click after move doesn't resolve properly

**URL:** <https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336>\
**Category:** MVC\
**Created:** [October 22, 2015, 1:14pm UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336 "2015-10-22T13:14:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jay](https://community.thinkgeo.com/u/Jay)\
**Post date:** [October 22, 2015, 1:14pm UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/1 "2015-10-22T13:14:19Z")

</div>

I’m&nbsp;displaying&nbsp;a&nbsp;map&nbsp;within&nbsp;a&nbsp;KendoUI&nbsp;popup&nbsp;window.&nbsp;My&nbsp;understanding&nbsp;of&nbsp;this&nbsp;is&nbsp;that&nbsp;it&nbsp;basically&nbsp;emulates&nbsp;a&nbsp;separate&nbsp;window&nbsp;via&nbsp;dynamic&nbsp;insertion&nbsp;of&nbsp;a&nbsp;div&nbsp;onto&nbsp;the&nbsp;existing&nbsp;page.  
  
  
  
When&nbsp;the&nbsp;map&nbsp;first&nbsp;displays,&nbsp;everything&nbsp;is&nbsp;fine.&nbsp;I&nbsp;display&nbsp;a&nbsp;popup&nbsp;with&nbsp;some&nbsp;information&nbsp;about&nbsp;what&nbsp;was&nbsp;clicked&nbsp;via  
  
  
  
function&nbsp;OnClientClickMap(e)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popup.lonlat&nbsp;=&nbsp;e.worldXY;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Map.ajaxCallAction(‘Controller’,&nbsp;‘ClickOnMap’,&nbsp;{&nbsp;‘x’:&nbsp;e.worldXY.lon,&nbsp;‘y’:&nbsp;e.worldXY.lat&nbsp;},&nbsp;function&nbsp;(result)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popup.setContentHTML(result.get\_responseData());  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popup.show();  
&nbsp;&nbsp;&nbsp;&nbsp;});  
}&nbsp;  
  
  
  
However,&nbsp;if&nbsp;I&nbsp;then&nbsp;move&nbsp;that&nbsp;window&nbsp;about&nbsp;the&nbsp;page,&nbsp;say&nbsp;up&nbsp;and&nbsp;to&nbsp;the&nbsp;left,&nbsp;and&nbsp;then&nbsp;click&nbsp;on&nbsp;the&nbsp;map&nbsp;in&nbsp;the&nbsp;same&nbsp;spot,&nbsp;the&nbsp;worldXY&nbsp;seems&nbsp;to&nbsp;have&nbsp;shifted&nbsp;by&nbsp;the&nbsp;same&nbsp;amount&nbsp;that&nbsp;I&nbsp;moved&nbsp;the&nbsp;window.&nbsp;That&nbsp;is,&nbsp;rather&nbsp;than&nbsp;the&nbsp;popup&nbsp;displaying&nbsp;from&nbsp;where&nbsp;I&nbsp;clicked,&nbsp;it&nbsp;is&nbsp;now&nbsp;offset&nbsp;by&nbsp;the&nbsp;window&nbsp;moved&nbsp;amount.  
  
  
  
Looking&nbsp;at&nbsp;the&nbsp;event&nbsp;details,&nbsp;I&nbsp;see&nbsp;that&nbsp;layerX&nbsp;and&nbsp;layerY&nbsp;remain&nbsp;with&nbsp;the&nbsp;same&nbsp;values&nbsp;as&nbsp;before&nbsp;the&nbsp;move,&nbsp;but&nbsp;clientX/Y,&nbsp;pageX/Y,&nbsp;screenX/Y&nbsp;are&nbsp;all&nbsp;shifted&nbsp;by&nbsp;an&nbsp;amount&nbsp;similar&nbsp;to&nbsp;the&nbsp;move,&nbsp;as&nbsp;are&nbsp;of&nbsp;course&nbsp;worldXY&nbsp;and&nbsp;xy.  
  
  
  
And&nbsp;interestingly&nbsp;enough,&nbsp;it&nbsp;seems&nbsp;to&nbsp;be&nbsp;determined&nbsp;from&nbsp;the&nbsp;first&nbsp;cilck.&nbsp;If&nbsp;I&nbsp;move&nbsp;the&nbsp;window&nbsp;immediately,&nbsp;then&nbsp;click,&nbsp;that&nbsp;is&nbsp;resolved&nbsp;properly,&nbsp;but&nbsp;a&nbsp;subsequent&nbsp;move&nbsp;and&nbsp;click&nbsp;exhibits&nbsp;the&nbsp;offset&nbsp;behavior.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [October 23, 2015, 2:51am UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/2 "2015-10-23T02:51:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jay](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jay](https://community.thinkgeo.com/u/Jay)\
**Post date:** [October 27, 2015, 2:05pm UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/3 "2015-10-27T14:05:25Z")

</div>

Hi&nbsp;Don.&nbsp;I’ve&nbsp;attached&nbsp;a&nbsp;sample&nbsp;that&nbsp;lets&nbsp;you&nbsp;reproduce&nbsp;the&nbsp;problem,&nbsp;more&nbsp;or&nbsp;less.It’s&nbsp;not&nbsp;exactly&nbsp;what&nbsp;I’m&nbsp;seeing,&nbsp;but&nbsp;it’s&nbsp;very&nbsp;close.&nbsp;You’ll&nbsp;need&nbsp;to&nbsp;update&nbsp;the&nbsp;references.  
  
[MovingDivBug.zip](https://community.thinkgeo.com/uploads/default/original/2X/1/194e04f117830c8276a2300f716ff1fe3a9fd0ed.zip) (51.5 KB)

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [October 28, 2015, 5:53am UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/4 "2015-10-28T05:53:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [October 29, 2015, 7:12am UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/5 "2015-10-29T07:12:33Z")

</div>

Hi&nbsp;Jay,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;still&nbsp;work&nbsp;for&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don

---

<div class="post-metadata">

**Author:** ![Jay](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@Jay](https://community.thinkgeo.com/u/Jay)\
**Post date:** [October 29, 2015, 9:07am UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/6 "2015-10-29T09:07:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [October 30, 2015, 5:44am UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/7 "2015-10-30T05:44:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [November 8, 2015, 8:57pm UTC](https://community.thinkgeo.com/t/map-click-after-move-doesnt-resolve-properly/4336/8 "2015-11-08T20:57:07Z")

</div>

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

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

  
Please&nbsp;let&nbsp;us&nbsp;know&nbsp;if&nbsp;any&nbsp;other&nbsp;questions.  
  
  
  
Thanks,  
  
  
  
Troy
