单击鼠标即可获取图像映射的坐标

时间:2021-01-27 21:19:16

I have an html image map and I want to get the coordinates when a user clicks on the map.

我有一个html图像地图,我想在用户点击地图时获取坐标。

Is there a way to retrieve the map coordinates with a mouse click on the map?

有没有办法通过鼠标点击地图检索地图坐标?

2 个解决方案

#1


You could use the JQuery library and do the following:

您可以使用JQuery库并执行以下操作:

$(".link").click(function(e){
        e.pageX;
              e.pageY;
}

#2


Yes there is. But using only javascript could be very complex.

就在这里。但仅使用javascript可能非常复杂。

If you can you need to implement jquery and then check this link.

如果可以,您需要实现jquery,然后检查此链接。

If you are talking about a real map image (like google maps or something) once you get the mouse coordinates simply multiply by the map scale. :)

如果您正在谈论一个真实的地图图像(如谷歌地图或其他东西),一旦获得鼠标坐标,只需乘以地图比例。 :)

#1


You could use the JQuery library and do the following:

您可以使用JQuery库并执行以下操作:

$(".link").click(function(e){
        e.pageX;
              e.pageY;
}

#2


Yes there is. But using only javascript could be very complex.

就在这里。但仅使用javascript可能非常复杂。

If you can you need to implement jquery and then check this link.

如果可以,您需要实现jquery,然后检查此链接。

If you are talking about a real map image (like google maps or something) once you get the mouse coordinates simply multiply by the map scale. :)

如果您正在谈论一个真实的地图图像(如谷歌地图或其他东西),一旦获得鼠标坐标,只需乘以地图比例。 :)