 var map = null;

 /**
  *This initializes the map component
  */
function Init()
{
	GetMap();
	CreateLayers();
}

 /**
  *This method creates a map and loads the default pins
  */
 function GetMap()
 {
    map = new VEMap('myMap');

		MapControl.Features.ScaleBarKilometers = true;
    map.LoadMap(new VELatLong(53.389846
, -6.224806
), 15 ,'r' ,false);

		map.ShowMiniMap(418,1);
		//map.ClearInfoBoxStyles();

 }

 /**
  *This method creates 3 layers.  Parking,
  *Info and Access.
  */
  function CreateLayers()
  {
	

	var infoTitle = "Info";
	CreateLayer(infoTitle);
	AddInfo(infoTitle);
	
	var parkingTitle = "Parking";
	CreateLayer(parkingTitle);
	AddParking(parkingTitle);

	var accessTitle = "Access";
	CreateLayer(accessTitle);
	AddAccess(accessTitle);



 }

  /**
  *This method creates a layer.
  *@param {String} title Title of the layer
  */
  function CreateLayer(title)
  {

	var layer = new VEShapeLayer();
	layer.SetTitle(title);
	map.AddShapeLayer(layer);
	return layer;

  }

 /**
  *This method shows the layer with
  *the given title
  *@param {String} title Title of the layer
  *@param {Boolean} state Optional flag to
  * 	show or hide layer.
  *		True will show layer, False will hide.
	  */
 function ToggleLayer(title,state)
 {

	var layer = GetLayer(title);

	if(layer != null)
	{
		var hideLayer = layer.IsVisible();
		if(state != null && state != 'undefined')
		{
			hideLayer = !state;
		}

		if(hideLayer)
		{
			layer.Hide();
		}
		else
		{
			layer.Show();
		}


	}

 }

 /**
  *This method gets a layer with
  *the given title
  *@param {String} title Title of the layer
  *@return VEShapeLayer
  */
 function GetLayer(title)
 {
	var layerCount = map.GetShapeLayerCount();
	for(var i = 0; i < layerCount; i++)
	{
		var layer = map.GetShapeLayerByIndex(i);

		if(layer != null && layer.GetTitle() == title)
		{
			return layer;
		}
	}
	return null;
 }



/**
  *This method adds
  *an array of pins.
  *@param title Title of the layer
  */
 function AddParking(title)
{
	var layer = GetLayer(title);


	var pin4 = new VEShape(VEShapeType.Pushpin,new VELatLong( 53.293101929490035,-6.134812831878658));
	pin4.SetDescription("Dunlaoghaire Shopping Centre<br />Click <a href='http://www.dunlaoghairesc.ie/' target='_blank'>here</a>" );
	pin4.SetTitle("Parking");
	pin4.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin4);

	var pin5 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.293557239969054, -6.132425665855415));
	pin5.SetDescription("Dunlaoghaire Shopping Centre<br />Click <a href='http://www.dunlaoghairesc.ie/' target='_blank'>here</a>" );
	pin5.SetTitle("Pavilion Parking");
	pin5.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin5);

	

	var pin8 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.292928781977864, -6.139935851097106));
	pin8.SetDescription("For more info<br />Click <a href='http://www.dlrtourism.com/shopping/display.asp?Cat=4&SubCat=34' target='_blank'>here</a>" );
	pin8.SetTitle("Bloomfields Shopping Centre Parking");
	pin8.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin8);

	var pin9 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.293050626596624,-6.141561269760133));
	pin9.SetDescription("For more info<br />Click <a href='http://www.dlrtourism.com/shopping/display.asp?Cat=4&SubCat=34' target='_blank'>here</a>" );
	pin9.SetTitle("Bloomfields Shopping Centre Parking");
	pin9.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin9);




}

/**
  *This method adds
  *an array of pins.
  *@param title Title of the layer
  */
 function AddInfo(title)
{

var layer = GetLayer(title);
	var pin1 = new VEShape(VEShapeType.Pushpin,  new VELatLong(53.389846, -6.224806));


	pin1.SetTitle("Dublin Bus node 253");
	pin1.SetCustomIcon("<img src=' http://freeflow.ie/bus.png' />");
	pin1.SetDescription("<br />Buses  <a href='http://www.dublinbus.ie/your_journey/viewer.asp?placeName=Dun%20Laoghaire%20DART%20Station' target='_blank'>More information</a> <br />Check Dublin Bus Website<br />" );
	layer.AddShape(pin1);
	
	
	var pin10 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.385819, -6.233525));

	pin10.SetDescription("For more info<br />Click <a href='http://www.dublinbus.ie/your_journey/viewer.asp?placeName=Dun%20Laoghaire%20Shopping%20Centre' target='_blank'>here</a>" );
	pin10.SetTitle("Dublin Bus Node 233");
	pin10.SetCustomIcon("<img src='bus.png' />");

	layer.AddShape(pin10);

	var pin2 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.384946, -6.234804));
	pin2.SetDescription("For information on DART and outer suburban rail services.<br />Click <a href='http://www.irishrail.ie' target='_blank'>here</a>" );
	pin2.SetTitle("BUSNODE 234");
	pin2.SetCustomIcon("<img src='bus.png' />");

	layer.AddShape(pin2);

	var pin3 = new VEShape(VEShapeType.Pushpin,new VELatLong( 53.29251514896906, -6.13381505012512));
	pin3.SetDescription("Dunlaoghaire Shopping Centre<br />Click <a href='http://www.dunlaoghairesc.ie/' target='_blank'>here</a>" );
	pin3.SetTitle("Shopping in Dún Laoghaire");
	pin3.SetCustomIcon("<img src='dlsc.png' />");

	layer.AddShape(pin3);


	var pin6 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.2941680537992,-6.133726537227637));
	pin6.SetDescription("For what is on<br />Click <a href='http://www.paviliontheatre.ie/' target='_blank'>here</a>" );
	pin6.SetTitle("Pavilion Theatre");
	pin6.SetCustomIcon("<img src='pt.png' />");

	layer.AddShape(pin6);
	
	var pin7 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.29247667127626,-6.139613986015337));
	pin7.SetDescription("For more info<br />Click <a href='http://www.dlrtourism.com/shopping/display.asp?Cat=4&SubCat=34' target='_blank'>here</a>" );
	pin7.SetTitle("Bloomfields Shopping Centre");
	pin7.SetCustomIcon("<img src='BF.png' />");

	layer.AddShape(pin7);
}
/**
*This method adds
*an array of pins.
*@param title Title of the layer
*/
function AddAccess(title)
{
	var layer = GetLayer(title);
	var line = new VEShape(VEShapeType.Polyline, [new VELatLong(53.29164297942172,  -6.134598255157456),
new VELatLong(53.29407987911379, -6.140338182449351),
new VELatLong(53.2937367976969, -6.140719056129441),
new VELatLong(53.293345617392276, -6.140928268432605),
new VELatLong(53.29287427243064,  -6.140960454940802),
new VELatLong(53.292909543322075,-6.139978766441346)
]);

	var lineColor = new VEColor(0,0,255,0.6);
	line.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line.SetLineWidth(lineWidth);

	line.HideIcon();

	layer.AddShape(line);
	
	var line1 = new VEShape(VEShapeType.Polyline, [new VELatLong(53.293041007297255,-6.140971183776845),
new VELatLong(53.293053833029276, -6.141647100448615)
]);

	var lineColor = new VEColor(0,0,255,0.6);
	line1.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line1.SetLineWidth(lineWidth);

	line1.HideIcon();

	layer.AddShape(line1);
	
	var line2 = new VEShape(VEShapeType.Polyline, [new VELatLong(53.292316347183174,-6.136068105697637),
new VELatLong(53.293159645171464, -6.135118603706346),
new VELatLong(53.2944486084055, -6.133847236633317),
new VELatLong(53.2943908944656,-6.133434176444995),
new VELatLong(53.2937367976969,-6.131969690322887)
]);

	var lineColor = new VEColor(0,0,255,0.6);
	line2.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line2.SetLineWidth(lineWidth);

	line2.HideIcon();

	layer.AddShape(line2);


}
