煎茶触摸 ->谷歌地图标记不响应触摸

发布于 2024-11-28 05:04:36 字数 880 浏览 1 评论 0原文

我还有另一个问题需要解决,因为它相当令人恼火。我开发一个应用程序已经有一段时间了,我设法让它运行良好。

具体来说,谷歌地图功能应该有出现的标记,当您单击它们时,屏幕应该放大并显示有关标记的一些信息。现在,我已经对此进行了编码,当您在 Chrome 上测试它时,它可以完美地工作。但是当我尝试将其移植到选项卡设备本身(Samsun Galaxy)时,每当我尝试触摸任何标记时都没有任何活动。

我对此感到相当困惑和恼怒,因为触摸标记的动作应该与使用鼠标单击它相同,我没有弄错吗?我想知道是否有其他人可以给我任何帮助,因为这是一件小事,给我带来了很大的麻烦。

我在下面添加的代码:

var marker_icon = new google.maps.MarkerImage('images/map/' + thisIcon + '.png', new google.maps.Size(32, 32));

trafficMarker = new google.maps.Marker({
  position: new google.maps.LatLng(TrfAl.lat, TrfAl.lon),
  animation: google.maps.Animation.DROP,
  map: mapPanel,
  icon: marker_icon,
  id: 'trafficAlertPanel' + i,
  componentId: 'trafficAlertPanel' + i,
});
markerArray[i]=trafficMarker;

google.maps.event.addListener(trafficMarker, 'click', function(){
  console.log('clicked!');
  LoadIncidentMap(this.id.substring(17));
});

I have another question which needs resolving as it is rather irritating. I have been working on an app for a while and i managed to get it working nicely.

Specifically, the google map feature is supposed to have markers which appear and when you click on them, the screen is supposed to zoom in and display some information regarding the marker. Now, I have coded this in and it works perfectly when you test it out on Chrome. But when I tried to port it over to the tab device itself (Samsun Galaxy), there is no activity whenever i try to touch the markers whatsoever.

I am rather baffled and miffed by this, as the action of touching the marker should be the same as clicking on it using a mouse, am I not mistaken? I was wondering if anyone else could give me any help with this, as it is something minor which is causing one hell of a hiccup for me.

The code I have added below:

var marker_icon = new google.maps.MarkerImage('images/map/' + thisIcon + '.png', new google.maps.Size(32, 32));

trafficMarker = new google.maps.Marker({
  position: new google.maps.LatLng(TrfAl.lat, TrfAl.lon),
  animation: google.maps.Animation.DROP,
  map: mapPanel,
  icon: marker_icon,
  id: 'trafficAlertPanel' + i,
  componentId: 'trafficAlertPanel' + i,
});
markerArray[i]=trafficMarker;

google.maps.event.addListener(trafficMarker, 'click', function(){
  console.log('clicked!');
  LoadIncidentMap(this.id.substring(17));
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔嚣张 2024-12-05 05:04:36

由于某种原因,在 Android 和 iOS 上点击时不会触发点击事件。一种解决方法是使用“mousedown”事件,该事件将在点击时触发。

google.maps.event.addListener(trafficMarker, 'mousedown', function(){
    console.log('clicked!');
    LoadIncidentMap(this.id.substring(17));
});

For some reason click events don't fire for taps on android and iOS. One work-around is to use the 'mousedown' event instead, which will fire on tap.

google.maps.event.addListener(trafficMarker, 'mousedown', function(){
    console.log('clicked!');
    LoadIncidentMap(this.id.substring(17));
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文