Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 951 Bytes

File metadata and controls

42 lines (32 loc) · 951 Bytes

map.fromLatLngToPoint()

Convert the unit from LatLng to the pixels from the left/top of the map div.

<div class="map" id="map_canvas"></div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div);
map.one(plugin.google.maps.event.MAP_READY, function() {

  var center = map.getCameraTarget();

  map.addMarker({
    position: center,
    draggable: true,
    title: "Drag me!"
  }, function(marker) {
    marker.showInfoWindow();

    // Catch the marker drag event
    marker.on(plugin.google.maps.event.MARKER_DRAG_END, function(latLng) {
        // LatLng -> Point
        map.fromLatLngToPoint(latLng, function(point) {

          // Show on the marker
          marker
            .setTitle(
              "left : " + point[0].toFixed(1) + "px\n" + "top : " + point[1].toFixed(1) + "px"
            )
            .showInfoWindow();
        });

    });

  });
});