material icon indicating copy to clipboard operation
material copied to clipboard

Problem with Leaflet / Mapbox.js

Open marvinernst opened this issue 11 years ago • 16 comments

I have a problem building an app with a leaflet map.

There is no click-event fired when clicking on a marker on the map. This is because angular-material is catching all click-events that are not from material itself.

Any idea how i could fix this?

marvinernst avatar Jan 27 '15 12:01 marvinernst

Can you provide a Codepen or Plunker so we can help you debug?

marcysutton avatar Jan 27 '15 18:01 marcysutton

Hi, I have made a small Codepen showing the problem. http://codepen.io/anon/pen/QwMEdq

It doesn't work because of this piece of code, but if i remove it every click gets fired twice.

document.addEventListener('click', function(ev) {
  // Prevent clicks unless they're sent by material
  if (!ev.$material) {
    ev.preventDefault();
    ev.stopPropagation();
  }
}, true);

marvinernst avatar Jan 28 '15 07:01 marvinernst

This issue popped up with mdGestures, and is similar to https://github.com/angular/material/issues/1326. Reviewing it with @ajoslin.

marcysutton avatar Jan 29 '15 02:01 marcysutton

There are several ways to fix this, I'll have to think about it.

ajoslin avatar Jan 29 '15 02:01 ajoslin

Leaflet will work on desktop now. On Wed, Jan 28, 2015 at 18:39 Marcy Sutton [email protected] wrote:

This issue popped up with mdGestures, and is the same issue as #1326 https://github.com/angular/material/issues/1326. Reviewing it with @ajoslin https://github.com/ajoslin.

— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/1300#issuecomment-71959183.

ajoslin avatar Jan 29 '15 03:01 ajoslin

It may also work on mobile. Could you test it and report back your results? On Wed, Jan 28, 2015 at 19:39 Andrew Joslin [email protected] wrote:

Leaflet will work on desktop now. On Wed, Jan 28, 2015 at 18:39 Marcy Sutton [email protected] wrote:

This issue popped up with mdGestures, and is the same issue as #1326 https://github.com/angular/material/issues/1326. Reviewing it with @ajoslin https://github.com/ajoslin.

— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/1300#issuecomment-71959183.

ajoslin avatar Jan 29 '15 03:01 ajoslin

I've tested on desktop and everything is working perfectly. Tests on mobile will follow.

marvinernst avatar Jan 29 '15 08:01 marvinernst

Closing for now, let us know if there is still an issue.

marcysutton avatar Jan 30 '15 18:01 marcysutton

@ajoslin @marcysutton I have this issue on both chrome and safari for iOS with v0.9.0-rc3.

Leaflet click events are firing on desktop, but nothing on mobile.

Firmware: iOS 8.3 Safari: 8 Chrome: v42.0.2311.47

dgavigan avatar May 03 '15 11:05 dgavigan

For mobile solutions that are also using jQuery, you can now use $mdGestureProvider in

   app = angular.module('MyApp', ['ngMaterial'])
      .config(function( $mdGestureProvider ) {
          $mdGestureProvider.skipClickHijack();
      });

This will configure $mdGesture to not intercept clicks (stop propagation and prevent defaults).

If your issues persists, please open a new issue. Do not comment on this one.

ThomasBurleson avatar May 03 '15 16:05 ThomasBurleson

That did the trick! Thanks a mil

dgavigan avatar May 03 '15 16:05 dgavigan

@dg1202 - #ftw, excellent. Thanks for using Angular Material.

ThomasBurleson avatar May 03 '15 16:05 ThomasBurleson

I had the same issue with Leaflet maps. This fix worked for me.

chriseyhorn avatar May 20 '15 01:05 chriseyhorn

thx a ton...

magnolo avatar Mar 02 '16 20:03 magnolo

I'm using Angular Leaflet Directive with Angular Material Design. The controls on the map on mobile devices don't work. If I use $mdGestureProvider.skipClickHijack();, what features of Material Design do I lose? Am I making a sacrifice?

adam-s avatar Mar 20 '16 22:03 adam-s

@adam-s I just tried to use one of the md-swipe directives e.g md-swipe-right, and they do not work if I use the $mdGestureProvider.skipClickHijack();-call. I ended up using angular's ng-touch directive instead.

johnedvard avatar Aug 03 '16 06:08 johnedvard