# Projection Issue with GetBitmap method

**URL:** <https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985>\
**Category:** MVC\
**Created:** [November 28, 2012, 6:07pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985 "2012-11-28T18:07:03Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rick](https://community.thinkgeo.com/u/Rick)\
**Post date:** [November 28, 2012, 6:07pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/1 "2012-11-28T18:07:03Z")

</div>

&nbsp;I&nbsp;am&nbsp;having&nbsp;issues&nbsp;trying&nbsp;to&nbsp;capture&nbsp;and&nbsp;save&nbsp;the&nbsp;map&nbsp;image&nbsp;using&nbsp;the&nbsp;GetBitmap&nbsp;method.

The&nbsp;image&nbsp;which&nbsp;is&nbsp;displayed&nbsp;in&nbsp;the&nbsp;browser&nbsp;has&nbsp;the&nbsp;correct&nbsp;projection,&nbsp;however&nbsp;when&nbsp;I&nbsp;use&nbsp;the&nbsp;GetBitmap&nbsp;method&nbsp;and&nbsp;save&nbsp;the&nbsp;image&nbsp;out&nbsp;to&nbsp;a&nbsp;file,&nbsp;the&nbsp;projection&nbsp;of&nbsp;the&nbsp;image&nbsp;is&nbsp;not&nbsp;correct.

&nbsp;

I&nbsp;have&nbsp;the&nbsp;full&nbsp;lic&nbsp;version&nbsp;of&nbsp;ThinkGeo&nbsp;MVC&nbsp;edition,&nbsp;the&nbsp;water&nbsp;marks&nbsp;in&nbsp;the&nbsp;image&nbsp;are&nbsp;due&nbsp;to&nbsp;me&nbsp;using&nbsp;my&nbsp;developer&nbsp;computer&nbsp;and&nbsp;iis&nbsp;express&nbsp;8.

I&nbsp;downloaded&nbsp;the&nbsp;latest&nbsp;dll’s&nbsp;from&nbsp;our&nbsp;customer&nbsp;portal.&nbsp;The&nbsp;versions&nbsp;are&nbsp;as&nbsp;follows.

MapSuiteCore.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6.0.0.198

MvcEdition.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6.0.0.198

&nbsp;

&nbsp;

Image&nbsp;from&nbsp;the&nbsp;browser&nbsp;which&nbsp;is&nbsp;using&nbsp;correct&nbsp;projection

 ![](https://community.thinkgeo.com/uploads/default/original/1X/57b949fc72a5f455a8061965e57ab9355e236f9c.png)

&nbsp;

Saved&nbsp;image&nbsp;from&nbsp;GetBitmap&nbsp;using&nbsp;incorrect&nbsp;projection&nbsp;

 ![](https://community.thinkgeo.com/uploads/default/original/1X/ead21862cc810136bd61f3fe933273766af226a1.png)

This&nbsp;is&nbsp;the&nbsp;gist&nbsp;of&nbsp;the&nbsp;code&nbsp;I&nbsp;am&nbsp;using

&nbsp;

&nbsp;

&nbsp;

`public imageOutput SaveImageCommand( imageInput input )        {            Map map = GetMapFromRequest( input.MapSessionId );            var MyBitmap = map.GetBitmap( );            MyBitmap.Save( @"d:\testmapImage2.png", ImageFormat.Png );            return new imageOutput( );        }public void CreateMap(){    Map map = new Map( MapName, new Unit( 100, UnitType.Percentage ), new Unit( 100, UnitType.Percentage ) );     map.MapBackground.BackgroundBrush = (new GeoSolidBrush( GeoColor.SimpleColors.Transparent ));            map.MapUnit = GeographyUnit.Meter;  LayerOverlay featuresOverlay = new LayerOverlay( "features" );                      featuresOverlay.IsVisible = true;                      featuresOverlay.IsBaseOverlay = false;            featuresOverlay.ServerCache.CacheDirectory = _settings.TileCachePath;            featuresOverlay.ServerCache.CacheId = Guid.NewGuid( ).ToString( );            featuresOverlay.Name = "features";            featuresOverlay.WebImageFormat = WebImageFormat.Png;            featuresOverlay.ClientCache.CacheId = "clientCacheID";            featuresOverlay.ClientCache.Duration = new TimeSpan( 0, 10, 0 );   featureOverlay.Layers.Add( ProcessFeatureShapes(input.ShapeData, projSphericalMercator) );      map.CustomOverlays.Add( featuresOverlay );    map.CurrentExtent = GetFullExtent( featureOverlay.Layers );  }       private RectangleShape GetFullExtent( GeoCollection<Layer> Layers )        {            List<BaseShape> rectangleShapes = new List<BaseShape>( );            foreach ( Layer layer in Layers )            {                layer.Open( );                if ( layer.HasBoundingBox == true )                    rectangleShapes.Add( layer.GetBoundingBox( ) );            }            return ExtentHelper.GetBoundingBoxOfItems( rectangleShapes );        }    private InMemoryFeatureLayer ProcessFeatureShapes( HashSet<ShapeData> shapeDataCollection, Proj4Projection projSphericalMercator )        {            InMemoryFeatureLayer layer = new InMemoryFeatureLayer( );            layer.Open( );            layer.Columns.Add( new FeatureSourceColumn( "name", DbfColumnType.String.ToString( ), 100 ) );            layer.Columns.Add( new FeatureSourceColumn( "data", DbfColumnType.Double.ToString( ), 40 ) );                        layer.EditTools.BeginTransaction( );                        foreach ( var shapeData in shapeDataCollection )            {                var data = _shapeFileProvider.GetShapeFileBinaryData( shapeData.Geography.GeographyType, shapeData.ShapeFileName ); //get the well known binary data                Feature feature = new Feature( data );                feature.ColumnValues.Add( "name", shapeData.Name );                feature.ColumnValues.Add( "data", shapeData.DataValue.ToString( ) );                feature.GetBoundingBox( ); //force the calculation.                layer.EditTools.Add( feature );            }                        layer.EditTools.CommitTransaction( );            layer.BuildIndex( );            layer.FeatureSource.Projection = projSphericalMercator;            layer.Close( );            return layer;        }`

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [November 29, 2012, 3:34am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/2 "2012-11-29T03:34:58Z")

</div>

Hi&nbsp;Rick,&nbsp;  
&nbsp;&nbsp;  
&nbsp;As&nbsp;your&nbsp;code&nbsp;is&nbsp;not&nbsp;runnable,&nbsp;so&nbsp;we&nbsp;tried&nbsp;to&nbsp;use&nbsp;our&nbsp;sample&nbsp;to&nbsp;recreate&nbsp;your&nbsp;scenario,&nbsp;but&nbsp;the&nbsp;image&nbsp;we&nbsp;get&nbsp;is&nbsp;the&nbsp;same&nbsp;as&nbsp;that&nbsp;in&nbsp;the&nbsp;browser,&nbsp;could&nbsp;you&nbsp;please&nbsp;provide&nbsp;a&nbsp;simple&nbsp;sample&nbsp;that&nbsp;could&nbsp;run?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Rick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rick](https://community.thinkgeo.com/u/Rick)\
**Post date:** [November 30, 2012, 5:53pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/3 "2012-11-30T17:53:49Z")

</div>

&nbsp;I&nbsp;took&nbsp;the&nbsp;example&nbsp;code&nbsp;"CSharp&nbsp;HowDoISamples&nbsp;Razor"&nbsp;and&nbsp;modified&nbsp;the&nbsp;UseADifferentProjectionForAFeatureLayer&nbsp;example&nbsp;to&nbsp;demostrate&nbsp;the&nbsp;issue.

I&nbsp;suspect,&nbsp;by&nbsp;the&nbsp;getbitmap&nbsp;call&nbsp;is&nbsp;not&nbsp;respecting&nbsp;the&nbsp;projection&nbsp;the&nbsp;layer&nbsp;is&nbsp;using,&nbsp;but&nbsp;instead&nbsp;using&nbsp;the&nbsp;orginal&nbsp;projection&nbsp;from&nbsp;the&nbsp;shape&nbsp;file.

when&nbsp;the&nbsp;image&nbsp;saves&nbsp;to&nbsp;disk,&nbsp;it&nbsp;is&nbsp;blank.

Here&nbsp;is&nbsp;the&nbsp;modified&nbsp;code&nbsp;for&nbsp;the&nbsp;view&nbsp;and&nbsp;controller.

I&nbsp;had&nbsp;to&nbsp;remove&nbsp;the&nbsp;\<&nbsp;from&nbsp;the&nbsp;script&nbsp;tag&nbsp;so&nbsp;the&nbsp;text&nbsp;would&nbsp;show.

&nbsp;

`@using ThinkGeo.MapSuite.Core;@using ThinkGeo.MapSuite.MvcEdition;script language="javascript" type="text/javascript">    function mapClick(e) {        Map1.ajaxCallAction('@ViewContext.RouteData.Values["Controller"].ToString( )', 'ClickEvent', { x: e.worldXY.lon, y: e.worldXY.lat }, null);    }/script>    @{Html.RenderPartial( "SourceCode" );}                        This sample converts a layer's projection from EPSG:4326 to EPSG:2163.                        <input type="button" id="btnZoomIn" value="Zoom In" onclick="Map1.zoomIn();return false;" />            <input type="button" id="btnZoomOut" value="Zoom Out" onclick="Map1.zoomOut();return false;" />                        @{            Html.ThinkGeo( ).Map( "Map1", new System.Web.UI.WebControls.Unit( 100, System.Web.UI.WebControls.UnitType.Percentage ), 510 )                .MapBackground( new BackgroundLayer( new GeoSolidBrush( GeoColor.FromHtml( "#E5E3DF" ) ) ) )                .CurrentExtent( -19268509.29874, 13535292.38285, 20656089.34576, -14435365.7673 )                .MapUnit( GeographyUnit.Meter )                .StaticOverlay( staticOverlay =>                {                    Proj4Projection proj4Projection = new Proj4Projection( );                    proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString( 4326 );                    proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString( );                    ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer( Server.MapPath( "~/App_Data/cntry02.shp" ) );                    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle( GeoColor.FromArgb( 255, 243, 239, 228 ), GeoColor.FromArgb( 255, 218, 193, 163 ), 1 );                    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;                    worldLayer.FeatureSource.Projection = proj4Projection;                    staticOverlay.TileType( TileType.SingleTile ).Layer( "WorldLayer", worldLayer );                } )                .OnClientClick( "mapClick" )                .Render( );        }    `&nbsp;&nbsp;`using System.Web.Mvc;using ThinkGeo.MapSuite.MvcEdition;using ThinkGeo.MapSuite.Core;using System.Drawing.Imaging;namespace CSharp_HowDoISamples{    public partial class ProjectionController : Controller    {        //        // GET: /UseADifferentProjectionForAFeatureLayer/        public ActionResult UseADifferentProjectionForAFeatureLayer( )        {            return View( );        }        [MapActionFilter]        public void ClickEvent( Map map, GeoCollection<object> args )        {                       var MyBitmap = map.GetBitmap( );            MyBitmap.Save( @"d:\testmapImage2.png", ImageFormat.Png );        }    }  }`

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [December 2, 2012, 10:56pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/4 "2012-12-02T22:56:48Z")

</div>

Rick,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;get&nbsp;the&nbsp;6.0.202.0&nbsp;or&nbsp;6.0.0.202&nbsp;or&nbsp;later&nbsp;and&nbsp;have&nbsp;a&nbsp;try,&nbsp;we&nbsp;fixed&nbsp;the&nbsp;bug&nbsp;in&nbsp;that&nbsp;version.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Rick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rick](https://community.thinkgeo.com/u/Rick)\
**Post date:** [December 9, 2012, 12:41pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/5 "2012-12-09T12:41:42Z")

</div>

&nbsp;I&nbsp;tested&nbsp;with&nbsp;the&nbsp;updated&nbsp;version&nbsp;6.0.0.202.&nbsp;and&nbsp;the&nbsp;UseADifferentProjectionForAFeatureLayer&nbsp;&nbsp;does&nbsp;now&nbsp;save&nbsp;the&nbsp;correct&nbsp;image.

I&nbsp;also&nbsp;tested&nbsp;with&nbsp;the&nbsp;version&nbsp;6.0.0.209

however,&nbsp;when&nbsp;i&nbsp;applied&nbsp;it&nbsp;to&nbsp;my&nbsp;application,&nbsp;i&nbsp;am&nbsp;still&nbsp;getting&nbsp;a&nbsp;different&nbsp;projection&nbsp;on&nbsp;the&nbsp;saved&nbsp;image.

I&nbsp;am&nbsp;using&nbsp;an&nbsp;InMemoryFeatureLayer&nbsp;and&nbsp;reading&nbsp;an&nbsp;external&nbsp;file&nbsp;(wellknownbinary&nbsp;data)&nbsp;and&nbsp;creating&nbsp;a&nbsp;feature&nbsp;from&nbsp;that&nbsp;and&nbsp;adding&nbsp;it&nbsp;into&nbsp;the&nbsp;layer.

I&nbsp;modified&nbsp;the&nbsp;LoadAHeatLayer&nbsp;example&nbsp;in&nbsp;the&nbsp;HowDoISamples&nbsp;razor.&nbsp;which&nbsp;basically&nbsp;does&nbsp;what&nbsp;our&nbsp;application&nbsp;is&nbsp;doing,&nbsp;and&nbsp;am&nbsp;able&nbsp;to&nbsp;reproduce&nbsp;the&nbsp;exact&nbsp;issue.

I&nbsp;have&nbsp;included&nbsp;the&nbsp;modified&nbsp;source,&nbsp;and&nbsp;the&nbsp;binaryfile&nbsp;i&nbsp;used.

The&nbsp;binary&nbsp;file&nbsp;(48.imgData)&nbsp;,&nbsp;i&nbsp;put&nbsp;into&nbsp;the&nbsp;App\_data&nbsp;folder.&nbsp;The&nbsp;file&nbsp;is&nbsp;the&nbsp;representation&nbsp;of&nbsp;the&nbsp;State&nbsp;of&nbsp;Texas.&nbsp;I&nbsp;had&nbsp;to&nbsp;zip&nbsp;the&nbsp;file&nbsp;so&nbsp;I&nbsp;could&nbsp;attach&nbsp;it&nbsp;to&nbsp;the&nbsp;post.

View&nbsp;Code:

I&nbsp;had&nbsp;to&nbsp;remove&nbsp;the&nbsp;\<&nbsp;from&nbsp;the&nbsp;script&nbsp;tag&nbsp;so&nbsp;the&nbsp;text&nbsp;would&nbsp;show.

&nbsp;

&nbsp;

`@using ThinkGeo.MapSuite.MvcEdition@using ThinkGeo.MapSuite.Core@model ThinkGeo.MapSuite.MvcEdition.Map script language="javascript" type="text/javascript">    function mapClick(e) {        var params = { x: e.worldXY.lon, y: e.worldXY.lat };        Map1.ajaxCallAction('@ViewContext.RouteData.Values["Controller"].ToString( )', 'ClickEvent', params, mapCallback);    }    function mapCallback(result) {        Map1.redrawLayer('features');    }/script>    @{Html.RenderPartial( "SourceCode" );}                        This sample demonstrates how to show HeatLayer with MapSuite.                        @{            Html.ThinkGeo( ).Map( Model )                .OnClientClick( "mapClick" ).Render( );        }    `

Controller&nbsp;Code:

&nbsp;

`using System;using System.Web.Mvc;using ThinkGeo.MapSuite.Core;using ThinkGeo.MapSuite.MvcEdition;using System.Drawing.Imaging;using System.IO;using System.Collections.Generic;namespace CSharp_HowDoISamples{    public partial class LayersFeatureSourcesController : Controller    {        //        // GET: /LoadAHeatLayer/        public ActionResult LoadAHeatLayer( )        {            Map map = new Map( "Map1", new System.Web.UI.WebControls.Unit( 100, System.Web.UI.WebControls.UnitType.Percentage ), new System.Web.UI.WebControls.Unit( 100, System.Web.UI.WebControls.UnitType.Percentage ) );            map.MapBackground.BackgroundBrush = (new GeoSolidBrush( GeoColor.SimpleColors.Transparent ));            map.MapUnit = GeographyUnit.Meter;            map.StaticOverlay.SetBaseEpsgProjection( Proj4Projection.GetGoogleMapParametersString( ) );            Proj4Projection projSphericalMercator = new Proj4Projection( );            projSphericalMercator.InternalProjectionParametersString = Proj4Projection.GetEsriParametersString( 4326 ); //North America Albers Equal Area Conic            projSphericalMercator.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString( );            projSphericalMercator.Open( );            var layer = GetFeatureLayer( );            layer.FeatureSource.Projection = projSphericalMercator;            LayerOverlay featuresOverlay = new LayerOverlay( "features" );            featuresOverlay.IsVisible = true;            featuresOverlay.Name = "features";            featuresOverlay.WebImageFormat = WebImageFormat.Png;            featuresOverlay.Layers.Add( layer );            map.StaticOverlay.IsBaseOverlay = false;            map.CustomOverlays.Add( featuresOverlay );            featuresOverlay.IsBaseOverlay = true;            featuresOverlay.SetBaseEpsgProjection( Proj4Projection.GetGoogleMapParametersString( ) );            featuresOverlay.IsBaseOverlay = false;            map.CurrentExtent = GetFullExtent( featuresOverlay.Layers );            return View( map );        }        public InMemoryFeatureLayer GetFeatureLayer( )        {            InMemoryFeatureLayer result = new InMemoryFeatureLayer( );            GeoPen newGeoPen3 = new GeoPen( new GeoColor( 100, GeoColor.StandardColors.Black ) );            newGeoPen3.Width = 0.3f;            GeoPen newGeoPen1 = new GeoPen( new GeoColor( 100, GeoColor.StandardColors.Black ) );            newGeoPen1.Width = 0.1f;            result.Open( );            result.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.State1( "name" );            result.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush = new GeoSolidBrush( GeoColor.StandardColors.Black );            result.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen = newGeoPen3;            result.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            result.Columns.Add( new FeatureSourceColumn( "name", DbfColumnType.String.ToString( ), 100 ) );            result.Columns.Add( new FeatureSourceColumn( "data", DbfColumnType.Double.ToString( ), 40 ) );            result.EditTools.BeginTransaction( );            var data = GetShapeFileBinaryData( Server.MapPath( "~/App_Data/48.imgData" ) );            Feature feature = new Feature( data );            feature.ColumnValues.Add( "name", "Texas" );            feature.ColumnValues.Add( "data", "200" );            feature.GetBoundingBox( ); //force the calculation.            result.EditTools.Add( feature );            result.EditTools.CommitTransaction( );            result.BuildIndex( );            return result;        }        private RectangleShape GetFullExtent( GeoCollection<Layer> Layers )        {            List<BaseShape> rectangleShapes = new List<BaseShape>( );            foreach ( Layer layer in Layers )            {                layer.Open( );                if ( layer.HasBoundingBox == true )                    rectangleShapes.Add( layer.GetBoundingBox( ) );            }            return ExtentHelper.GetBoundingBoxOfItems( rectangleShapes );        }        public byte[] GetShapeFileBinaryData( string fileName )        {            byte[] data = null;            using ( var stream = new FileStream( fileName, FileMode.Open, FileAccess.Read, FileShare.Read ) )            {                data = new byte[stream.Length];                using ( BinaryReader reader = new BinaryReader( stream ) )                {                    reader.Read( data, 0, (int)stream.Length );                }            }            return data;        }        [MapActionFilter]        public void ClickEvent( Map map, GeoCollection<object> args )        {            var MyBitmap = map.GetBitmap( );            MyBitmap.Save( @"d:\testmapImage2.png", ImageFormat.Png );        }    }}`  
  
[48.zip](https://community.thinkgeo.com/uploads/default/original/2X/0/04f2d8250cc76ab6ef756b0109ee008d264dccaf.zip) (588 KB)

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [December 10, 2012, 3:55am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/6 "2012-12-10T03:55:29Z")

</div>

Rick,

Changing&nbsp;two&nbsp;parts&nbsp;of&nbsp;your&nbsp;code&nbsp;will&nbsp;solve&nbsp;the&nbsp;problem,

Method&nbsp;ClickEvent

`string[] Locations=((string)args[2]).Split(',');map.CurrentExtent = new  RctangleShape(double.Parse(Locations[0]),double.Parse(Locations[3]),double.Parse(Locations[2]),double.Parse(Locations[1]));`

Js&nbsp;part

`var params = { x: e.worldXY.lon, y: e.worldXY.lat, extent: e.view.Map1.getExtent() };`

Regards,

Edgar

---

<div class="post-metadata">

**Author:** ![Rick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rick](https://community.thinkgeo.com/u/Rick)\
**Post date:** [December 10, 2012, 11:00am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/7 "2012-12-10T11:00:22Z")

</div>

&nbsp;Thanks&nbsp;for&nbsp;the&nbsp;reply,&nbsp;that&nbsp;worked.

Now&nbsp;the&nbsp;question&nbsp;is,&nbsp;why&nbsp;and&nbsp;how&nbsp;would&nbsp;i&nbsp;find&nbsp;that&nbsp;in&nbsp;the&nbsp;documentation?

&nbsp;

Rick

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [December 10, 2012, 7:14pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/8 "2012-12-10T19:14:11Z")

</div>

There&nbsp;is&nbsp;no&nbsp;documentation&nbsp;about&nbsp;this,&nbsp;the&nbsp;reason&nbsp;you&nbsp;get&nbsp;the&nbsp;wrong&nbsp;bitmap&nbsp;is&nbsp;the&nbsp;real&nbsp;map.CurrentExtent&nbsp;has&nbsp;not&nbsp;been&nbsp;updated&nbsp;when&nbsp;you&nbsp;click&nbsp;on&nbsp;it&nbsp;without&nbsp;a&nbsp;callback,&nbsp;so&nbsp;the&nbsp;width/height&nbsp;of&nbsp;extent&nbsp;is&nbsp;not&nbsp;equal&nbsp;to&nbsp;the&nbsp;width/height&nbsp;of&nbsp;the&nbsp;map,&nbsp;then&nbsp;the&nbsp;image&nbsp;would&nbsp;be&nbsp;stretched,&nbsp;so&nbsp;you&nbsp;need&nbsp;to&nbsp;get&nbsp;the&nbsp;real&nbsp;extent&nbsp;from&nbsp;the&nbsp;client&nbsp;side&nbsp;to&nbsp;get&nbsp;the&nbsp;right&nbsp;image.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Chuck](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/8e7dd6/32.png) [@Chuck](https://community.thinkgeo.com/u/Chuck)\
**Post date:** [April 15, 2013, 5:38pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/9 "2013-04-15T17:38:31Z")

</div>

I&nbsp;there&nbsp;any&nbsp;way&nbsp;to&nbsp;get&nbsp;the&nbsp;map&nbsp;extent&nbsp;without&nbsp;having&nbsp;to&nbsp;render&nbsp;it&nbsp;in&nbsp;the&nbsp;UI&nbsp;first?

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [April 16, 2013, 12:11am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/10 "2013-04-16T00:11:39Z")

</div>

Hi&nbsp;Chuck,&nbsp;  
&nbsp;&nbsp;  
&nbsp;As&nbsp;far&nbsp;as&nbsp;I&nbsp;know,&nbsp;there&nbsp;isn’t&nbsp;a&nbsp;better/easier&nbsp;way&nbsp;to&nbsp;manage&nbsp;it,&nbsp;for&nbsp;the&nbsp;synchronization&nbsp;between&nbsp;client&nbsp;and&nbsp;server&nbsp;side&nbsp;is&nbsp;a&nbsp;bit&nbsp;complicated,&nbsp;which&nbsp;requires&nbsp;lots&nbsp;of&nbsp;codes&nbsp;to&nbsp;implement&nbsp;it,&nbsp;as&nbsp;the&nbsp;interaction&nbsp;is&nbsp;always&nbsp;a&nbsp;Ajax&nbsp;call&nbsp;and&nbsp;&nbsp;if&nbsp;we&nbsp;want&nbsp;to&nbsp;keep&nbsp;the&nbsp;sync,&nbsp;a&nbsp;large&nbsp;number&nbsp;of&nbsp;data&nbsp;would&nbsp;be&nbsp;attached&nbsp;in&nbsp;every&nbsp;Ajax&nbsp;call&nbsp;which&nbsp;is&nbsp;not&nbsp;the&nbsp;purpose&nbsp;of&nbsp;Mvc.&nbsp;But,&nbsp;in&nbsp;the&nbsp;code&nbsp;behind&nbsp;mode,&nbsp;we&nbsp;can&nbsp;keep&nbsp;the&nbsp;sync&nbsp;easily&nbsp;by&nbsp;a&nbsp;post&nbsp;back.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Hope&nbsp;it&nbsp;helps.&nbsp;  
&nbsp;Thanks&nbsp;  
&nbsp;&nbsp;  
&nbsp;Johnny&nbsp;

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [April 16, 2013, 2:51am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/11 "2013-04-16T02:51:15Z")

</div>

&nbsp;Hi&nbsp;James,

Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;welcome&nbsp;to&nbsp;MapSuite&nbsp;World,&nbsp;please&nbsp;get&nbsp;the&nbsp;latest&nbsp;version&nbsp;6.0.0.338&nbsp;or&nbsp;6.0.338.0&nbsp;first&nbsp;from&nbsp;[helpdesk.thinkgeo.com](http://helpdesk.thinkgeo.com)&nbsp;,&nbsp;here&nbsp;we&nbsp;fixed&nbsp;1&nbsp;bug&nbsp;on&nbsp;Wms&nbsp;stuff,&nbsp;then&nbsp;I&nbsp;guess&nbsp;there&nbsp;are&nbsp;two&nbsp;ways&nbsp;to&nbsp;add&nbsp;WMS:&nbsp;

1.&nbsp;Use&nbsp;a&nbsp;WMS&nbsp;plugin,&nbsp;attached&nbsp;is&nbsp;the&nbsp;sample&nbsp;of&nbsp;the&nbsp;plugin.&nbsp;Please&nbsp;build&nbsp;it&nbsp;and&nbsp;copy&nbsp;the&nbsp;dll&nbsp;to&nbsp;“C:\Program&nbsp;Files&nbsp;(x86)\ThinkGeo\Map&nbsp;Suite&nbsp;GIS&nbsp;Editor\Map&nbsp;Suite&nbsp;GISEditor\Plugins”

2.&nbsp;Use&nbsp;dynamic&nbsp;language&nbsp;to&nbsp;fulfill&nbsp;it,&nbsp;dynamic&nbsp;function&nbsp;is&nbsp;in&nbsp;here:

 ![](https://community.thinkgeo.com/uploads/default/original/2X/0/0f7680d76324cc42cbf2a10190ceb62eddc4c0af.png)

Then&nbsp;type&nbsp;in&nbsp;the&nbsp;popup&nbsp;window&nbsp;with&nbsp;the&nbsp;code&nbsp;in&nbsp;“Post11167SampleForDynamicLanguage.txt”&nbsp;attached.

The&nbsp;reason&nbsp;of&nbsp;not&nbsp;using&nbsp;wms&nbsp;as&nbsp;a&nbsp;default&nbsp;base&nbsp;layer&nbsp;is&nbsp;wms&nbsp;depends&nbsp;on&nbsp;the&nbsp;internet&nbsp;and&nbsp;sometimes&nbsp;it&nbsp;will&nbsp;cause&nbsp;our&nbsp;GisEditor&nbsp;stuck.&nbsp;We&nbsp;will&nbsp;fix&nbsp;this&nbsp;problem&nbsp;in&nbsp;the&nbsp;near&nbsp;future.

Hope&nbsp;it&nbsp;helps,

Johnny

&nbsp;

[Post11167SampleForDynamicLanguage.txt](https://community.thinkgeo.com/uploads/default/original/2X/7/77d59d8a8279e4f2cbb291ab94c12f04d1d495aa.txt) (941 Bytes)  
[Post11167Sample.zip](https://community.thinkgeo.com/uploads/default/original/2X/a/aea0c62a501731591d248403191d7ad1809e2aa4.zip) (5.77 KB)

---

<div class="post-metadata">

**Author:** ![Chuck](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/8e7dd6/32.png) [@Chuck](https://community.thinkgeo.com/u/Chuck)\
**Post date:** [April 16, 2013, 4:27pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/12 "2013-04-16T16:27:49Z")

</div>

Hi&nbsp;Johnny,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;the&nbsp;reply.&nbsp;&nbsp;I&nbsp;know&nbsp;that&nbsp;in&nbsp;web&nbsp;edition&nbsp;you&nbsp;can&nbsp;call&nbsp;GetBitMap&nbsp;on&nbsp;a&nbsp;map&nbsp;during&nbsp;initial&nbsp;page&nbsp;load&nbsp;(i.e.,&nbsp;no&nbsp;post-back)&nbsp;and&nbsp;the&nbsp;image&nbsp;will&nbsp;be&nbsp;projected&nbsp;correctly.&nbsp;&nbsp;If&nbsp;you&nbsp;try&nbsp;the&nbsp;same&nbsp;in&nbsp;an&nbsp;MVC&nbsp;controller&nbsp;(with&nbsp;Web&nbsp;or&nbsp;MVC&nbsp;edition)&nbsp;then&nbsp;the&nbsp;projection&nbsp;problem&nbsp;described&nbsp;by&nbsp;Rick&nbsp;will&nbsp;occurr.&nbsp;  
&nbsp;&nbsp;  
&nbsp;How&nbsp;is&nbsp;it&nbsp;that&nbsp;the&nbsp;client-side&nbsp;extent&nbsp;is&nbsp;known&nbsp;in&nbsp;a&nbsp;webforms&nbsp;aspx&nbsp;page&nbsp;without&nbsp;posting&nbsp;back?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Chuck

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [April 17, 2013, 4:58am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/13 "2013-04-17T04:58:24Z")

</div>

&nbsp;Hi&nbsp;Chuck,

If&nbsp;the&nbsp;clientmap.Currentextent&nbsp;and&nbsp;clientmap.HeightInPixels&nbsp;and&nbsp;clientmap.WidthInPixel&nbsp;are&nbsp;known&nbsp;in&nbsp;the&nbsp;serverside,&nbsp;then&nbsp;in&nbsp;the&nbsp;server&nbsp;side&nbsp;(controller&nbsp;in&nbsp;MVC)&nbsp;we&nbsp;can&nbsp;use:

`servermap.Currentextent=map.Currentextent;servermap.GetBitmap(map.WidthInPixel,map.HeightInPixel);`

to&nbsp;get&nbsp;the&nbsp;right&nbsp;bitmap.

But,&nbsp;the&nbsp;problem&nbsp;is&nbsp;that&nbsp;the&nbsp;clientmap.Currentextent&nbsp;and&nbsp;clientmap.HeightInPixels&nbsp;and&nbsp;clientmap.WidthInPixel&nbsp;are&nbsp;calculated&nbsp;in&nbsp;the&nbsp;client-side&nbsp;and&nbsp;are&nbsp;not&nbsp;known&nbsp;in&nbsp;the&nbsp;serverside,&nbsp;server-side&nbsp;don’t&nbsp;know&nbsp;them&nbsp;because&nbsp;client-side&nbsp;doesn’t&nbsp;send&nbsp;them&nbsp;back&nbsp;to&nbsp;server-side&nbsp;yet,&nbsp;and&nbsp;therefore&nbsp;server-side&nbsp;can’t&nbsp;get&nbsp;the&nbsp;right&nbsp;bitmap&nbsp;in&nbsp;MVC.

So,&nbsp;to&nbsp;get&nbsp;these&nbsp;three&nbsp;parameters&nbsp;for&nbsp;server-side&nbsp;we&nbsp;need&nbsp;to&nbsp;use&nbsp;a&nbsp;postback&nbsp;or&nbsp;ajaxcall.&nbsp;As&nbsp;the&nbsp;question&nbsp;is&nbsp;“How&nbsp;is&nbsp;it&nbsp;that&nbsp;the&nbsp;client-side&nbsp;extent&nbsp;is&nbsp;known&nbsp;in&nbsp;a&nbsp;webforms&nbsp;aspx&nbsp;page&nbsp;without&nbsp;posting&nbsp;back?”,&nbsp;the&nbsp;choice&nbsp;would&nbsp;be&nbsp;to&nbsp;ajaxcall.

Attached&nbsp;is&nbsp;the&nbsp;sample&nbsp;of&nbsp;using&nbsp;ajaxcall&nbsp;to&nbsp;get&nbsp;the&nbsp;bitmap

Hope&nbsp;it&nbsp;helps

Gary

[Post10859Sample.zip](https://community.thinkgeo.com/uploads/default/original/2X/6/63cc94ea2ad98f8b9666a7b4dd05e45e118dde5e.zip) (1.32 KB)

---

<div class="post-metadata">

**Author:** ![Chuck](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/8e7dd6/32.png) [@Chuck](https://community.thinkgeo.com/u/Chuck)\
**Post date:** [April 17, 2013, 8:10am UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/14 "2013-04-17T08:10:45Z")

</div>

Thanks&nbsp;Gary&nbsp;-&nbsp;that&nbsp;helps.

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [April 17, 2013, 8:56pm UTC](https://community.thinkgeo.com/t/projection-issue-with-getbitmap-method/3985/15 "2013-04-17T20:56:44Z")

</div>

Glad&nbsp;to&nbsp;hear&nbsp;that&nbsp;it&nbsp;works.&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Johnny
