android google map marker placing

前端 未结 4 1598
故里飘歌
故里飘歌 2021-02-06 00:40

In my Android application I need to place marker at exact position on map. I pin a marker on map with 51.507351, -0.127758 (London) location. I used the following code to do the

4条回答
  •  借酒劲吻你
    2021-02-06 01:32

    The logic behind how the markers are anchored is something like this for a 4px-by-2px image:

            0,0      0.5,0.0        1,0
            *-----+-----+-----+-----*
            |     |     |     |     |
            |     |     |     |     |
      0,0.5 +-----+-----+-----+-----+ 1,0.5
            |     |     |   X |     |           (U, V) = (0.7, 0.6)
            |     |     |     |     |
            *-----+-----+-----+-----*
            0,1      0.5,1.0        1,1
    

    Also take into consideration that based on your bitmap resource, it could be positioned a little different than you would expect, because they actually approximate to the nearest snap position. So in the example above, your anchor points will snap to this position:

     *-----+-----+-----+-----*
     |     |     |     |     |
     |     |     |     |     |
     +-----+-----+-----X-----+   (X, Y) = (3, 1)
     |     |     |     |     |
     |     |     |     |     |
     *-----+-----+-----+-----*
    

    Documentation

提交回复
热议问题