diff --git a/cloud/html/js/preview.js b/cloud/html/js/preview.js index 642b6050a..bb17e5fc9 100644 --- a/cloud/html/js/preview.js +++ b/cloud/html/js/preview.js @@ -16,7 +16,10 @@ var preview={ sensorctx.marker.closeTooltip(); preview.play(div,sensor); + var offset={x:0,y:0}; div.attr('draggable','true').bind('dragstart',function (e) { + var divoffset=$(this).offset(); + offset={x:e.pageX-divoffset.left,y:e.pageY-divoffset.top}; e.originalEvent.dataTransfer.setData("application/json",JSON.stringify(sensor)); page.find("#mapCanvas").unbind('dragover').on('dragover', function (e) { e.preventDefault(); @@ -24,7 +27,8 @@ var preview={ e.preventDefault(); var div=$("[template] [preview-template]").clone().addClass("max-size"); var icon=L.divIcon({html:div[0],iconSize:[300,200],iconAnchor:[0,0]}); - var marker=L.marker(map.mouseEventToLatLng(e),{icon:icon,draggable:true}).addTo(page.data('preview').layer); + var e1={clientX:e.clientX-offset.x,clientY:e.clientY-offset.y}; + var marker=L.marker(map.mouseEventToLatLng(e1),{icon:icon,draggable:true}).addTo(page.data('preview').layer); marker._zoomargs={zoom:map.getZoom(),width:300,height:200}; $(marker._icon).addClass("page-home-preview-screen"); var sensor1=JSON.parse(e.originalEvent.dataTransfer.getData("application/json")); diff --git a/cloud/html/js/stats.js b/cloud/html/js/stats.js index dbf222c96..d4c987999 100644 --- a/cloud/html/js/stats.js +++ b/cloud/html/js/stats.js @@ -70,7 +70,10 @@ var stats={ }, create: function (sensorctx, sensor, page, map, create_chart_icon) { sensorctx.text=L.tooltip({permanent:true,direction:'center',className:'tooltip_text'}); + var offset={x:0,y:0}; var div=$('
').on('dragstart', function (e) { + var divoffset=$(this).offset(); + offset={x:e.pageX-divoffset.left,y:e.pageY-divoffset.top}; e.originalEvent.dataTransfer.setData('application/json',JSON.stringify(sensor)); page.find("#mapCanvas").unbind('dragover').on('dragover', function (e) { e.preventDefault(); @@ -78,7 +81,8 @@ var stats={ e.preventDefault(); var div1=div.clone().removeAttr('draggable').css({width:'100%',height:'100%'}); var icon1=L.divIcon({html:div1[0],iconSize:[350,200],iconAnchor:[0,0]}); - var marker1=L.marker(map.mouseEventToLatLng(e),{icon:icon1,draggable:true}).addTo(page.data('stat').layer); + var e1={clientX:e.clientX-offset.x,clientY:e.clientY-offset.y}; + var marker1=L.marker(map.mouseEventToLatLng(e1),{icon:icon1,draggable:true}).addTo(page.data('stat').layer); marker1._sensor=JSON.parse(e.originalEvent.dataTransfer.getData('application/json')); marker1._chart=stats.create_chart(div1.find('canvas')); marker1._zoomargs={zoom:map.getZoom(),width:350,height:200};