17 cze 2008

Szukanie wpółrzędnych adresu

function showAddress(address) {

  geo.getLatLng(
    address,
    function (point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(address);

        var point_s = marker.getPoint();
        lat = point_s.lat();
        lng = point_s.lng();
        document.getElementById("srchres").innerHTML = lat + ', ' + lng;
      }
    }
  );
}
5 kwi 2008

Tablica z opisem icon

var iconData = {
  "flag": { width: 29, height: 25 },
  "flag_shadow": { width: 20, height: 19 },
  "house": { width: 32, height: 32 },
  "house-shadow": { width: 59, height: 32 },
  "headquarters": { width: 32, height: 32 },
  "headquarters-shadow": { width: 59, height: 32 }
};
3 kwi 2008

Utworzenie ikony dla mapy

var baseIcon = new GIcon();
baseIcon.iconSize = new GSize(32, 32);
baseIcon.shadowSize = new GSize(56, 32);
baseIcon.iconAnchor = new GPoint(16, 32);
baseIcon.infoWindowAnchor = new GPoint(16, 0);
var ikona = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal3/icon21.png', null, 'http://maps.google.com/mapfiles/kml/pal3/icon21s.png');

var point = map.map.getCenter();
var marker = new GMarker(point, ikona);
28 mar 2008

Dodawanie Markera i opisu do mapy

Funkcja dodająca marker: 

function createMarker(point,  info) {  
    var marker = new GMarker(point);  
    GEvent.addListener(marker, "click", function() {  
        marker.openInfoWindowHtml(info);
    });  
    return marker;  
}

Wywołanie funkcji:

var marker = createMarker(map.getCenter(), 'Opis - chmórka');

Dodanie Markera do mapy:

map.addOverlay(marker);