using
System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for GoogleMapCommon
/// </summary>
public class GoogleMapCommon
{
Page mPageHandel = null;
string mMapDivName = string.Empty;
GoogleMapPoint mCenterPoint;
string mMapHandleName;
int mMapZoom;
private readonly static string mGoogleMapURL = ConfigurationManager.AppSettings["GoogleMapURL"];
/// <summary>
/// Show Google Map
/// </summary>
/// <param name="pageHandel">page handle</param>
/// <param name="mapHandleName">Map Handle Name.</param>
/// <param name="mapDivName">Div where Shows map</param>
/// <param name="centerPoint">center point</param>
/// <param name="zoom">map zoom 1 to 19</param>
public GoogleMapCommon(Page pageHandel, string mapHandleName, string mapDivName, GoogleMapPoint centerPoint, int mapZoom)
{
mPageHandel = pageHandel;
mMapHandleName = mapHandleName;
mMapDivName = mapDivName;
mCenterPoint = centerPoint;
if (mapZoom > 19 || mapZoom < 1)
{
mMapZoom = 4;
}
else
{
mMapZoom = mapZoom;
}
}
/// <summary>
/// Show Google mape
/// </summary>
public void ShowMap()
{
ShowMap(null);
}
/// <summary>
/// Show Google mape
/// </summary>
/// <param name="point"></param>
public void ShowMap(GoogleMapPoint point)
{
GoogleMapPoint[] points ={ point};
ShowMap(points);
}
/// <summary>
/// Show Google mape
/// </summary>
/// <param name="points"></param>
public void ShowMap(GoogleMapPoint[] points)
{
mPageHandel.ClientScript.RegisterClientScriptInclude("GoogleMaps", mGoogleMapURL);
StringBuilder js = new StringBuilder("var " + mMapHandleName + " = null; ");
js.AppendLine("function load()");
js.AppendLine("{ ");
js.AppendLine(" if (GBrowserIsCompatible()) ");
js.AppendLine(" {");
js.AppendLine(" " + mMapHandleName + " = new GMap2(document.getElementById("" + mMapDivName + ""));");
js.AppendLine(" " + mMapHandleName + ".setCenter(new GLatLng(" + mCenterPoint.Latitude + ", " + mCenterPoint.Longitude + ")," + mMapZoom + ");");
if (points != null)
{
for (int i = 0; i < points.Length; i++)
{
js.AppendLine(" var point" + i + " = new GLatLng(" + points[i].Latitude + ", " + points[i].Longitude + ")");
js.AppendLine("var blueIcon = new GIcon(G_DEFAULT_ICON);");
js.AppendLine("blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";");
js.AppendLine("blueIcon.iconSize = new GSize(35,35);");
js.AppendLine("blueIcon.shadowSize=new GSize(60,35);");
js.AppendLine("markerOptions = { icon:blueIcon }; ");
if (points[i].IsBuleIcon) //Create a blue icon
{
js.AppendLine(" var marker" + i + " = new GMarker(point" + i + ",markerOptions);");
}
else
{
js.AppendLine(" var marker" + i + " = new GMarker(point" + i + ");");
}
if (!string.IsNullOrEmpty(points[i].PointClickHandle))
{
// add event
js.AppendLine("GEvent.addListener(marker" + i + ", "click", function(){ " + mMapHandleName + ".openInfoWindowHtml(point" + i + ", " + points[i].PointClickHandle + ")});");
}
js.AppendLine(mMapHandleName + ".addOverlay(marker" + i + ");");
}
}
js.AppendLine(" }");
js.AppendLine("}"); //create function finsh
js.AppendLine("load();"); // call the load function.
mPageHandel.ClientScript.RegisterStartupScript(mPageHandel.GetType(), "Start", js.ToString(),true);
}
/// <summary>
/// Google Map Point
/// </summary>
public struct GoogleMapPoint
{
public GoogleMapPoint(double longitude, double latitude)
{
Longitude = longitude;
Latitude = latitude;
PointClickHandle = string.Empty;
IsBuleIcon = false;
}
public GoogleMapPoint(double longitude, double latitude, string pointClickHandle, bool isBuleIcon)
{
Longitude = longitude;
Latitude = latitude;
PointClickHandle = pointClickHandle;
IsBuleIcon = isBuleIcon;
}
public double Longitude;
public double Latitude;
public string PointClickHandle;
public bool IsBuleIcon;
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for GoogleMapCommon
/// </summary>
public class GoogleMapCommon
{
Page mPageHandel = null;
string mMapDivName = string.Empty;
GoogleMapPoint mCenterPoint;
string mMapHandleName;
int mMapZoom;
private readonly static string mGoogleMapURL = ConfigurationManager.AppSettings["GoogleMapURL"];
/// <summary>
/// Show Google Map
/// </summary>
/// <param name="pageHandel">page handle</param>
/// <param name="mapHandleName">Map Handle Name.</param>
/// <param name="mapDivName">Div where Shows map</param>
/// <param name="centerPoint">center point</param>
/// <param name="zoom">map zoom 1 to 19</param>
public GoogleMapCommon(Page pageHandel, string mapHandleName, string mapDivName, GoogleMapPoint centerPoint, int mapZoom)
{
mPageHandel = pageHandel;
mMapHandleName = mapHandleName;
mMapDivName = mapDivName;
mCenterPoint = centerPoint;
if (mapZoom > 19 || mapZoom < 1)
{
mMapZoom = 4;
}
else
{
mMapZoom = mapZoom;
}
}
/// <summary>
/// Show Google mape
/// </summary>
public void ShowMap()
{
ShowMap(null);
}
/// <summary>
/// Show Google mape
/// </summary>
/// <param name="point"></param>
public void ShowMap(GoogleMapPoint point)
{
GoogleMapPoint[] points ={ point};
ShowMap(points);
}
/// <summary>
/// Show Google mape
/// </summary>
/// <param name="points"></param>
public void ShowMap(GoogleMapPoint[] points)
{
mPageHandel.ClientScript.RegisterClientScriptInclude("GoogleMaps", mGoogleMapURL);
StringBuilder js = new StringBuilder("var " + mMapHandleName + " = null; ");
js.AppendLine("function load()");
js.AppendLine("{ ");
js.AppendLine(" if (GBrowserIsCompatible()) ");
js.AppendLine(" {");
js.AppendLine(" " + mMapHandleName + " = new GMap2(document.getElementById("" + mMapDivName + ""));");
js.AppendLine(" " + mMapHandleName + ".setCenter(new GLatLng(" + mCenterPoint.Latitude + ", " + mCenterPoint.Longitude + ")," + mMapZoom + ");");
if (points != null)
{
for (int i = 0; i < points.Length; i++)
{
js.AppendLine(" var point" + i + " = new GLatLng(" + points[i].Latitude + ", " + points[i].Longitude + ")");
js.AppendLine("var blueIcon = new GIcon(G_DEFAULT_ICON);");
js.AppendLine("blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";");
js.AppendLine("blueIcon.iconSize = new GSize(35,35);");
js.AppendLine("blueIcon.shadowSize=new GSize(60,35);");
js.AppendLine("markerOptions = { icon:blueIcon }; ");
if (points[i].IsBuleIcon) //Create a blue icon
{
js.AppendLine(" var marker" + i + " = new GMarker(point" + i + ",markerOptions);");
}
else
{
js.AppendLine(" var marker" + i + " = new GMarker(point" + i + ");");
}
if (!string.IsNullOrEmpty(points[i].PointClickHandle))
{
// add event
js.AppendLine("GEvent.addListener(marker" + i + ", "click", function(){ " + mMapHandleName + ".openInfoWindowHtml(point" + i + ", " + points[i].PointClickHandle + ")});");
}
js.AppendLine(mMapHandleName + ".addOverlay(marker" + i + ");");
}
}
js.AppendLine(" }");
js.AppendLine("}"); //create function finsh
js.AppendLine("load();"); // call the load function.
mPageHandel.ClientScript.RegisterStartupScript(mPageHandel.GetType(), "Start", js.ToString(),true);
}
/// <summary>
/// Google Map Point
/// </summary>
public struct GoogleMapPoint
{
public GoogleMapPoint(double longitude, double latitude)
{
Longitude = longitude;
Latitude = latitude;
PointClickHandle = string.Empty;
IsBuleIcon = false;
}
public GoogleMapPoint(double longitude, double latitude, string pointClickHandle, bool isBuleIcon)
{
Longitude = longitude;
Latitude = latitude;
PointClickHandle = pointClickHandle;
IsBuleIcon = isBuleIcon;
}
public double Longitude;
public double Latitude;
public string PointClickHandle;
public bool IsBuleIcon;
}
}