I\'m using Google Maps with jQuery Mobile.
I can bind a click event to the map easily enough, but is there a way to bind a long click? I\'d like to add a marker to
For anyone looking for a solution, I got this on the Google Maps forums, and it does the trick.
function LongClick(map, length) {
this.length_ = length;
var me = this;
me.map_ = map;
google.maps.event.addListener(map, 'mousedown', function(e) { me.onMouseDown_(e) });
google.maps.event.addListener(map, 'mouseup', function(e) { me.onMouseUp_(e) });
}
LongClick.prototype.onMouseUp_ = function(e) {
var now = +new Date;
if (now - this.down_ > this.length_) {
google.maps.event.trigger(this.map_, 'longpress', e);
}
}
LongClick.prototype.onMouseDown_ = function() {
this.down_ = +new Date;
}
new LongClick(map, 300);
google.maps.event.addListener(map, 'longpress', function(event) {
do stuff...
}