﻿var map = null;
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

var geocoder = new GClientGeocoder();

var lats = [];
                var lngs = [];
                var info = [];
                
//javascript:void(prompt('',map.getCenter()));                    

                
function load() {
    if (GBrowserIsCompatible()) {
    
        if (document.getElementById("map") != null)
        {
        map = new GMap2(document.getElementById("map"));
        
        //map.setCenter(new GLatLng(51.26191485308451, -0.1318359375), 9);
        map.setCenter(new GLatLng(51.32889547080776, 0.296630859375), 9);
        map.addControl(new GLargeMapControl());
        
               
                
                //var marker = [];
                
                lats[0] = '51.440025';
                lngs[0] = '0.368001';
                info[0] = '<p style=\"color: black;\">Family Matters HQ</p>';
                
                lats[1] = '51.150053';
                lngs[1] = '0.871127';
                info[1] = '<p style=\"color: black;\">Ashford Gateway Centre<br />14 Park Mall<br />Ashford<br />Kent. TN24 8RY</p>';
                
                lats[2] = '51.153407';
                lngs[2] = '0.865536';
                info[2] = '<p style=\"color: black;\">Red Cross Hall</p>';
                
              
                lats[3] = '51.456959';
                lngs[3] = '0.142333';
                info[3] = '<p style=\"color: black;\">Bexley Natural Health Clinic & Crystal Shop</p>';
                
                lats[4] = '51.406701891531554';
                lngs[4] = '0.01956939697265625';
                info[4] = '<p style=\"color: black;\">The Centre for Counselling Training & Therapy</p>';
                
                lats[5] = '51.382755';
                lngs[5] = '0.517324';
                info[5] = '<p style=\"color: black;\">Chatham British Red Cross</p>';
                
                lats[6] = '51.111031';
                lngs[6] = '-0.189272';
                info[6] = '<p style=\"color: black;\">Crawley Volunteer Centre</p>';
                
                lats[7] = '51.443015';
                lngs[7] = '0.216572';
                info[7] = '<p style=\"color: black;\">Dartford Natural Health Centre</p>';
                
                lats[8] = '51.44532818234795';
                lngs[8] = '0.2134394645690918';
                info[8] = '<p style=\"color: black;\">North West Kent CVS</p>';
                
                lats[9] = '51.4434156985154';
                lngs[9] = '0.23792266845703125';
                info[9] = '<p style=\"color: black;\">Resource Centre</p>';
                
                lats[10] = '51.449862';
                lngs[10] = '0.059463';
                info[10] = '<p style=\"color: black;\">Wellington Counselling</p>';
                
                lats[11] = '51.313526';
                lngs[11] = '0.890856';
                info[11] = '<p style=\"color: black;\">Faversham Community Café & Resource Centre</p>';
                
                lats[12] = '51.315834';
                lngs[12] = '0.891008';
                info[12] = '<p style=\"color: black;\">Faversham Umbrella Charity</p>';
                
                lats[13] = '51.384145';
                lngs[13] = '0.550685';
                info[13] = '<p style=\"color: black;\">St Barnabas House Counselling & Therapy Centre</p>';
                
                lats[14] = '51.393468';
                lngs[14] = '0.550169';
                info[14] = '<p style=\"color: black;\">Faversham Umbrella Charity</p>';
                
                lats[15] = '51.476921';
                lngs[15] = '-0.016047';
                info[15] = '<p style=\"color: black;\">Greenwich West Community & Arts Centre</p>';
                
                lats[16] = '51.271718';
                lngs[16] = '0.526787';
                info[16] = '<p style=\"color: black;\">Maidstone Counselling Centre</p>';
                
                lats[17] = '51.402035';
                lngs[17] = '-0.16755';
                info[17] = '<p style=\"color: black;\">The Vestry Hall</p>';
                
                lats[18] = '51.404071';
                lngs[18] = '0.105189';
                info[18] = '<p style=\"color: black;\">Orpington Outreach Centre</p>';
                
                lats[19] = '51.224448';
                lngs[19] = '-0.197155';
                info[19] = '<p style=\"color: black;\">Woodhatch Centre</p>';
                
                lats[20] = '51.285822';
                lngs[20] = '0.16927';
                info[20] = '<p style=\"color: black;\">Riverhead Clinic</p>';
                
                lats[21] = '51.339598';
                lngs[21] = '0.735773';
                info[21] = '<p style=\"color: black;\">Phoenix House (Swale Community Centres)</p>';
                
                lats[22] = '51.33956684140783';
                lngs[22] = '0.7375860214233398';
                info[22] = '<p style=\"color: black;\">The Physiotherapy Centre</p>';
                
                lats[23] = '51.21031';
                lngs[23] = '0.273902';
                info[23] = '<p style=\"color: black;\">Tonbridge Baptist Church</p>';
                
                lats[24] = '51.193394';
                lngs[24] = '0.274314';
                info[24] = '<p style=\"color: black;\">Angel Leisure Centre</p>';
                
                lats[25] = '51.145477';
                lngs[25] = '0.283038';
                info[25] = '<p style=\"color: black;\">St Philip’s Church</p>';
                
                lats[26] = '51.145863529778126';
                lngs[26] = '0.2870607376098633';
                info[26] = '<p style=\"color: black;\">TN2 Community Trust</p>';
                
               
                for (i = 0;i<lats.length;i++)
                {
                    var latLng = new GLatLng(lats[i], lngs[i]);
                    map.addOverlay(createMarker(latLng, i));
                }
            }
            }
        }
        
function createMarker(point, index) {
  // Create a lettered icon for this point using our icon class
  var letter = String.fromCharCode("A".charCodeAt(0) + index);
  var letteredIcon = new GIcon(baseIcon);
  letteredIcon.image = "http://www.google.com/mapfiles/marker.png";// + letter + ".png";

  // Set up our GMarkerOptions object
  markerOptions = { icon:letteredIcon, draggable:false };
  var marker = new GMarker(point, markerOptions);
  
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(info[index]);
  });
  return marker;
}

function setMap(lat, lng, zoom)
        {
            if (GBrowserIsCompatible()) {
                var latLng = new GLatLng(lat, lng);
                map.setCenter(latLng, zoom);
            }
        }



