ThinkGeo.com    |     Blog    |     Wiki    |     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