Add a marker to an image in javascript?

后端 未结 1 1370
梦如初夏
梦如初夏 2020-12-13 21:40

Anyone know how I can add a marker to an image (not a map) in Javascript?

Ideally I\'d like a handler that behaves much like adding a marker to a map - i.e. onclick

1条回答
  •  隐瞒了意图╮
    2020-12-13 22:21

    Yes, it is possible.

    Although it's totally doable with just javascript, I would use some kind of library like JQuery.

    The approach would be to have an img-element with your marker, and then add a click-handler to the image you want to use as your "map" which moves your marker to where the element was clicked.

    Here is an untested example:

    
    
    
    
    

    Edit: And this is totally possible without JQuery too, of course. Below is a code-example of just that.

    
    
    
    
    

    0 讨论(0)
提交回复
热议问题