Place marker on google maps api with html button

后端 未结 1 1603
刺人心
刺人心 2021-01-29 06:48

(I\'m learning on my own, I know my code is messy, inb4 sorry) I have a table with some data and a button, I want that when I press the button a marker appears on the map in the

1条回答
  •  伪装坚强ぢ
    2021-01-29 07:27

    Is this what you're looking for?

    The addmarker function, being called by the button agregar, was inside the myMap function. I have separated them.

    I have also simplified your map initialization and the marker "setter", assigning new objects directly to properties.

    Fiddle:

    https://jsfiddle.net/cbao9wLg/62/

    $('#button').click(function() {
      addmarker('-22.3157017', '-49.0660877', 'Infowindow test');
    });
    $('#button2').click(function() {
      addmarker('-23.5936152', '-46.5856465', 'Infowindow test2');
    });
    
    
    
    

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