Search code examples
jquerygoogle-mapsjquery-gmap3

.html() not show result in jquery


this is code:

$(function () {

  $("#test").gmap3({
    marker: {
      latLng: [46.578498, 2.457275],
      options: {
        draggable: true
      },
      events: {
        dragend: function (marker) {
          var position = (marker.getPosition());
          //alert (position)
          //alert($("#position").html(position));
          //alert($("#map").append('position: ',position));
          $("#map").append(marker.getPosition());
        }

      }
    },
    map: {
      options: {
        zoom: 5
      }
    }
  });
});

this is gmap3 for google map work true , problem is here :

 dragend: function (marker) {
     var position = (marker.getPosition());
     $("#map").html(position);
 }

html:

<div id="map" > </div>
<div id="position" > </div>

when use alert show position number corectly but just dont show in div


Solution

  • Its an typeof Object, Try using $("#map").html(position.toString()); instead so you should get an output.

    Also, you can just do var position = marker.getPosition(); without extra brackets. Cheers.