2 mar 2009

Obrysowanie granic Polygonu

polygon = new GPolygon(points, "#00A000", 1, 1, "#00ff00", 0.1, {clickable: true});

var bounds = polygon.getBounds()
//for(var i=0;i<points.length;i++){bounds.extend(points[i])}

var pSW = bounds.getSouthWest();
var pNE = bounds.getNorthEast();

var pNW = new GLatLng(pSW.lat(), pNE.lng());
var pSE = new GLatLng(pNE.lat(), pSW.lng());

var points2 = [];
points2.push(pSW);
points2.push(pNW);
points2.push(pNE);
points2.push(pSE);
points2.push(pSW);
polygon2 = new GPolygon(points2, "#00A000", 1, 1, "#00ff00", 0.1, {clickable: true});
2 mar 2009

Przeliczenie pozycji kursora myszy na współrzędne latlng

<img decoding="async" fetchpriority="high" id="maska_img" src="moa.net.pl.jpg" width="300" height="300" onClick="testMaskClick()">
function testMaskClick() {

var IE = document.all ? true : false;
 if (IE) {
  tempX = event.clientX + document.body.scrollLeft;
  tempY = event.clientY + document.body.scrollTop;
 } else {
  tempX = e.pageX;
  tempY = e.pageY;
 }
 if (tempX < 0) tempX = 0;
 if (tempY < 0) tempY = 0;
 
 var point1 = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
var point = map.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(point1.x+tempX-300, point1.y-(650-tempY+20)), map.getZoom());

map.addOverlay(new GMarker(point));
}

300,20 - pozycja mapy na stronie
650 - wysokość mapy

2 mar 2009

Prosty zestaw styli do formularzy

body {background:white;line-height:17px;font-size:12px;font-family:tahoma, arial, helvetica, sans-serif;}
form  { padding: 0px; margin: 0px; display: inline; }
input { cursor: hand; }
.lista td { border-bottom: 1px solid #EDEDED; }
.lista td { padding-left: 10px; padding-right: 10px; }
.lista td .button { text-align: center; }
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})
);