ThinkGeo.com    |     Documentation    |     Premium Support

Base map offset

On android when using the latest ThinkGeo version features placed on Bing and OSM maps are not showing up in the correct location. coordinates I am using are 33.753681,-84.381055 which is an intersection of Jesse Hill Jr Dr Se and Coca Cola PL SE in Atlanta – coordinates confirmed with Google Maps, and also confirmed using OSM maps in Thiinkgeo WPF.

I’ve not been able to get Google to work at all but I would suspect it has the same issues as well.

The location on Android is off by about 65 feet east and 120’ south. Code used for this test is as follows:

        OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();
        androidMap = FindViewById<MapView>(Resource.Id.androidmap);
        androidMap.MapUnit = GeographyUnit.Meter;
        androidMap.ZoomLevelSet = new SphericalMercatorZoomLevelSet();
        androidMap.CurrentExtent = osmOvelerlay.GetBoundingBox();
        androidMap.Overlays.Add(osmOvelerlay);
        InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
        inMemoryLayer.InternalFeatures.Add(new ThinkGeo.MapSuite.Shapes.Feature(new Vertex(-84.381055, 33.753681)));
        inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Red), 8);
        inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        LayerOverlay inmemoryOverlay = new LayerOverlay();
        inmemoryOverlay.TileType = TileType.SingleTile;
        inmemoryOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer);
        androidMap.Overlays.Add("memlayer", inmemoryOverlay);
        Proj4Projection proj4 = new Proj4Projection();
        proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
        proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3857);
        proj4.Open();
        inMemoryLayer.FeatureSource.Projection = proj4;

Hi Richard,

Thanks to let us know it.

It looks the xxxOverlay have the same problem in Android version, our developer will look into it and see whether it can be solved.

For now please try the code as below in Android.

            LayerOverlay baseoverlay = new LayerOverlay();
        OpenStreetMapLayer osm = new OpenStreetMapLayer();
        baseoverlay.Layers.Add(osm);

You should want to add this package to use OpenStreetMapLayer: ThinkGeo.MapSuite.Layers.OpenStreetMap

For Bing and Google layer it also have its standalone package.

Regards,

Ethan

Hi Richard,

Here is the workaround for xxxOverlay:

    public class CustomZoomLevelSet : ZoomLevelSet
{
    public CustomZoomLevelSet()
    {
        double worldWidth = 40075016.704;
        double tileWidth = 256;
        for (int i = 0; i < 20; i++)
        {
            double resolution = worldWidth / (tileWidth * Math.Pow(2, i));
            double scale = 39.3701 * 96 * resolution;
            CustomZoomLevels.Add(new ZoomLevel(scale));
        }
    }
}

And just set map1.ZoomLevelSet = new CustomZoomLevelSet();

Because some reason, we cannot put the code into the product, so if you need to use the xxxOverlay, you can just use the code for make it match the point.

Regards,

Ethan

This resolved the problem.

Hi Richard,

I am glad to hear that works.

Any question please let us know.

Regards,

Ethan

In order for the maps to line up with features properly I still have to use the custom zoom level set. Unfortunately this presents an additional problem which I cannot come up with a work around for. When zooming in close via a pinch zoom operation to the point where the map scale bar is below 50 feet the base maps stop displaying. Easiest way to duplicate is to simply pinch in until map scale is below 50 feet and then start panning around – I am using a tile cache with the bingmapOverlay so I haven’t checked to see if that is part of the issue.

Now using the regular bingMapsZoomLevelset there is not issue with the base maps displaying, but then I am back in a situation where features don’t line up as they should.

Richard,
The Bingmap support 20 zoom level. If your customzoomlevelset class has more than 21 level. It may not able to get the image tile.

So the max one we could use is 21. The Aerial map only support to 20.
And we recommend use Bingmapovlay instead of BingmapLayer.

Here is my code.

  private void InitalizeMap()
        {
            mapView.MapUnit = GeographyUnit.Meter;
            BingMapsOverlay bm = new BingMapsOverlay("You ID");
            mapView.Overlays.Add(bm);

            mapView.ZoomLevelSet = new CustomZoomLevelSet();
            mapView.CurrentExtent = new RectangleShape(-19062735.6816748, 9273256.52450252, -5746827.16371793, 2673516.56066139); ;
        }

Here is the zoom set

 public class CustomZoomLevelSet : ZoomLevelSet
    {
        public CustomZoomLevelSet()
        {
            double worldWidth = 40075016.704;
            double tileWidth = 256;
            for (int i = 0; i < 21; i++)
            {
                double resolution = worldWidth / (tileWidth * Math.Pow(2, i));
                double scale = 39.3701 * 96 * resolution;
                CustomZoomLevels.Add(new ZoomLevel(scale));
            }
        }
    }

If I misunderstand the issue. Could you attach a simple sample to here to help me understand the issue.

Thanks

Frank

That will teach me. Google has 23 and I should have checked to see how many the others had before re-using the same piece of code. Changed code for Bing so it only has 20 zoom levels and all is good now.

Thanks Richard,
Good to know it works. Go ahead let us know if you have any more questions.

Thanks

Frank