/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is WCPierce Web Controls.
*
* The Initial Developer of the Original Code is William C. Pierce.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
using System;
using System.Xml.Serialization;
namespace WCPierce.Web.UI.WebControls
{
/// <summary>
/// GMarker is a type of map overlay that shows an icon at a single point on
/// the map. The constructor takes an instance of GIcon, which can be shared
/// among many markers, and the point at which it should be displayed.
/// GMarker also includes some convenience methods to open info windows over
/// the marker, which is common for Google Maps hacks.
///
/// 2005-09-09
/// + Changed getMarkerById to getOverlayById
/// </summary>
[Serializable()]
public class GMarker : GOverlay
{
/// <summary>
///
/// </summary>
protected string _iconId = String.Empty;
/// <summary>
///
/// </summary>
protected GPoint _point = new GPoint(0, 0);
/// <summary>
/// Default constructor required for XmlSerialization
/// </summary>
public GMarker() : this(new GPoint(0,0), String.Empty, String.Empty) { }
/// <summary>
///
/// </summary>
/// <param name="Point"></param>
public GMarker(GPoint Point) : this(Point, String.Empty, String.Empty) { }
/// <summary>
///
/// </summary>
/// <param name="Point"></param>
/// <param name="Id"></param>
public GMarker(GPoint Point, string Id) : this(Point, Id, String.Empty) { }
/// <summary>
/// Creates a marker with the given icon at the given point. If no icon is
/// given, we use the default Google Maps icon.
/// </summary>
/// <param name="Point"></param>
/// <param name="Id"></param>
/// <param name="IconId"></param>
public GMarker(GPoint Point, string Id, string IconId)
{
_point = Point;
_id = Id;
_iconId = IconId;
}
#region Public Properties
/// <summary>
/// The point at which the GMarker is located
/// </summary>
public override GPoint Point
{
get { return _point; }
set { _point = value; }
}
/// <summary>
/// The user assignable Id give to this Marker
/// </summary>
[XmlAttribute()]
public override string Id
{
get { return _id; }
set { _id = value; }
}
/// <summary>
/// Used for XmlSerialization
/// </summary>
[XmlAttribute()]
public string IconId
{
get { return _iconId; }
set { _iconId = value; }
}
/// <summary>
/// Used for databinding
/// </summary>
public float Longitude
{
get { return _point.X; }
}
/// <summary>
/// Used for databinding
/// </summary>
public float Latitude
{
get { return _point.Y; }
}
#endregion
#region Public Methods
/// <summary>
/// Opens an info window with the given HTML content over the given GMarker.
/// </summary>
/// <param name="HtmlElem">An HTML DOM element</param>
/// <returns></returns>
public string OpenInfoWindow(string HtmlElem)
{
//string initStr = String.Format(Utilities.UsCulture, "{0}.getOverlayById('{1}').openInfoWindow({2});", this.JsId, this.Id, HtmlElem);
string retStr = String.Format(Utilities.UsCulture, "this.getOverlayById('{0}').openInfoWindow({1});", this.Id, HtmlElem);
//initJs.Append(initStr);
return retStr;
}
/// <summary>
/// Like OpenInfoWindow, but takes an HTML string rather than an HTML DOM element
/// </summary>
/// <param name="HtmlStr">The string of HTML to show in the info window</param>
/// <returns></returns>
public string OpenInfoWindowHtml(string HtmlStr)
{
//string initStr = String.Format(Utilities.UsCulture, "{0}.getOverlayById('{1}').openInfoWindowHtml('{2}');", this.JsId, this.Id, HtmlStr);
string retStr = String.Format(Utilities.UsCulture, "this.getOverlayById('{0}').openInfoWindowHtml('{1}');", this.Id, HtmlStr);
//initJs.Append(initStr);
return retStr;
}
/// <summary>
/// Like openInfoWindow, but takes an XML element and the URI of an XSLT
/// document to produce the content of the info window. The first time a
/// URI is given, it is downloaded with GXmlHttp and subsequently cached.
/// </summary>
/// <param name="Xml"></param>
/// <param name="XsltUri"></param>
/// <returns></returns>
public string OpenInfoWindowXslt(string Xml, Uri XsltUri)
{
//string initStr = String.Format(Utilities.UsCulture, "{0}.getOverlayById('{1}').openInfoWindowXslt(GXml.parse('{2}'), '{3}');", this.JsId, this.Id, Xml, XsltUri.AbsoluteUri);
string retStr = String.Format(Utilities.UsCulture, "this.getOverlayById('{0}').openInfoWindowXslt(GXml.parse('{1}'), '{2}');", this.Id, Xml, XsltUri.AbsoluteUri);
//initJs.Append(initStr);
return retStr;
}
/// <summary>
/// Shows a blowup of the map over this marker. We use a default zoom level
/// of 1 and the current map type if the zoomLevel and mapType parameters
/// are not given.
/// </summary>
/// <param name="ZoomLevel"></param>
/// <param name="MapType"></param>
/// <returns></returns>
public string ShowMapBlowup(int ZoomLevel, GMapType MapType)
{
//string initStr = String.Format(Utilities.UsCulture, "{0}.getOverlayById('{1}').showMapBlowup({2}, {3});", this.JsId, this.Id, ZoomLevel, MapType);
string retStr = String.Format(Utilities.UsCulture, "this.getOverlayById('{0}').showMapBlowup({1}, {2});", this.Id, ZoomLevel, MapType);
//initJs.Append(initStr);
return retStr;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public string ShowMapBlowup()
{
return ShowMapBlowup(1, GMapType.G_MAP_TYPE);
}
#endregion
}
}