Fix for setting Zoom property

Oct 12, 2010 at 1:43 AM

Hi Radioman,

Using winforms I had a problem with the visual studio form designer refusing to open because it was getting an "Object reference not set to an instance of an object." error. I tracked this to be becase I had set a value for the Zoom property of the map control, and the code in GMap.NET.Interals\Core.cs for the set function of the Zoom property was failing becase the Projection object was null. The following change stopped it crashing:

// --- origonal code ---

      public int Zoom
      {
         set
         {
            if(zoom != value && !IsDragging)
            {
               zoom = value;

               minOfTiles = Projection.GetTileMatrixMinXY(value);
               // more code ...
            }
         }
      }

// --- changed code ---
      public int Zoom
      {
         set
         {
            if(zoom != value && !IsDragging)
            {
               zoom = value;
               if (Projection != null)     // added this  if   statement
               {
                  minOfTiles = Projection.GetTileMatrixMinXY(value);
                  // more code ...
               }
            }
         }
      }

 

Oct 12, 2010 at 7:02 AM

fixed, thanks!