In my app I am using google maps and I am creating locations on the maps once the user right clicks. I have this event doing the trick for me
google.maps.event.addListener(map, 'rightclick', function (e) {
if (checkDistance(e.latLng)) {
if (viewModel.haveRolesToDoStuffOnProjectLevel()) {
geocoder.geocode({ location: e.latLng }, function (result) {
if (result.length > 0) {
var data = {
name: result[0].formatted_address.split(",")[0],
location: e.latLng,
address: result[0].formatted_address
}
if (viewModel.oldLocation()) {
moveLocationCreate(data);
} else {
startLocationCreate(data);
}
}
});
}
}
});
Everything is working fine until I open the app in mobile. On mobile the rightclick event won't fire. I have searched to find a way to have something like long click on mobile but it is not working. Can anyone help me finding a solution for this?
if you try this google maps event demo site on your phone/tablet, you would realize nothing happen even when you do a long click. It just means Google Maps support no tablet events.
But with jQuery, you can detect a long click, or other "mobile only" events. However, jQuery has no knowledge of the maps and, therefore, do tell you where you clicked on.
So one solution to that might be to use both, the Google Maps Click event, and the jQuery tabhold event.
First, let tabhold
set a flag, to indicate that this click function is from tabhold
; then on the onclick function, check if this current click event is from tabhold, if so, perform the action.
I have a quick [demo on jsfiddle][4], I just copied and pasted some code so it looks kind of ugly. But hopefully it helps.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다