Exemple #1
0
    protected void Map1_OnClick(object sender, AsyncMapEventArgs e)
    {
        if (e.leftMouseButton)
        {
            if (e.Shape == null)
            {
                //Add pushpin where the user clicked.
                Simplovation.Web.Maps.VE.Shape shape = new Simplovation.Web.Maps.VE.Shape(e.latlong);
                shape.Title       = "OnClick Shape";
                shape.Description = "Lat: " + e.latlong.Latitude.ToString() + "<br/>Lng: " + e.latlong.Longitude.ToString();

                Map1.AddShape(shape);
            }
            else
            {
                //Center on the pushpin the user clicked
                Map1.LatLong = e.Shape.Points[0];
            }
        }
        else if (e.rightMouseButton)
        {
            if (e.Shape != null)
            {
                //If the user right-clicked on a pushpin, remove it from the map
                Map1.DeleteShape(e.Shape);
            }
        }
    }
    protected void lbShapesPushpin_Click(object sender, EventArgs e)
    {
        Simplovation.Web.Maps.VE.Shape s = new Simplovation.Web.Maps.VE.Shape(Map1.LatLong);

        s.Title       = "Pushpin";
        s.Description = "Added " + DateTime.Now.ToString();
        s.MoreInfoURL = "~/MorePushpinInfo.aspx";
        s.PhotoURL    = "~/images/PushpinImage.png";

        Map1.AddShape(s);
    }
    protected void lbShapesPolyline_Click(object sender, EventArgs e)
    {
        Simplovation.Web.Maps.VE.LatLong[] points = new Simplovation.Web.Maps.VE.LatLong[4];
        points[0] = new Simplovation.Web.Maps.VE.LatLong(Map1.Latitude - 4, Map1.Longitude);
        points[1] = new Simplovation.Web.Maps.VE.LatLong(Map1.Latitude - 8, Map1.Longitude);
        points[2] = new Simplovation.Web.Maps.VE.LatLong(Map1.Latitude - 8, Map1.Longitude + 7);
        points[3] = new Simplovation.Web.Maps.VE.LatLong(Map1.Latitude - 4, Map1.Longitude + 4);

        Simplovation.Web.Maps.VE.Shape s = new Simplovation.Web.Maps.VE.Shape(Simplovation.Web.Maps.VE.ShapeType.Polyline, points);

        Map1.AddShape(s);
    }
    protected void lbShapesCustomPushpin_Click(object sender, EventArgs e)
    {
        Simplovation.Web.Maps.VE.Shape s = new Simplovation.Web.Maps.VE.Shape(Map1.LatLong);
        s.Title = "Custom Pushpin";

        s.Description = "<div>Added:&nbsp;" + DateTime.Now.ToString() + "</div>";

        s.MoreInfoURL = "~/MorePushpinInfo.aspx";

        // Set a CustomIcon for the Shape to use
        s.CustomIcon       = new CustomIconSpecification();
        s.CustomIcon.Image = VirtualPathUtility.ToAbsolute("~/DynamicSearch/icon.png");

        /*
         * // Add HTML to be used for the Custom Icon that this Pushpin Shape will use
         * s.CustomIcon = new CustomIconSpecification("<div style='background-color: lightblue; color: black; border: solid 1px red; padding: 2px; font-weight: bold;'>" + (Map1.Layers[0].Shapes.Count + 1) + "</div>");
         */

        Map1.AddShape(s);
    }
    protected void lbShapesPolygon_Click(object sender, EventArgs e)
    {
        Simplovation.Web.Maps.VE.LatLong[] points = new Simplovation.Web.Maps.VE.LatLong[6];
        points[0] = new Simplovation.Web.Maps.VE.LatLong(46.1950421086602, -97.03125);
        points[1] = new Simplovation.Web.Maps.VE.LatLong(46.0122238406324, -104.326171875);
        points[2] = new Simplovation.Web.Maps.VE.LatLong(43.1330611624061, -104.326171875);
        points[3] = new Simplovation.Web.Maps.VE.LatLong(42.9403392336318, -96.943359375);
        points[4] = new Simplovation.Web.Maps.VE.LatLong(45.2748864370489, -96.767578125);
        points[5] = new Simplovation.Web.Maps.VE.LatLong(45.7061792853308, -97.3828125);

        Simplovation.Web.Maps.VE.Shape s = new Simplovation.Web.Maps.VE.Shape(Simplovation.Web.Maps.VE.ShapeType.Polygon, points);

        s.FillColor   = Simplovation.Web.Maps.VE.Color.Red;
        s.FillColor.A = 0.5; // make sure the color is semi-transparent

        s.LineColor = Simplovation.Web.Maps.VE.Color.Blue;

        s.LineWidth = 2; // make the line width 2 pixels

        Map1.AddShape(s);
    }