2 mar 2009

Dodawnie Markera w oparciu w współrzędne pikselowe

Utworzenie ikony:

var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(6, 20);

Dodanie markera w lewym dolnym rogu mapy:

map.addOverlay(
  new GMarker(map.getBounds().getSouthWest(), 
  {
    icon: icon, draggable: true
  }
));

Dodanie markera w lewym dolnym rogu mapy + (10,10) pikseli:

var point1 = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom())

map.addOverlay(
 new GMarker(map.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(point1.x+10, point1.y-10), map.getZoom()), {icon: icon, draggable: true})
);