I used this gmap api code for building overlay div with image: http://jsfiddle.net/doktormolle/QRuW8/. it works for desktop with mouse, but not working with touch event. please, help me.
I tried to do it next:
google.maps.event.addDomListener(container,
‘touchstart’,
function(e){
this.style.cursor=’move’;
that.map.set(‘draggable’,false);
that.set(‘origin’,e);
that.moveHandler = google.maps.event.addDomListener(that.get('map').getDiv(),
'touchmove',
function(e){
let touch = e.touches[0] || e.changedTouches[0];
var origin = that.get('origin'),
left = origin.clientX-touch.clientX,
top = origin.clientY-touch.clientY,
pos = that.getProjection()
.fromLatLngToDivPixel(that.get('position')),
latLng = that.getProjection()
.fromDivPixelToLatLng(new google.maps.Point(pos.x-left,
pos.y-top));
that.set('origin',e);
that.set('position',latLng);
that.draw();
});
}
);
google.maps.event.addDomListener(container,'touchancel',function(e){
that.map.set('draggable',true);
this.style.cursor='default';
google.maps.event.removeListener(that.moveHandler);
});
google.maps.event.addDomListener(container,'touchend',function(e){
that.map.set('draggable',true);
this.style.cursor='default';
google.maps.event.removeListener(that.moveHandler);
});
but it doesn’t work. what do I make wrong? thanks