//<![CDATA[
var map;
var geocoder=null;
var points = new Array();
var coordinates = new Array();

function loadinici() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    //map.addControl(new GSmallMapControl());
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());         
    map.setCenter(new GLatLng(41.65,2.25494384765625), 8);
    //map.setMapType(G_HYBRID_MAP);
    puntsmapa();
  }
}
function showAddress(address) {
  if (geocoder) {
    geocoder.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);
        }
      }
    );
  }
}
function showAddressini(address) {
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
          map.setCenter(point, 13);
        }
      }
    );
  }
}    

var MarkersArray = [];  // global

function trobaCiutat(lat,longitud,id,i,titol,texte){
  var geocoder = new GClientGeocoder();
  var tinyIcon = new GIcon();
  tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
  tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  tinyIcon.iconSize = new GSize(12, 20);
  tinyIcon.shadowSize = new GSize(22, 20);
  tinyIcon.iconAnchor = new GPoint(6, 20);
  tinyIcon.infoWindowAnchor = new GPoint(5, 1);
  
  // Set up our GMarkerOptions object literal
  markerOptions = { icon:tinyIcon };
  var point = new GLatLng(lat,longitud); 
  window['marcador'+i] = new GMarker(point,markerOptions); 
  map.addOverlay(window['marcador'+i]);
  window['htmlm'+i] = "<b>"+titol+"</b><br /><p>"+texte+"</p><a href='index.php?seccio=Projectes&id="+id+"'>» + info</a>";
  GEvent.addListener(window['marcador'+i], "click", function() { window['marcador'+i].openInfoWindowHtml(window['htmlm'+i],{maxWidth:204}); });
}
function trobaCiutat2(lat,longitud,id,i,titol,texte){
  var geocoder = new GClientGeocoder();
  var tinyIcon = new GIcon();
  tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
  tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  tinyIcon.iconSize = new GSize(12, 20);
  tinyIcon.shadowSize = new GSize(22, 20);
  tinyIcon.iconAnchor = new GPoint(6, 20);
  tinyIcon.infoWindowAnchor = new GPoint(5, 1);
  
  // Set up our GMarkerOptions object literal
  markerOptions = { icon:tinyIcon };
  var point = new GLatLng(lat,longitud); 
  window['marcador'+i] = new GMarker(point,markerOptions); 
  map.addOverlay(window['marcador'+i]);
  window['htmlm'+i] = "<b>"+titol+"</b><br /><p>"+texte+"</p><a href='index.php?seccio=Projectes&id="+id+"'>» + info</a>";
  GEvent.addListener(window['marcador'+i], "click", function() { window['marcador'+i].openInfoWindowHtml(window['htmlm'+i],{maxWidth:204}); });
  map.setCenter(point, 13);
}
//]]>

