function gotoPolygonAdminResultGM(coordString,tablename, resultID) {
	coordString = coordString.replace(/ /g,"||");
	
	// now split into an array of long then lat ...
	var coordArray = coordString.split("||");
	
	// then create an array of points from this array using the lats first then the longs ..
	var adminpoints = [];
	
	// temp move the map first ...
	//map.setCenter(new GLatLng(coordArray[1],coordArray[0]),15);
	map.setCenter(new google.maps.LatLng(coordArray[1],coordArray[0]),15);
	switchAllLayersOff();
	
	for (var i = 0;i< coordArray.length;i=i+2){
		var point = new google.maps.LatLng(coordArray[i+1],coordArray[i]);
		var imagelocation = getCustomIcon(tablename, false) ; 
		var icon = new google.maps.MarkerImage(imagelocation,
		new google.maps.Size(20, 20),
		// The origin for this image is 0,0.
		new google.maps.Point(0,0),
		// The anchor for this image is the base of the flagpole at 0,32.
		new google.maps.Point(10, 10));

		adminpoints.push(point);
	}
	var theColour = getColour(tablename);
	if (theAdminPolygon) {
		theAdminPolygon.setMap(null);
		map.markers.pop(theAdminPolygon);
	}

	theAdminPolygon = new google.maps.Polygon({paths: adminpoints,strokeColor: theColour, fillColor: theColour, fillOpacity:0.2, strokeOpacity: 1.0, strokeWeight: 3});
	google.maps.event.addListener(theAdminPolygon,'click',function() {
	    if (startCapture == false ) {
		showAdminResult(tablename, resultID);	
	     } // startcapture = false
	}); // end of the listener function
	map.setCenter(theAdminPolygon.getBounds().getCenter());
	var theBounds = theAdminPolygon.getBounds();
	map.fitBounds(theBounds);
	try {
		doCloseInfoWindow();
	}
	catch ( e) {
	}
	
	//map.addOverlay(theAdminPolygon);
	theAdminPolygon.setMap(map);
	map.markers.push(theAdminPolygon);

}



function gotoAdminResultGM(lng,lat,tablename, resultID) {
	//alert(lng,lat);
	doCloseInfoWindow()
	// zoom in rather than stay at current zoom
	var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));

	var icon = getCustomIcon(tablename, false) ;
	  var markeroptions = {};
	  if (!markeroptions.icon) {
	    markeroptions.icon = icon;
	  }
	  //var m = new GMarker(point, markeroptions);
	  //theAdminPoint = new GMarker(point, markeroptions);
	  
	  
	  
	var imagelocation = getCustomIcon(tablename, false) ; 

	var icon = new google.maps.MarkerImage(imagelocation,
		new google.maps.Size(20, 20),
		// The origin for this image is 0,0.
		new google.maps.Point(0,0),
		// The anchor for this image is the base of the flagpole at 0,32.
		new google.maps.Point(10,10));
	if (theAdminPoint) {
		theAdminPoint.setMap(null);
		map.markers.pop(theAdminPoint);
	}

	theAdminPoint = new google.maps.Marker({position: point, icon: icon});

	  
	  //var m = new GMarker(point);
	  // strip the header texts from the name string

	//map.setCenter(new GLatLng(lat, lng), 15);
	map.setCenter(new google.maps.LatLng(lat,lng),15);
	switchAllLayersOff();
	//map.addOverlay(theAdminPoint);
	theAdminPoint.setMap(map);
	map.markers.push(theAdminPoint);
	//GEvent.addListener(theAdminPoint, "click", function() {
	google.maps.event.addListener(theAdminPoint,'click',function() {
	    if (startCapture == false ) {
		showAdminResult(tablename, resultID);	
	     } // startcapture = false
	}); // end of the listener function

}


function gotoLineAdminResultGM(coordString,tablename, resultID) {
	coordString = coordString.replace(/ /g,"||");
	// now split into an array of long then lat ...
	//alert(coordString);
	var coordArray = coordString.split("||");
	
	// then create an array of points from this array using the lats first then the longs ..
	var points = [];
	
	// temp move the map first ...
	
	
	//alert("pre loop");
	
	for (var i = 0;i< coordArray.length;i=i+1){
		//alert(i);
		//alert(coordArray[i+1]);
		//alert(coordArray[i]);
		var temppoints = coordArray[i].split(",");
		//var point = new GLatLng(coordArray[i+1],coordArray[i]);
		//var point = new GLatLng(temppoints[1],temppoints[0]);
		var point = new google.maps.LatLng(temppoints[1],temppoints[0]);
		//theMarkerPoint = new GMarker(point);
		//var gPoint= new GPoint(coordArray[i+1],coordArray[i]);
		points.push(point);
		//map.addOverlay(theMarkerPoint);
	}
	
	var theColour = getColour(tablename);
	
	if (theAdminLine) {
		theAdminLine.setMap(null);
		map.markers.pop(theAdminLine);
	}
	theAdminLine = new google.maps.Polyline({path:points,strokeColor:theColour,strokeOpacity:1.0,strokeWeight:2});
	
	//alert("pre add listener");
	//GEvent.addListener(theAdminLine, "click", function() {
	google.maps.event.addListener(theAdminLine,'click',function() {
	    if (startCapture == false ) {
		showAdminResult(tablename, resultID);	
	     } // startcapture = false
	}); // end of the listener function

	//map.setCenter(theAdminLine.getBounds().getCenter());
	var theBounds = theAdminLine.getBounds();
	//var theZoom = map.getBoundsZoomLevel(theBounds);
	//map.setZoom(theZoom);
	map.fitBounds(theBounds);
	try {
		doCloseInfoWindow();
	}
	catch ( e) {
	}
	
	//map.addOverlay(theAdminLine);
	theAdminLine.setMap(map);
	map.markers.push(theAdminLine);
	// zoom in rather than stay at current zoom
}


// version 3 - this method no longer exists for lines
// following code from: http://stackoverflow.com/questions/3529902/google-maps-api-v3-add-point-on-polyline-beetwen-two-existing-points-on-click-po
google.maps.Polyline.prototype.getBounds = function() {
  var bounds = new google.maps.LatLngBounds();
  this.getPath().forEach(function(e) {
    bounds.extend(e);
  });
  return bounds;
};


function resetOverlayGM() {
	//map.clearOverlays();
	try {
		theAdminLine.setMap(null);
	}
	catch(e) { }
	
	try {
		theAdminPolygon.setMap(null);
	}
	catch(e) { }
	

	try {
		theAdminPoint.setMap(null);
	}
	catch(e) { }
	updateMap(true);
}


