This project is read-only.

specific extent brutile layer and save tilling image

Feb 2, 2015 at 8:29 AM
Edited Feb 4, 2015 at 11:04 AM
hi every body.

im new. i tried to use brutile layer google map in my app c# dotspatial.

here is the image when im startup my app


my question is,
  1. how to zoom a specific extent?. so, when i startup my app the map already in this extent.
    here is the image
  2. when im offline the map not show image how to save tilling image google map brutile layer. so when im offline the map still show?.


edit new

i try to find a right projection, here is the code
            BruTileLayer _btLayer = new BruTileLayer();
            _btLayer = BruTileLayer.CreateGoogleMapLayer();
            _btLayer.LegendText = "Google Map";
            _btLayer.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
            dsMap.Projection = _btLayer.Projection;
            panelMapHeader.sText = _btLayer.LegendText;

            ProjectionInfo wgs84 = KnownCoordinateSystems.Geographic.World.WGS1984;
            dsMap.Projection = wgs84;
            ProjectionInfo sphericalMercator = null;
            sphericalMercator = ProjectionInfo.FromProj4String("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
            Extent extents = dsMap.MapFrame.ViewExtents;
            double[] minXY = new double[] { 95.0597, -10.9974 };
            double[] z = new double[] { 0 };
            Reproject.ReprojectPoints(minXY, z, wgs84, sphericalMercator, 0, 1);
            double[] maxXY = new double[] { 141.007, 5.90688 };
            Reproject.ReprojectPoints(maxXY, z, wgs84, sphericalMercator, 0, 1);
            Extent NEWEXT = new Extent(minXY[0], minXY[1], maxXY[0], maxXY[1]);
            double[] centerXY = new double[] { dsMap.MapFrame.ViewExtents.Center.X, dsMap.MapFrame.ViewExtents.Center.Y };
            dsMap.Extent.SetCenter(new Coordinate(centerXY[0], centerXY[1]));

            __extentBM = (Extent)dsMap.ViewExtents.Clone();__
            rectExtentBM = dsMap.ProjToPixel(extentBM);
            IsMapLoaded = true;


and when i startup my app the result is image the map is show but in the ocean. coordinate lat long is true, wgs84 datum.

but , when i try to change
 extentBM = (Extent)dsMap.ViewExtents.Clone();


extentBM = (Extent)dsMap.Extent.Clone();
the result is image . the map is show but show map world, not my extent and projection. and the coordinate is still Spherical Mercator (meters) not wgs84 datum like my first image.
how to fix that?
Feb 3, 2015 at 9:52 AM
Does your projection is right?It seems your points are in the ocean
Feb 4, 2015 at 3:21 AM
Edited Feb 4, 2015 at 3:24 AM
when i try to change proj4string with many preojection, the map always in the ocean.

when i debug after Reproject.ReprojectPoints the value minXY and z always Nan or infinity
Feb 4, 2015 at 6:00 AM
Just try to find right projection for shape file..You can do it using Qgis and openlayer plugin.When you find that you must reproject to googles projection and then it works.
Feb 4, 2015 at 10:36 AM
Edited Feb 4, 2015 at 10:37 AM
i try to find right projection and i have a indonesian shapefile and running it to qgis, i copied the information extent and proj in properties to my code minx,miny, maxx maxy and sphericalMercator value.

but still have problem.

see my edited question.

Feb 4, 2015 at 1:55 PM
I think there is still problem with projections,Try to install openlayer maps plugin on qgis and test if your layer places in right position ?
Don't set extend by minXY..Get extend from your layers extend.or zoom map to layer extend
Feb 4, 2015 at 2:20 PM
_btLayer.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
THIS IS NOT TRUE! It should be:
_btLayer.Projection = KnownCoordinateSystems.Projected.World.WebMercator;
Feb 5, 2015 at 5:09 AM
Edited Feb 12, 2015 at 6:47 AM
FObermaier : yes it works with KnownCoordinateSystems.Projected.World.WebMercator; but the coordinate is meters. so i copy extent openlayer in meters.

i need the coordinat is lat long. how to change to latlon?