28 Cze 2010

Rysowanie boxa na mapie

function rysowanieBoxa() {
 if (boxes != null) {
  for (var i = 0; i < boxes.length; i++) {
   var vertices = [
   boxes[i].getSouthWest(),
   new GLatLng(boxes[i].getSouthWest().lat(),
    boxes[i].getNorthEast().lng()),
   boxes[i].getNorthEast(),
   new GLatLng(boxes[i].getNorthEast().lat(),
    boxes[i].getSouthWest().lng()),
   boxes[i].getSouthWest()
   ];
   var polygon = new GPolyline(vertices, '#ff0000', 1, 1.0);
   map.addOverlay(polygon);
  }
 }
}
28 Cze 2010

Przygotownie boxa w obrębie punktu

var marker = new GMarker(point,{title: address});
map.addOverlay(marker);

boxes=[];
boxes[0]=
new google.maps.LatLngBounds(
new google.maps.LatLng(point.lat()-dist*0.01,point.lng()-dist*0.02),
new google.maps.LatLng(point.lat()+dist*0.01,point.lng()+dist*0.02)
);
2 Mar 2009

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

<img loading="lazy" 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

20 Sty 2009

Przesunięcie mapy o 0,100 pikseli, panBy

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(7, 20);

var marker = new GMarker(new GLatLng(52.50378799438477, 13.31508636474609), icon)
map.addOverlay(marker);
marker.openInfoWindowHtml('<b>Hotel</b>');
map.panBy(new GSize(0, 100));