Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.1 KB

File metadata and controls

55 lines (40 loc) · 1.1 KB

💚 This is the latest document.

map.fromLatLngToPoint()

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

map.fromLatLngToPoint(position, callback);

Parameters

name type description
position ILatLng position
callback Function function(point) {}

Demo code

<div class="map" id="map_canvas"></div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div);

var center = map.getCameraTarget();

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

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();
  });

});