Zoom to particular latitude and longtitude

Oct 9, 2012 at 6:49 PM

Hi all,

   If I enter latitude and longtitude in  a textbox, how do i Zoom to that particular co-ordinates




Oct 9, 2012 at 7:45 PM

Assuming your map is in the same spatial reference coordinate system of the coordinates you specify in the textbox, the following code will center the map at the specified coordinate while maintaining your current map scale.

        public void WindowCenter(Map dsMapToCenter, DotSpatial.Topology.Coordinate dsMapPoint)
                IEnvelope dsEnvelope = dsMapToCenter.ViewExtents.ToEnvelope();
                DotSpatial.Topology.Coordinate srcPt = dsMapToCenter.ViewExtents.Center;
                DotSpatial.Topology.Coordinate trgPt = dsMapPoint;
                dsEnvelope.Translate((trgPt.X - srcPt.X), (trgPt.Y - srcPt.Y));
                dsMapToCenter.ViewExtents = new Extent(dsEnvelope);

Oct 9, 2012 at 7:57 PM

Hi ,

   I just tried out the code, the map is centering at the searched  coordinate , how do i add zoom level capability here . When i used zoomIn() , it is very less.

Should i repeated used zoomin() until the correct size i want is attained?




Oct 9, 2012 at 9:03 PM

The envelope (dsEnvelope) has a zoom method on it that accepts a value.  You could specify whatever you want in the Zoom method before you convert to an extent and set on the Map.


Oct 19, 2012 at 11:20 AM



Here dsenvelope is not aking function called 

    dsEnvelope.Translate((trgPt.X - srcPt.X), (trgPt.Y - srcPt.Y));
please help

Oct 19, 2012 at 1:05 PM

Translate is defined as a C# extension.  You'll need to add a using statement for the namespace where the extension is defined.  It is probably one of the ones here:

using DotSpatial.Controls;
using DotSpatial.Data;
using DotSpatial.Projections;
using DotSpatial.Symbology;
using DotSpatial.Topology;

Oct 25, 2012 at 1:14 PM

Hey could you please show me some quick sample or code snippet . I am unable to handle this...