Javascript 谷歌地图将光标更改为图像拾取偏移

Javascript 谷歌地图将光标更改为图像拾取偏移,javascript,css,google-maps,google-maps-api-3,cursor,Javascript,Css,Google Maps,Google Maps Api 3,Cursor,我已将谷歌地图光标更改为我自己的图像。这幅图像有一个明显的特点。该网站允许人们点击地图上的某个地方,在他们选择的确切纬度/经度处创建一个标记。 问题是,由于图像有一个特定的点(图像的底部中心),所以每个人都认为该点所在的位置就是标记的位置。相反,标记位于图像的左上角,并以相当数量的像素关闭 我需要的是一种偏移图像的方法,这样当单击发生时,它正好发生在图像的点所在的位置,而不是自动拾取的位于左上角的点 我曾试图在photoshop中将图像本身置于中心位置,但没有做到这一点。我已经浏览了谷歌地图AP

我已将谷歌地图光标更改为我自己的图像。这幅图像有一个明显的特点。该网站允许人们点击地图上的某个地方,在他们选择的确切纬度/经度处创建一个标记。 问题是,由于图像有一个特定的点(图像的底部中心),所以每个人都认为该点所在的位置就是标记的位置。相反,标记位于图像的左上角,并以相当数量的像素关闭

我需要的是一种偏移图像的方法,这样当单击发生时,它正好发生在图像的点所在的位置,而不是自动拾取的位于左上角的点

我曾试图在photoshop中将图像本身置于中心位置,但没有做到这一点。我已经浏览了谷歌地图API,但什么都没有出现


关于如何做到这一点,你有什么想法吗?

你可以在

演示:

Wow--这很好用!!非常感谢你!(还有——我试图对你的答案投赞成票,但在我获得15%的声誉之前我是不会同意的) pixelCoordinate = worldCoordinate * 2zoomLevel
  google.maps.event.addListener(map, 'click', function(e){      
       //assume a cursor with a size of 22*40

   var  //define the anchor, the base(top-left) is 0,0
        //bottom middle will be 11,40
       anchor         = new google.maps.Point(11,40),

        //the map-projection, needed to calculate the desired LatLng
       proj           = this.getProjection(),

        //clicked latLng
       pos            = e.latLng;

        //the power of the map-zoom
       power          = Math.pow(2,map.getZoom()),

        //get the world-coordinate
        //will be equal to the pixel-coordinate at zoom 0
       point          = proj.fromLatLngToPoint(pos),

        //calculate the new world-coordinate based on the anchor
       offsetPoint    = new google.maps.Point(
                                        (point.x*power+anchor.x)/power,
                                        (point.y*power+anchor.y)/power
                                       ),
        //convert it back to a LatLng
       offsetPosition = proj.fromPointToLatLng(offsetPoint);

       //done

       new google.maps.Marker({ position:offsetPosition, map:map});
  });