示例#1
0
        void SetLocation()
        {
            pointTable.Clear();
            pointTable.AddRow(GetRow(location.LongitudeM, location.LatitudeM));

            GeoResponse.CResult.CGeometry.CViewPort vp = location.ViewPort;
            Envelope expand;

            if (vp.NorthEast.Lat == 0 && vp.NorthEast.Long == 0 && vp.SouthWest.Lat == 0 && vp.SouthWest.Long == 0)
            {
                expand = new Envelope(-25000000, 25000000, -17000000, 17000000);
            }
            else
            {
                expand = new Envelope(vp.NorthEast.Long, vp.SouthWest.Long, vp.NorthEast.Lat, vp.SouthWest.Lat);
            }
            Coordinate p     = new Coordinate(location.LongitudeM, location.LatitudeM);
            Envelope   point = new Envelope(p, p);

            point.ExpandBy(mapBox1.Map.PixelSize * 40);
            if (!expand.Contains(point))
            {
                mapBox1.Map.ZoomToBox(expand);
                expand.ExpandToInclude(point);
                expand.ExpandBy(mapBox1.Map.PixelSize * 40);
            }
            mapBox1.Map.ZoomToBox(expand);
            mapBox1.Refresh();
        }
示例#2
0
        public bool SetLocation(FactLocation loc, int level)
        {
            while (!loaded)
            {
                Application.DoEvents();
            }
            GeoResponse.CResult.CGeometry.CViewPort viewport = null;
            GeoResponse res = null;

            Object[] args = new Object[] { 0, 0 };
            if (loc.IsGeoCoded(false) && loc.ViewPort != null)
            {
                labMapLevel.Text = "Previously Geocoded: " + loc.ToString();
                viewport         = MapTransforms.ReverseTransformViewport(loc.ViewPort);
                args             = new Object[] { loc.Latitude, loc.Longitude };
            }
            else
            {
                location = loc.ToString();
                res      = CallGoogleGeocode(location);
                if (res.Status == "OK")
                {
                    labMapLevel.Text = GoogleMap.LocationText(res, loc, level);
                    viewport         = res.Results[0].Geometry.ViewPort;
                    double lat = res.Results[0].Geometry.Location.Lat;
                    double lng = res.Results[0].Geometry.Location.Long;
                    args = new Object[] { lat, lng };
                }
                else if (res.Status == "OVER_QUERY_LIMIT" && loc.IsGeoCoded(false))
                {
                    labMapLevel.Text        = "Previously Geocoded: " + loc.ToString();
                    viewport                = new GeoResponse.CResult.CGeometry.CViewPort();
                    viewport.NorthEast.Lat  = loc.Latitude + 2;
                    viewport.NorthEast.Long = loc.Longitude + 2;
                    viewport.SouthWest.Lat  = loc.Latitude - 2;
                    viewport.SouthWest.Long = loc.Longitude - 2;
                    args = new Object[] { loc.Latitude, loc.Longitude };
                }
                else
                {
                    return(false);
                }
            }
            Object marker = webBrowser.Document.InvokeScript("frontAndCenter", args);

            args = new Object[] { viewport.NorthEast.Lat, viewport.NorthEast.Long, viewport.SouthWest.Lat, viewport.SouthWest.Long };
            webBrowser.Document.InvokeScript("setViewport", args);
            webBrowser.Show();
            return(true);
        }
示例#3
0
 public bool SetLocation(FactLocation loc, int level)
 {
     if (loc is null)
     {
         return(false);
     }
     while (!loaded)
     {
         Application.DoEvents();
     }
     GeoResponse.CResult.CGeometry.CViewPort viewport;
     if (loc.IsGeoCoded(false) && loc.ViewPort != null)
     {
         labMapLevel.Text = "Previously Geocoded: " + loc.ToString();
         viewport         = MapTransforms.ReverseTransformViewport(loc.ViewPort);
     }
     else
     {
         GeoResponse res = GoogleMap.CallGoogleGeocode(loc, loc.ToString());
         if (res.Status == "OK")
         {
             labMapLevel.Text = GoogleMap.LocationText(res, loc, level);
             viewport         = res.Results[0].Geometry.ViewPort;
         }
         else if (res.Status == "OVER_QUERY_LIMIT" && loc.IsGeoCoded(false))
         {
             labMapLevel.Text        = "Previously Geocoded: " + loc.ToString();
             viewport                = new GeoResponse.CResult.CGeometry.CViewPort();
             viewport.NorthEast.Lat  = loc.Latitude + 2;
             viewport.NorthEast.Long = loc.Longitude + 2;
             viewport.SouthWest.Lat  = loc.Latitude + 2;
             viewport.SouthWest.Long = loc.Longitude + 2;
         }
         else
         {
             return(false);
         }
     }
     object[] args = new object[] { viewport.NorthEast.Lat, viewport.NorthEast.Long, viewport.SouthWest.Lat, viewport.SouthWest.Long };
     webBrowser.Document.InvokeScript("setBounds", args);
     webBrowser.Show();
     return(true);
 }