Q&A - Question
How to zoom the map to the shape
JörD asked on August 08, 2018, keyword: Viewer / Editor
I have different shape types for example: Point, Line, multi-point. I want to zoom the map to the shape after drawing.
The experiments with
GIS. ZoomBy (GIS. Zoom * 2, Pt. X, Pt. y); // shp.Centroid.X/Y
or as in the answer:
does not work with all shape types.
Could you recommend a procedure that is valid for all shape types?
Thank you in advance.
EltS replied August 08, 2018
We usually calculate the map extension by the shape to zoom it.
Example: you have a point shape, Pt.X = 10, Pt.Y = 20, so you could calculate TGIS_Extent like this bellow:
extent.XMax = 10 + 5 //-- The five is a factor of zoom
extent.XMin = 10 - 5
extent.YMax = 20 + 5
extent.YMin = 20 - 5
and then you can set the MAP.VisibleExtent = extent
by the way, you could have more than one shape, you just have to iterate to get the "max" and "min' coordinates and then apply that same method.
That I know of, if you have a polygon, you could iterate the shape parts and points to get the coordinates and again apply that same method.
JörD replied August 08, 2018
thank you for your support.
I tested it superficial and it works very well!
Tomasz Kosinski (TatukGIS) replied August 08, 2018
Generally try to use
shape.ProjectedExtetnt instead of shape.Extent.
shape.ProjectedExtent is already expressed in a viewer coordinate system while shape.Extent is expressed ina layer coordinate system
If you would like to answer the question please Sign In.
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
- Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
- Keep the content positive and professional.
- Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
- The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.