protected void Page_Load(object sender, EventArgs e)
{
GMap.GoogleKey = ConfigurationManager.AppSettings["MapKey"];
GMap.Click += new Reimers.Map.ClickHandler(GMap_Click);
Sidebar.Click += new Reimers.WebControls.SidebarHandler(Sidebar_Click);
Sidebar.AlternatingItemStyle.BackColor = System.Drawing.Color.Silver;
if (!Page.IsPostBack || !Page.IsCallback)
{
Sidebar.Map = "GMap";
Sidebar.HeaderText = "Locations";
GMap.Controls.Add(new Reimers.Map.Controls.GoogleLargeMapControl("lmc"));
//Removed because they are not needed.
GMap.Options.MapTypes.RemoveAt(2);
GMap.Options.MapTypes.RemoveAt(1);
}
}
string Sidebar_Click(GoogleOverlay Item)
{
return GMap.SetCenter(Item.Bounds.Center);
}
void GMap_Click(Reimers.Map.GoogleMap Map, Reimers.Map.GoogleLatLng Position, ref string MapCommand)
{
//Perform reverse geocoding on clicked point.
Reimers.Map.Geocoding.Location location =
Reimers.Map.Geocoding.GoogleGeocoder.ReverseGeocode(Position);
//Plot a marker if successful
if (location.Point != null)
{
GoogleMarker marker = new GoogleMarker(
location.Address.City,
location.Point,
new GoogleMarkerOptions(location.Address.City, true, false));
marker.Options.UpdateAfterDrag = true;
marker.ClientSideHandlers.OnClick =
marker.OpenInfoWindowHTML(
Map,
location.Address.ToString(),
new GoogleInfoWindowOptions(true));
MapCommand = Map.AddOverlay(marker, true) + Sidebar.RedrawSidebar();
}
}