Common Questions and Answers About Map Suite Desktop
Click on any of the frequently asked questions below to be taken to the
answer.
- If I have the latitude and longitude of a
point, how can I plot it on a map?
- I would like to have more custom properties
(like a tag property) on a map shape object. How can I add my own
properties?
- How do I convert screen coordinates into
world coordinates?
- How do I convert world coordinates into
screen coordinates?
- How can I find a map shape when the user
clicks it?
- How can I find a feature (road, city, etc.)
when the user clicks it?
- How can I zoom in on an area based on a
query?
- I see a layer can have different zoomLevels.
What would I use this feature for?
- How can I get information about point or
feature from a dbf file?
- Once I have a record number, how can I get
the shape for that record?
- How can I zoom in or out programmatically?
- How can I set the full extent of a map to
something specific?
- How can I display my data so each item
falls within some group? For example, if I have several cities with
different populations, how could I group these cities into the categories
of small, medium, and large, each with its own symbol on the map?
- How can I display my data so each item is
represented with a special symbol based on a exact textual match (not
categories, classes or ranges)? For example, a lake should be blue, a dry
lake should be brown, etc.
- How can I use my own rendering logic when
the symbol representing an place's location is being drawn?
- How can I have items labeled differently
based on a value in a field in the shape file? For example, if I have
several cities in each country in Europe, I want to show capitals in a
larger font than non-capitals.
- I see that a map can have multiple layers.
Why would I use multiple layers?
- How can I print a map?
- How can I print a map if I want to include
my own logic? For example, if I want to include a legend or some
additional text?
- I want a user to be able to draw various
shapes (circles, rectangles, etc.) and I want to execute some custom logic
while the shape is being created. How can I do this?
- What are map shapes and how can I use them?
- How can I define my own custom labeling
plug-in?
- Can I change the data in a shape file, and
if so, how?
- How can I stop one or more map shapes from
being printed while printing the map?
- What do I need to do to distribute my
application which uses Map Suite? How do I get all the dependencies on the
destination computer?
- What vector and raster formats are
supported by Map Suite?
- How do I zoom in to Point?
- How do I zoom in to a set of MapShape
Points?
- How can I dynamically load controls using
spatial queries?
- Is there a way to highlight map features
based on a SQL query?
- How can I add satellite and aerial imagery
to my project?
If I have the latitude and longitude of a point, how can I
plot it on a map?
All you need to do is, 1) Create a new point, 2) Add that point to the map.
Create a new Winforms project, add a map (name it Map1) to the form, and add
the following code to the form's load event:
C#
// This first section is simply to get
get a map of the US to show
map1.MapUnit = MapSuite.Geometry.MapLengthUnits.DecimalDegrees;
MapSuite.Layer
lyr = new MapSuite.Layer(@"..\..\sampledata\world\cntry02.shp");
lyr.ZoomLevelExtentUnit = MapSuite.Geometry.ZoomLevelExtentUnits.miles;
MapSuite.ZoomLevel
t = new MapSuite.ZoomLevel(30000,
0);
MapSuite.AreaSymbol
area = new MapSuite.AreaSymbol(new GeoPen(GeoColor.KnownColors.Black, 1), new GeoSolidBrush(GeoColor.KnownColors.LightGray));
MapSuite.SymbolRenderer
sr = new MapSuite.SymbolRenderer(area);
t.GeoStyle.SymbolRenderers.Add(sr);
lyr.CustomZoomLevels.Add(t);
map1.Layers.Add(lyr);
// This second section is all you need
to plot a point if you have the latitude and longitude
MapSuite.Geometry.PointShape
ps = new MapSuite.Geometry.PointShape(-119.09, 34.32);
map1.MapShapes.Add(new
MapSuite.PointMapShape(ps, new MapSuite.PointSymbol(MapSuite.PointStyleEnum.Circle)));
//This third section shows how to add a
label for the point
MapSuite.TextSymbol
ts = new MapSuite.TextSymbol(new GeoFont("Arial", 8), new
GeoSolidBrush(GeoColor.KnownColors.Blue),
0, 10);
map1.MapShapes[0].TextSymbols.Add(ts);
map1.MapShapes[0].Name = "Los Angeles";
map1.Refresh();
VB.NET
' This first section is simply to get
get a map of the US to show
map1.MapUnit =
MapSuite.Geometry.MapLengthUnits.DecimalDegrees
Dim lyr As New MapSuite.Layer("..\..\sampledata\world\cntry02.shp")
lyr.ZoomLevelExtentUnit = MapSuite.Geometry. ZoomLevelExtentUnits.miles
Dim t As New MapSuite.ZoomLevel(30000, 0)
Dim area As New MapSuite.AreaSymbol(New
GeoPen(GeoColor.KnownColors.Black, 1), New
GeoSolidBrush(GeoColor.KnownColors.LightGray))
Dim sr As New MapSuite.SymbolRenderer(area)
t.GeoStyle.SymbolRenderers.Add(sr)
lyr.CustomZoomLevels.Add(t)
map1.Layers.Add(lyr)
' This second section is all you need to
plot a point if you have the latitude and longitude
Dim ps As New MapSuite.Geometry.PointShape(-119.09, 34.32)
map1.MapShapes.Add(New
MapSuite.PointMapShape(ps, New MapSuite.PointSymbol(MapSuite.PointStyleEnum.Circle)))
'This third section shows how to add a
label for the point
Dim ts As New MapSuite.TextSymbol(New
GeoFont("Arial", 8), New GeoSolidBrush(GeoColor.KnownColors.Blue), 0, 10)
map1.MapShapes(0).TextSymbols.Add(ts)
map1.MapShapes(0).Name = "Los Angeles"
map1.Refresh()
Back to Top
I would like to have more custom properties (like a tag
property) on a map shape object. How can I add my own properties?
Adding custom properties is quite easy. All you have to do is inherit from
one of the classes and add your own custom properties, like in the following
code:
C#
public class MyPointMapShape : PointMapShape
{
public
MyPointMapShape(PointShape PointShape, PointSymbol PointSymbol)
: base(PointShape,
PointSymbol)
{
}
string _Tag = string.Empty;
public string Tag
{
get
{
return
_Tag;
}
set
{
_Tag = value;
}
}
}
VB.NET
Public Class
MyPointMapShape
Inherits
PointMapShape
Public Sub New(ByVal PointShape As
PointShape, ByVal PointSymbol As PointSymbol)
MyBase.New(PointShape,
PointSymbol)
End Sub
Private _Tag As String = String.Empty
Public Property Tag() As String
Get
Return
_Tag
End Get
Set(ByVal value As String)
_Tag = value
End Set
End Property
End
Class
From here, you can add as many custom properties as you would like.
Back to Top
How do I convert screen coordinates into world coordinates?
The map control has a method ToWorldCoordinate which takes in a PointF
object (a point in canvas / screen coordinates). Returned is a PointR object (a
point in world coordinates).
C#
System.Drawing.PointF
controlPointF = new System.Drawing.PointF(45, 34);
PointR pointR =
Map1.ToWorldCoordinate(controlPointF);
PointShape p0 = new PointShape(pointR.X,
pointR.Y);
VB.NET
Dim controlPointF As New System.Drawing.PointF(45, 34)
Dim pointR As PointR =
Map1.ToWorldCoordinate(controlPointF)
Dim p0 As New PointShape(pointR.X, pointR.Y)
Back to Top
How do I convert world coordinates into screen coordinates?
The map control has a method ToCanvasCoordinate which takes in a PointR
object (a point in world coordinates). Returned is a PointF object (a point in
canvas / screen coordinates).
C#
PointShape pointShape = new PointShape(-119.09,
34.32);
System.Drawing.PointF screetPoint =
Map1.ToCanvasCoordinate(pointShape.X, pointShape.Y);
VB.NET
Dim pointShape As New PointShape(-119.09, 34.32)
Dim screetPoint As
System.Drawing.PointF = Map1.ToCanvasCoordinate(pointShape.X, pointShape.Y)
Back to Top
How can I find a map shape when the user clicks it?
First, set the Map.Mode to ModeType.SelectMapShapes. Once this is done,
every time a map shape is clicked, the Map.SelectMapShapes event will fire,
passing in the map shapes that were selected. It is the map shapes (plural)
because you could have more than one map shape in one location. Therefore, when
that location is clicked, it is unclear which map shape was meant. So, it is
actually an array of map shapes. Here is the code to make it clearer. Note: The
Geometry sample named "Select Map Shapes Mode" can show you more
detail on this.
VB.NET
private void
Map1_SelectMapShapes(MapSuite.BaseMapShape[]
MapShapes)
{
if (MapShapes != null)
MessageBox.Show(MapShapes[0].Name);
}
VB.NET
Private Sub
Map1_SelectMapShapes(ByVal MapShapes As MapSuite.BaseMapShape())
If MapShapes IsNot Nothing Then
MessageBox.Show(MapShapes(0).Name)
End If
End
Sub
Back to Top
How can I find a feature (road, city, etc.) when the user
clicks it?
First, set the Map.Mode to ModeType.SelectFeatures. Once this is done, every
time a feature is clicked, the Map.SelectFeatures event will fire, passing in
the features that were selected. It is the features (plural) because you could
have more than one feature in one location (for example, a bridge crossing over
a river). Here is the code to make it clearer. Note: The Query sample named
"Select Features Mode" can show you more detail on this.
C#
private void
Map1_SelectFeatures(MapSuite.FeatureInfo[]
FeatureInfos)
{
if (FeatureInfos
!= null)
MessageBox.Show(FeatureInfos[0].RecordNumber.ToString());
}
VB.NET
Private Sub
Map1_SelectFeatures(ByVal FeatureInfos As MapSuite.FeatureInfo())
If FeatureInfos IsNot Nothing Then
MessageBox.Show(FeatureInfos(0).RecordNumber.ToString())
End If
End
Sub
Back to Top
How can I zoom in on an area based on a query?
First, you need to create a custom field object, but the real work comes
from calling GetRecordsExtents
function from the layer object to see the extent you need to use. Below
is some code to make this a little clearer.
C#
//Here you would set the record numbers
to something meaningful in your your system
int[] RecordNumbers = new
int[2];
RecordNumbers[0] = 2;
RecordNumbers[1] = 5;
RecordNumbers[2] = 17;
//Setup new extent that will show all
three of the selected records
RectangleR NewExtent =
Map1.Layers[0].GetRecordsExtents(RecordNumbers);
//Scale the extent up just a little
(10%) to make it more viewable
NewExtent.ScaleUp(10);
//Set the map's current extent to the
extent we just created
Map1.CurrentExtent
= NewExtent;
VB.NET
'Here you would set the record numbers
to something meaningful in your your system
Dim RecordNumbers As Integer() = New Integer(1) {}
RecordNumbers(0) = 2
RecordNumbers(1) = 5
RecordNumbers(2) = 17
'Setup new extent that will show all
three of the selected records
Dim NewExtent As
RectangleR = Map1.Layers(0).GetRecordsExtents(RecordNumbers)
'Scale the extent up just a little (10%)
to make it more viewable
NewExtent.ScaleUp(10)
'Set the map's current extent to the
extent we just created
Map1.CurrentExtent
= NewExtent
Back to Top
I see a layer can have different zoomlevels. What would I
use this feature for?
Imagine you have an application which maps a traveler's journey between two
points. You would, likely, start by showing the entire US as the full extent.
At this level, you would show the states and maybe the interstate and US
highways. As the user zooms in to a single state, you might show state
highways. As they zoom in more you might show county roads. As they zoom in so
they are looking at a city, you could show all the city streets.
In such an application you would need to setup different zoomlevels to
control what is shown to the user and when (otherwise, the map would be too
cluttered). In this example, you would setup a zoomlevel to show states,
interstate and US highways. This zoomlevel would be setup to show when the user
was at any zoom level (say between 30,000 miles across and 0 miles across).
Then another zoomlevel would be created to show state highways when the user is
zoomed into the state level (say between 750 miles across and 0 miles across).
You keep setting up more and more zoomlevels like this. Your final zoomlevel would
be to show the city streets when the user is zoomed to between 10 miles across
and 0 miles across). You may notice that all of the zoomlevels here are set to
keep showing as the user zooms in (the second parameter is 0 miles across). You
could also set one or more zoomlevels to stop showing once zoomed in too close
to something.
The Misc sample named "ZoomLevels" can show you in more detail how
to use zoomlevels.
Back to Top
How can I get information about point or feature from a dbf
file?
Using Layer.DataQuery you can get all the information available in the dbf
file. This routine takes in either a SQL string or record number(s). If you
have the record number of the point you want information about (23 in this
example), you would use the following code to get the data about that point
from the dbf file into a DataTable object:
C#
DataTable
dt = Map1.Layers[0].DataQuery(23, false);
VB.NET
Dim
dt as DataTable =
Map1.Layers.Item(0).DataQuery(23, False)
The Querying sample "Combination Query" will show you more detail
on this topic.
Back to Top
Once I have a record number, how can I get the shape for
that record?
Using Layer.GetShape you can get the shape object for a record (in “Shapes
From Layer” sample). The following code would accomplish this:
C#
MapSuite.Geometry.BaseShape shape = Map1.Layers[0].GetShape(23);
VB.NET
Dim
shape as MapSuite.Geometry.BaseShape =
Map1.Layers.Item(0).GetShape(23)
You could also use Layer.DataQuery with the following code (this will return
all the dbf file information as well as the shape):
C#
DataTable
dt = Map1.Layers[0].DataQuery(23, true);
VB.NET
Dim
dt as DataTable =
Map1.Layers.Item(0).DataQuery(23, True)
Back to Top
How can I zoom in or out programmatically?
Zooming in or out is quite easy – you can do it with a single line of code:
C#
Map1.ZoomIn(40); // This
will zoom in 40%
Map1.ZoomOut(40);
// This will zoom out 40%
VB.NET
map1.ZoomIn(40) '-- This
will zoom in 40%
map1.ZoomOut(40) '-- This
will zoom out 40%
You can see this code in every sample under the routine ToolBar1_ButtonClick which
is used by the menu and the toolbar.
Back to Top
How can I set the full extent of a map to something
specific?
The Map1.FullExtent is a read-only property so you cannot change it but you
can easily accomplish your task by creating your own extent and when the user
clicks on your "Full Extent" menu item/toolbar button you just assign
your custom extent to the map's current extent. The following code shows you
how.
C#
// First
you need a module level variable to hold the custom full extent
RectangleR rect;
// Then (in some routine) set the map so that
it is showing the extent that
// will be your custom full extent, saving that
in the variable
rect =
Map1.CurrentExtent;
// Then, when you want to go to your custom
full extent, just assign the variable to the map's current extent
Map1.CurrentExtent
= rect;
VB.NET
' First you need a module level variable
to hold the custom full extent
Dim rect As RectangleR
' Then (in some routine) set the map so
that it is showing the extent that
' will be your custom full extent,
saving that in the variable
rect = Map1.CurrentExtent
' Then, when you want to go to your
custom full extent, just assign the variable to the map's current extent
Map1.CurrentExtent
= rect
Back to Top
How can I display my data so each item falls within some
group? For example, if I have several cities with different populations, how could
I group these cities into the categories of small, medium, and large, each with
its own symbol on the map?
To accomplish this you would use class breaks. You can see the Rendering
sample named "Label Value Renderer" (or another one is Class Break
Renderer) for more detail. Basically, you need to create a series of class
breaks and one class break cap to group the data. For example, let's use the
example of cities, like in Label Value Renderer. In that sample, each listed
city falls into one of five categories: Less than 500,000; 500,000 - 999,999;
1,000,000 - 1,999,999; 2,000,000 - 4,999,999; and 5,000,000 and over. When we
setup the class breaks, you'll see how it works. The code below accomplishes
the task.
C#
// First we need to setup the zoomLevel and collection
ZoomLevel customZoomLevel = new ZoomLevel(10000,
2500);
SymbolClassBreakCollection classbreaks = new SymbolClassBreakCollection();
// Create first break, which is 'Under
500,000' and add it to the collection
SymbolClassBreakRenderer.ClassBreak
breaks;
breaks = new SymbolClassBreakRenderer.ClassBreak(500000,
mSymbol1);
classbreaks.Add(breaks);
// Create second break, which is 'Under
1,000,000' and add it to the collection
breaks = new SymbolClassBreakRenderer.ClassBreak(1000000,
mSymbol2);
classbreaks.Add(breaks);
// Create third break, which is 'Under
2,000,000' and add it to the collection
breaks = new SymbolClassBreakRenderer.ClassBreak(2000000,
mSymbol3);
classbreaks.Add(breaks);
// Create cap, which will handle the
final two categories. Every class break collection must end with a cap
// In this case, the cap says,
everything over 5,000,000 should get Symbol5 and under 5,000,000 will get
Symbol4
SymbolClassBreakRenderer.ClassBreakCap
cap;
cap = new SymbolClassBreakRenderer.ClassBreakCap(5000000,
mSymbol5, mSymbol4);
classbreaks.Add(cap);
// Now, we just add the class break
collection to a renderer and add the renderer to the zoomLevel
SymbolClassBreakRenderer rend = new SymbolClassBreakRenderer("population", classbreaks);
customZoomLevel.GeoStyle.SymbolRenderers.Add(rend);
// At this point, we have setup our class
breaks.
VB.NET
' First we need to setup the zoomLevel
and collection
Dim customZoomLevel As New ZoomLevel(10000, 2500)
Dim classbreaks As New SymbolClassBreakCollection()
' Create first break, which is 'Under
500,000' and add it to the collection
Dim breaks As
SymbolClassBreakRenderer.ClassBreak
breaks = New
SymbolClassBreakRenderer.ClassBreak(500000, mSymbol1)
classbreaks.Add(breaks)
' Create second break, which is 'Under
1,000,000' and add it to the collection
breaks = New
SymbolClassBreakRenderer.ClassBreak(1000000, mSymbol2)
classbreaks.Add(breaks)
' Create third break, which is 'Under
2,000,000' and add it to the collection
breaks = New
SymbolClassBreakRenderer.ClassBreak(2000000, mSymbol3)
classbreaks.Add(breaks)
' Create cap, which will handle the
final two categories. Every class break collection must end with a cap
' In this case, the cap says, everything
over 5,000,000 should get Symbol5 and under 5,000,000 will get Symbol4
Dim cap As
SymbolClassBreakRenderer.ClassBreakCap
cap = New
SymbolClassBreakRenderer.ClassBreakCap(5000000, mSymbol5, mSymbol4)
classbreaks.Add(cap)
' Now, we just add the class break
collection to a renderer and add the renderer to the zoomLevel
Dim rend As New SymbolClassBreakRenderer("population",
classbreaks)
customZoomLevel.GeoStyle.SymbolRenderers.Add(rend)
' At this point, we have setup our class breaks.
When you are this far, you have the class breaks setup. It is important that
you remember that the sequence is quite important. The sequence in which the
class breaks are added to the collection will determine into which class each
value falls. The logic will work something like the following.
- For each value to be put into a class break (for each city
in this example)
- Compare to each class break
- Does the current value fall below the current class break
level?
- If yes, then the current value is assigned to the current
class break, go to the next value (city).
- If no, then go to the next class break.
- If we get to the class break cap and the current value is
higher than the cap (5,000,000 in this example) then assign to the highest
class break, regardless of how high the value is.
So, if you add the class breaks in a different order, expect different
results.
Back to Top
How can I display my data so each item is represented with
a special symbol based on an exact textual match (not categories, classes or
ranges)? For example, a lake should be blue; a dry lake should be brown, etc.
To accomplish this you would use symbol value renderers. You can see the
Rendering sample named "Value Renderer" for more detail. You need to
create a collection to hold the values to match and then setup a symbol for
each value ('Lake', 'Dry Lake', etc.). See the following code.
C#
// First we need to setup the zoomLevel and collection
ZoomLevel customZoomLevel = new ZoomLevel(10000,
0);
SymbolValueCollection values = new SymbolValueCollection();
SymbolValueRenderer.Value
val;
AreaSymbol sym;
// Add renderer value for any record
named "Lake". This will be a simple light sky blue color for a lake
sym = new AreaSymbol(new GeoPen(GeoColor.FromArgb(0,
0, 0, 0)), new GeoSolidBrush(GeoColor.KnownColors.LightSkyBlue));
val = new SymbolValueRenderer.Value("Lake", sym);
values.Add(val);
// Add renderer value for any record
named "Dry Lake". This will be an actual graphic that looks like a
dry lake
Bitmap bmp = new Bitmap(@"..\..\SampleData\Textures\rust
pebbles.bmp");
sym = new AreaSymbol(new GeoPen(GeoColor.FromArgb(0,
0, 0, 0)), new GeoTextureBrush(bmp));
val = new SymbolValueRenderer.Value("Lake Dry", sym);
values.Add(val);
// Now, we must create the renderer
(collection of values) and add it to the zoomLevel
SymbolValueRenderer rend = new SymbolValueRenderer("Feature", values);
customZoomLevel.GeoStyle.SymbolRenderers.Add(rend);
// At this point, lakes and dry lakes are
configured to show using the symbols we specified
// all you need to do now is add the zoomLevel
to the layer and add the layer to the map
VB.NET
' First we need to setup the zoomLevel
and collection
Dim customZoomLevel As New ZoomLevel(10000, 0)
Dim values As New SymbolValueCollection()
Dim val As
SymbolValueRenderer.Value
Dim sym As AreaSymbol
' Add renderer value for any record
named "Lake". This will be a simple light sky blue color for a lake
sym = New
AreaSymbol(New GeoPen(GeoColor.FromArgb(0, 0,
0, 0)), New
GeoSolidBrush(GeoColor.KnownColors.LightSkyBlue))
val = New
SymbolValueRenderer.Value("Lake",
sym)
values.Add(val)
' Add renderer value for any record
named "Dry Lake". This will be an actual graphic that looks like a
dry lake
Dim bmp As New Bitmap("..\..\SampleData\Textures\rust
pebbles.bmp")
sym = New
AreaSymbol(New GeoPen(GeoColor.FromArgb(0, 0,
0, 0)), New GeoTextureBrush(bmp))
val = New
SymbolValueRenderer.Value("Lake Dry", sym)
values.Add(val)
' Now, we must create the renderer
(collection of values) and add it to the zoomLevel
Dim rend As New SymbolValueRenderer("Feature",
values)
customZoomLevel.GeoStyle.SymbolRenderers.Add(rend)
' At this point, lakes and dry lakes are
configured to show using the symbols we specified
' all you need to do now is add the zoomLevel to the layer and add
the layer to the map
Back to Top
How can I use my own rendering logic when the symbol
representing a place's location is being drawn?
Setting up your own rendering logic for this is quite easy. You can see the
Rendering sample named "Custom Symbols" for a more detailed example
on how to accomplish this but simply put, all you need to do is create a module
level variable of type PointSymbol and then wire-up a custom draw event to
handle that object's drawing. The following code should make it clearer:
C#
// Module-level variable to represent the point symbol for
each location
internal PointSymbol
mCustomPointSymbol;
// Then, create the custom draw routine
private void
mCustomPointSymbol_CustomDraw(System.Drawing.Graphics
g, System.Drawing.PointF PointF, MapSuite.PointSymbol symbol)
{
// Logic for custom drawing of symbol used
for each city – this will draw a star-burst with a yellow center
GraphicsPath path = new GraphicsPath();
Rectangle R = new Rectangle(Convert.ToInt32(PointF.X - 10), Convert.ToInt32(PointF.Y - 10), 20, 20);
path.AddEllipse(R);
PathGradientBrush brush = new PathGradientBrush(path.PathPoints);
Color[] c = { Color.FromArgb(0, 0, 0, 0) };
brush.CenterColor = Color.Yellow;
brush.SurroundColors = c;
brush.FocusScales = new
PointF(Convert.ToSingle(0.01),
Convert.ToSingle(0.01));
g.FillEllipse(brush, R);
brush.Dispose();
}
// Then, in the form's load event, instantiate
the variable and wire-up the custom draw routine
private void
CustomSymbolsApp_Load(object sender, System.EventArgs e)
{
mCustomPointSymbol
= new PointSymbol(PointStyleEnum.Custom);
mCustomPointSymbol.CustomDraw += new PointSymbol.CustomDrawEventHandler(this.mCustomPointSymbol_CustomDraw);
}
VB.NET
'-- Module-level variable to represent the point symbol for
each location
Friend mCustomPointSymbol As PointSymbol
' Module-level variable to represent the
point symbol for each location
' Then, create the custom draw routine
Private Sub
mCustomPointSymbol_CustomDraw(ByVal g As System.Drawing.Graphics, ByVal
PointF As System.Drawing.PointF, ByVal symbol As
MapSuite.PointSymbol)
' Logic for custom
drawing of symbol used for each city – this will draw a star-burst with a
yellow center
Dim path As New GraphicsPath()
Dim R As New
Rectangle(Convert.ToInt32(PointF.X - 10), Convert.ToInt32(PointF.Y - 10), 20,
20)
path.AddEllipse(R)
Dim brush As New
PathGradientBrush(path.PathPoints)
Dim c As Color() = {Color.FromArgb(0, 0, 0, 0)}
brush.CenterColor = Color.Yellow
brush.SurroundColors = c
brush.FocusScales = New
PointF(Convert.ToSingle(0.01), Convert.ToSingle(0.01))
g.FillEllipse(brush, R)
brush.Dispose()
End Sub
' Then, in the form's
load event, instantiate the variable and wire-up the custom draw routine
Private Sub CustomSymbolsApp_Load(ByVal sender As Object, ByVal e As System.EventArgs)
mCustomPointSymbol = New
PointSymbol(PointStyleEnum.[Custom])
AddHandler
mCustomPointSymbol.CustomDraw, AddressOf Me.mCustomPointSymbol_CustomDraw
End
Sub
Back to Top
How can I have items labeled differently based on a value
in a field in the shape file? For example, if I have several cities in each
country in Europe, I want to show capitals in a larger font than non-capitals.
To accomplish this you would use the label value renderer. You can see the
Rendering sample named "Label Value Renderers" for more detail. You
need to create a label value collection and add to that collection one label
value for each value to be match. In this example, we will have two label
values; one for "Y" and one for "N" in the field named
"Capital." The code below does just that.
C#
// First we need to setup the zoomLevel and collection
ZoomLevel t2 = new ZoomLevel(2500,
0);
LabelValueCollection col = new LabelValueCollection();
LabelValueRenderer.LabelValue
val;
TextSymbol sym;
// Setup for capitals
sym = new TextSymbol(new GeoFont("Arial",
12, GeoFontStyle.Bold), new GeoSolidBrush(GeoColor.KnownColors.Black), 0, -8);
val = new LabelValueRenderer.LabelValue("Y", sym);
col.Add(val);
// Setup for non-capitals
sym = new TextSymbol(new GeoFont("Arial",
8, GeoFontStyle.Bold), new GeoSolidBrush(GeoColor.KnownColors.Black), 0, -6);
val = new LabelValueRenderer.LabelValue("N", sym);
col.Add(val);
// Create renderer, testing field
"Capital" but displaying field "Name"
LabelValueRenderer rend = new LabelValueRenderer("Capital", "Name",
col);
// Add renderer to the zoomLevel
t2.GeoTextStyle.LabelRenderers.Add(rend);
VB.NET
Dim t2 As New ZoomLevel(2500, 0)
Dim col As New LabelValueCollection()
Dim val As
LabelValueRenderer.LabelValue
Dim sym As TextSymbol
' Setup for capitals
sym = New
TextSymbol(New GeoFont("Arial",
12, GeoFontStyle.Bold), New GeoSolidBrush(GeoColor.KnownColors.Black),
0, -8)
val = New
LabelValueRenderer.LabelValue("Y",
sym)
col.Add(val)
' Setup for non-capitals
sym = New
TextSymbol(New GeoFont("Arial",
8, GeoFontStyle.Bold), New
GeoSolidBrush(GeoColor.KnownColors.Black), 0, -6)
val = New
LabelValueRenderer.LabelValue("N",
sym)
col.Add(val)
' Create renderer, testing field
"Capital" but displaying field "Name"
Dim rend As New LabelValueRenderer("Capital",
"Name", col)
' Add renderer to the zoomLevel
t2.GeoTextStyle.LabelRenderers.Add(rend)
Back to Top
I see that a map can have multiple layers. Why would I use
multiple layers?
Since a layer is the object that holds the data (that is a layer has one and
only one shape file as its data source) if you want to have multiple data
sources then you need multiple layers. The Misc sample named "ZoomLevels"
can show you more details about this. In this sample, you will see five layers
created. One layer has the streets of Austin, one layer has the countries, one
layer has the details about the US states, etc. The zoomlevels in this sample
just, in effect, tell each layer to render only at certain zoom factors. The
point is that each layer actually has the data from the shape file. So,
multiple shape files mean multiple layers.
Back to Top
How can I print a map?
If you just want to print the map, it is quite easy. The Rendering sample
named "Printing " shows how it is done, but the code is the
following:
C#
PrintPreviewDialog print = new PrintPreviewDialog();
Map1.PrintDocument.DefaultPageSettings.Landscape = true;
print.Document = Map1.PrintDocument;
print.ShowDialog();
VB.NET
Dim print As New PrintPreviewDialog()
Map1.PrintDocument.DefaultPageSettings.Landscape = True
print.Document = Map1.PrintDocument
print.ShowDialog()
At this point, the user will see the print preview dialog and can print just
by pressing the print button.
Back to Top
How can I print a map if I want to include my own logic?
For example, if I want to include a legend or some additional text?
The Misc sample named "Printing" shows how it is done but the
basics are this. You create a module level variable to hold the print document.
You also wire up the PrintPage event so that when the map prints, you will get
an event and you can add all the logic you want. The following code should make
it clearer:
C#
//
Module-level variable
private PrintDocument
mPrintDocument = new PrintDocument();
// Logic when you want to show the print
preview window
PrintPreviewDialog print = new PrintPreviewDialog();
mPrintDocument.DefaultPageSettings.Landscape
= true;
print.Document
= mPrintDocument;
print.ShowDialog();
// You'll also need to add this to the form's
load event to wire up the custom print event
mPrintDocument.PrintPage
+= new PrintPageEventHandler(mPrintDocument_PrintPage);
// Finally, you will need to add the routine
for the event
private void
mPrintDocument_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs
e)
{
// Put your own custom drawing logic here
// Here we will use a simplified version of
the code in the printing sample
// First, draw the map with a border
Bitmap b = map1.GetBitmap(820, 580, false);
e.Graphics.DrawImage(b, 200, 120);
e.Graphics.DrawRectangle(new Pen(Color.Black, 2), new Rectangle(200, 120, Misc.GetBitmapScreenWidth(b),
Misc.GetBitmapScreenHeight(b)));
// Next draw a title
on the page
e.Graphics.DrawString("This
is the title for the page", new Font("Arial",
15, FontStyle.Bold), new SolidBrush(Color.Black), 310, 54);
// Add as much logic as you would like
}
VB.NET
'-- Module-level variable
Private mPrintDocument As New
PrintDocument()
'-- Logic when you want to show the print
preview window
Dim print As New
PrintPreviewDialog()
mPrintDocument.DefaultPageSettings.Landscape = True
print.Document = mPrintDocument
print.ShowDialog()
'-- You'll also need to add this to the form's load event
to wire up the custom print event
AddHandler mPrintDocument.PrintPage, AddressOf mPrintDocument_PrintPage
'-- Finally, you will need to add the routine
for the event
Private Sub
mPrintDocument_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
mPrintDocument.PrintPage
' Put your own custom
drawing logic here
' Here we will use a
simplified version of the code in the printing sample
' First, draw the map
with a border
Dim b As Bitmap = map1.GetBitmap(820, 580, False)
e.Graphics.DrawImage(b, 200, 120)
e.Graphics.DrawRectangle(New Pen(Color.Black, 2), New
Rectangle(200, 120, Misc.GetBitmapScreenWidth(b), Misc.GetBitmapScreenHeight(b)))
' Next draw a title on
the page
e.Graphics.DrawString("This
is the title for the page", New
Font("Arial", 15, FontStyle.Bold),
New SolidBrush(Color.Black), 310, 54)
' Add as much logic as
you would like
End
Sub
At this point, the user will see the print preview dialog and can print just
by pressing the print button. All of your custom logic will be shown in the
print preview dialog.
Back to Top
I want a user to be able to draw various shapes (circles,
rectangles, etc.) and I want to execute some custom logic while the shape is
being created. How can I do this?
The Misc sample named "Track Shapes" will be very helpful to you
in understanding how to accomplish this. In this sample there are no layers, no
shape files, just track shapes being drawn (they can also be moved). As you can
see from the code in this sample, there are plenty of events which you can tie
into. You can execute your logic when the shape is just starting to be dragged,
when the dragging is complete, or while the dragging is happening. As well, you
can run your logic while the track shape is being drawn or when the drawing is
complete. All of these events are used in the sample.
While the track shape is being drawn, you will see that there is logic to
show the total area / perimeter / radius of the shape. When the track shape is
finished being drawn, you will see logic to make the shape permanent (actually
add it to the map as a map shape).
Explore this sample and it should be pretty clear how to accomplish these
things. Below is a bit of the logic from the sample which is in the
Map1_TrackShapesDraw event.
C#
private void
map1_TrackShapesDraw(int X, int Y, System.Drawing.Graphics
G)
{
// This code shows how to add the total area
and perimeter to a track rectangle as it is being drawn
double Area, Perimeter;
string AreaUnit
= "squarekm";
string
LengthUnit = "kilometres";
Area = Map1.TrackRectangle.get_Area(MapAreaUnits.squarekm);
Perimeter = Map1.TrackRectangle.get_Perimeter(MapLengthUnits.kilometres);
G.DrawString("Area:
" + Math.Round(Area, 2) +
AreaUnit, new Font("Arial", 9, FontStyle.Bold),
new SolidBrush(Color.Black), X, Y - 30);
G.DrawString("Perimeter: " + Math.Round(Perimeter, 2) + LengthUnit, new Font("Arial", 9, FontStyle.Bold),
new SolidBrush(Color.Black), X, Y - 16);
}
VB.NET
Private Sub
map1_TrackShapesDraw(ByVal X As Integer, ByVal Y As Integer, ByVal G As System.Drawing.Graphics)
' This code shows how
to add the total area and perimeter to a track rectangle as it is being drawn
Dim Area As Double, Perimeter As Double
Dim AreaUnit As String = "squarekm"
Dim LengthUnit As String = "kilometres"
Area =
Map1.TrackRectangle.get_Area(MapAreaUnits.squarekm)
Perimeter = Map1.TrackRectangle.get_Perimeter(MapLengthUnits.kilometres)
G.DrawString("Area:
" + Math.Round(Area, 2) + AreaUnit, New
Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), X, Y - 30)
G.DrawString("Perimeter:
" + Math.Round(Perimeter, 2) + LengthUnit, New
Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), X, Y - 16)
End
Sub
Back to Top
What are map shapes and how can I use them?
The Misc sample named "Track Shapes" will show you how to create
map shapes based on a track shape (a shape a user draws). A map shape is a
shape that is added via code and not from a shape file. That is, mostly shapes
will be added from shape files (roads, buildings, etc.) but you might want to
have your own shapes. Your own shapes might include proposed buildings or even
vehicles driving down the street.
Map shapes can be easily moved and reside outside the context of layers. Map
shapes are on the map, not on a layer. Let's say you want to allow a user to
plot the points, on a map of the world, where they have visited. For this, you
would load a layer with data of the world. Then you would set the map into
track point mode. Then, let the user click creating the various points. Each
time the user clicks, the Map1_FinishedTrackShape event will fire – here you
will add the map shape and record any data in a data store (for example,
storing the latitude and longitude in a database).
The following code should make it clear:
C#
// Put this code in the form's load
event. This will show a map of the world.
Map1.MapUnit = MapLengthUnits.DecimalDegrees;
Layer worldLayer = new
Layer(@"..\..\SampleData\world\cntry02.shp",
true);
worldLayer.ZoomLevel01.GeoStyle = GeoAreaStyles.GetSimpleAreaStyle(GeoColor.KnownColors.LightGray,GeoColor.KnownColors.Black);
worldLayer.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18;
Map1.Layers.Add(worldLayer);
// Then, set the map's mode to track
point so that every time the user clicks, a point shape will be created
Map1.Mode = ModeType.TrackPoint;
//Finally, in the FinishedTrackShape
event, add the code to add the point to the map as a map shape.
private void
Map1_FinishedTrackShape(BaseShape Shape)
{
BasePointShape
pnt = (BasePointShape)Shape;
Map1.MapShapes.Add(new
PointMapShape(pnt));
// Here you would also
add any logic to store the location of the point the user selected
}
VB.NET
' Put this code in the form's load
event. This will show a map of the world.
Map1.MapUnit = MapLengthUnits.DecimalDegrees
Dim worldLayer As New Layer("..\..\SampleData\world\cntry02.shp",
True)
worldLayer.ZoomLevel01.GeoStyle =
GeoAreaStyles.GetSimpleAreaStyle(GeoColor.KnownColors.LightGray,
GeoColor.KnownColors.Black)
worldLayer.ZoomLevel01.ApplyUntilZoomLevel =
ApplyUntilZoomLevel.ZoomLevel18
Map1.Layers.Add(worldLayer)
' Then, set the map's mode to track
point so that every time the user clicks, a point shape will be created
Map1.Mode = ModeType.TrackPoint
'Finally,
in the FinishedTrackShape event, add the code to add the point to the map as a
map shape.
Private Sub
Map1_FinishedTrackShape(ByVal Shape As BaseShape)
Dim pnt As BasePointShape = CType(Shape,
BasePointShape)
Map1.MapShapes.Add(New
PointMapShape(pnt))
' Here you would also
add any logic to store the location of the point
the user selected
End
Sub
As you can see, there is very little code to actually add a map shape to a
map (two lines). Most of the code will depend on how you want to store the data
about the points the user selected.
Back to Top
How can I define my own custom labeling plug-in?
The Rendering sample named "Custom Labeler" goes over this is
greater detail but what you will need to do is create a class that inherits
from MapSuite.ILabeler. There are several methods to implement, all named
DrawLabels (taking in different parameters). In the sample, you will see
DrawLabels implemented for Polygons and MultiLines. The code for polygons is
below:
C#
// Class declaration
public class
CustomLabeler : MapSuite.ILabeler
{
// DrawLabels routine
public void DrawLabels(Graphics
g, Array[] TextSymbolArrays, Array[] SymbolArray, MapSuite.Geometry.PolygonF[] Polygons, ref
SimplePolygonF[] LabeledAreas, int CanvasWidth, int
CanvasHeight)
{
// Drawing labels
for polygons
StringFormat
Format = new StringFormat();
Format.Alignment = StringAlignment.Center;
for (int i = 0; i <= Polygons.Length - 1; i++)
{
TextSymbol[]
TextSymbols = (TextSymbol[])TextSymbolArrays[i];
for (int j = 0; j <= Polygons[i].Parts.Length - 1; j++)
{
for
(int k = 0; k <= TextSymbols.Length - 1;
k++)
{
g.DrawString(TextSymbols[k].TextValue, TextSymbols[k].Font, TextSymbols[k].Brush,
Polygons[i].Parts[j].Centroid.X + TextSymbols[k].XOffset,
Polygons[i].Parts[j].Centroid.Y + TextSymbols[k].YOffset, Format);
}
}
}
}
public void DrawLabels(Graphics
g, Array[] TextSymbolArrays, Array[] SymbolArrays, PointF[]
Points, ref SimplePolygonF[]
LabeledAreas, Int32 CanvasWidth, Int32 CanvasHeight)
{
// This routine
left blank intentionally.
}
public void DrawLabels(Graphics
g, Array[] TextSymbolArrays, Array[] SymbolArrays, MultiPointF[]
MultiPoints, ref SimplePolygonF[]
LabeledAreas, Int32 CanvasWidth, Int32 CanvasHeight)
{
// This routine
left blank intentionally.
}
public void DrawLabels(Graphics
g, Array[] TextSymbolArrays, Array[] SymbolArrays, MultiLineF[]
MultiLines, ref SimplePolygonF[]
LabeledAreas, Int32 CanvasWidth, Int32 CanvasHeight)
{
// This routine
left blank intentionally.
}
}
VB.NET
' Class declaration
Public Class CustomLabeler
Implements
MapSuite.ILabeler
' DrawLabels routine
Public Sub DrawLabels(ByVal
g As Graphics, ByVal
TextSymbolArrays As Array(), ByVal SymbolArray As
Array(), ByVal Polygons As MapSuite.Geometry.PolygonF(), ByRef
LabeledAreas As SimplePolygonF(), ByVal CanvasWidth As Integer, ByVal CanvasHeight
As Integer) Implements ILabeler.DrawLabels
' Drawing labels for
polygons
Dim Format As New StringFormat()
Format.Alignment = StringAlignment.Center
For i As Integer = 0 To Polygons.Length - 1
Dim
TextSymbols As TextSymbol() = DirectCast(TextSymbolArrays(i), TextSymbol())
For j As Integer = 0 To Polygons(i).Parts.Length - 1
For k As Integer = 0 To TextSymbols.Length - 1
g.DrawString(TextSymbols(k).TextValue, TextSymbols(k).Font, TextSymbols(k).Brush,
Polygons(i).Parts(j).Centroid.X + TextSymbols(k).XOffset,
Polygons(i).Parts(j).Centroid.Y + TextSymbols(k).YOffset, Format)
Next
Next
Next
End Sub
Public Sub DrawLabels(ByVal
g As Graphics, ByVal
TextSymbolArrays As Array(), ByVal SymbolArrays As
Array(), ByVal Points As
PointF(), ByRef LabeledAreas As SimplePolygonF(), ByVal
CanvasWidth As Int32, ByVal
CanvasHeight As Int32) Implements
ILabeler.DrawLabels
' This routine
left blank intentionally.
End Sub
Public Sub DrawLabels(ByVal
g As Graphics, ByVal
TextSymbolArrays As Array(), ByVal SymbolArrays As
Array(), ByVal MultiPoints As MultiPointF(), ByRef
LabeledAreas As SimplePolygonF(), ByVal CanvasWidth As
Int32, ByVal CanvasHeight As Int32) Implements
ILabeler.DrawLabels
' This routine
left blank intentionally.
End Sub
Public Sub DrawLabels(ByVal
g As Graphics, ByVal
TextSymbolArrays As Array(), ByVal SymbolArrays As
Array(), ByVal MultiLines As MultiLineF(), ByRef
LabeledAreas As SimplePolygonF(), ByVal CanvasWidth As
Int32, ByVal CanvasHeight As Int32) Implements
ILabeler.DrawLabels
' This routine left
blank intentionally.
End Sub
End
Class
Now, to use your custom labeler, you just need to create it and plug it in.
Like the following:
C#
CustomLabeler cl = new CustomLabeler();
customZoomLevel.LabelerPlugin
= cl; // this assumes
you have a zoomlevel object declared as customZoomLevel
VB.NET
Dim
cl As New
CustomLabeler()
customZoomLevel.LabelerPlugin
= cl '-- this assumes
you have a zoomlevel object declared as customZoomLevel
Back to Top
Can I change the data in a shape file, and if so, how?
Yes, you can. To delete shapes in the file, use the Layer.DeleteShape method
which takes in a record number. If you want to change the data in a shape file,
first you must call Layer.BeginEdit and then follow that with either
Layer.CommitEdit or Layer.RollbackEdit. Between calling BeingEdit and
CommitEdit or RollbackEdit you can call Layer.DeleteShape, Layer.AddShape, or
Layer.UpdateShape depending on whether you want to do a delete, insert, or an
update. The Layer sample named "Edit Shape File" is the sample that
best illustrates this but below you will see some code that will help you.
C#
// Insert a new shape
private void
Map1_FinishedTrackShape(MapSuite.Geometry.BaseShape
Shape)
{
Map1.Layers[0].BeginEdit();
Map1.Layers[0].AddShape(Shape);
Map1.Layers[0].CommitEdit();
}
// Update an existing shape
private void
Map1_FinishedTrackShape(MapSuite.Geometry.BaseShape
Shape)
{
Map1.Layers[0].BeginEdit();
Map1.Layers[0].UpdateShape(Convert.ToInt32(lblRecordNumber.Text), Shape);
Map1.Layers[0].CommitEdit();
}
// Delete an existing shape
Map1.Layers[0].BeginEdit();
Map1.Layers[0].DeleteShape(Convert.ToInt32(lblRecordNumber.Text));
Map1.Layers[0].CommitEdit();
VB.NET
' Insert a new shape
Private Sub
Map1_FinishedTrackShape(ByVal Shape As MapSuite.Geometry.BaseShape)
Map1.Layers(0).BeginEdit()
Map1.Layers(0).AddShape(Shape)
Map1.Layers(0).CommitEdit()
End Sub
' Update an existing
shape
Private Sub
Map1_FinishedTrackShape(ByVal Shape As MapSuite.Geometry.BaseShape)
Map1.Layers(0).BeginEdit()
Map1.Layers(0).UpdateShape(Convert.ToInt32(lblRecordNumber.Text), Shape)
Map1.Layers(0).CommitEdit()
End Sub
'-- Delete an existing shape
Map1.Layers(0).BeginEdit()
Map1.Layers(0).DeleteShape(Convert.ToInt32(lblRecordNumber.Text))
Map1.Layers(0).CommitEdit()
Back to Top
How can I stop one or more map shapes from being printed
while printing the map?
The easiest way would be to set each map shape's Active property to false.
If Active is true then the map shape will print, otherwise it will not. You can
use this to stop just a few map shapes from printing or you could loop through
the collection and stop them all from printing. The following code should help
make it clear for you.
C#
// User clicks on something to trigger
the printing of the map
PrintPreviewDialog print = new PrintPreviewDialog();
Map1.MapShapes[0].Active = false;
print.Document = Map1.PrintDocument;
print.ShowDialog();
VB.NET
'User clicks on something to trigger the
printing of the map
Dim print As New PrintPreviewDialog()
map1.MapShapes.Item(0).Active = False
print.Document = map1.PrintDocument
print.ShowDialog()
Now, the first map shape will not show in the print preview dialog. You
could also put that one line inside of a loop and affect all the map shapes.
Back to Top
What do I need to do to distribute my application which
uses Map Suite? How do I get all the dependencies on the destination computer?
In the full version of Map Suite, we include a merge module that can be
included in your setup program. The merge module will install everything needed
for Map Suite to run on that machine.
Back to Top
What vector and raster formats are supported by Map Suite?
For vector data, Map Suite supports ShapeFile format.
For raster imagery, Map Suite supports TIFF, GeoTIFF, MrSID, ECW, JPEG2000, BMP
and JPEG.
Back to Top
How do I zoom in to a Point?
Zooming into a point is a common question we receive from our customers.
Since point-based objects don't consume much area, it can be a bit difficult to
create an extent to zoom in to. The answer to this problem is the buffer
method. The buffer method allows you to buffer a point by a certain distance to
give it area. For example, in the code below we have taken a point and buffered
it by 5 miles on each side. Once we have this new buffered point, all we need
to do is get the RectangleR from the envelope and set this to the map extent.
This will then zoom the map into an area 10 miles around your point. Below is
some sample code to help get you started:
C#
// The following code will zoom the map into an area 10
miles around the point.
PointShape pnt = new PointShape(LongValue,
LatValue);
Map1.CurrentExtent = pnt.Buffer(5, MapLengthUnits.DecimalDegrees, MapLengthUnits.miles).Envelope.ToRectangleR();
VB.NET
' The
following will zoom the map into an area 10 miles around the point.
Dim pnt As
PointShape = New PointShape(LongValue,
LatValue)
Map1.CurrentExtent = pnt.Buffer(5, MapLengthUnits.DecimalDegrees,
MapLengthUnits.miles).Envelope.ToRectangleR
Back to Top
How do I zoom in to a set of MapShape Points?
To zoom the map in to an extent that includes specific points see the
following routine:
C#
private RectangleR
CalculateMapExtent()
{
//Declare Variables
PointShape
pointShape;
double
upperLeftLat = 0;
double
upperLeftLong = 0;
double
lowerRightLat = 0;
double
lowerRightLong = 0;
//Loop through the
points collection to find the upper left and lower right point values
foreach (BaseMapShape baseMapShape in
Map1.MapShapes)
{
if
(baseMapShape is PointMapShape)
{
pointShape = (PointShape)baseMapShape.BaseShape;
if
(pointShape.Y > upperLeftLat | upperLeftLat == 0) upperLeftLat =
pointShape.Y;
if (pointShape.X
< upperLeftLong | upperLeftLong == 0) upperLeftLong = pointShape.X;
if
(pointShape.Y < lowerRightLat | lowerRightLat == 0) lowerRightLat =
pointShape.Y;
if
(pointShape.X > lowerRightLong | lowerRightLong == 0) lowerRightLong =
pointShape.X;
}
}
//Create
variables to set the extent
PointR
upperLeftPoint = new PointR(upperLeftLong,
upperLeftLat);
PointR
lowerRightPoint = new PointR(lowerRightLong,
lowerRightLat);
RectangleR
mapExtent = new RectangleR(upperLeftPoint,
lowerRightPoint);
//Scale Up Map extent
by 5%
mapExtent.ScaleUp(5);
if
(mapExtent.get_Width(MapLengthUnits.DecimalDegrees,
MapLengthUnits.miles) < 400)
{
while
(!(mapExtent.get_Width(MapLengthUnits.DecimalDegrees,
MapLengthUnits.miles) > 400))
{
mapExtent.ScaleUp(5);
}
}
return
mapExtent;
}
VB.NET
Private Function
CalculateMapExtent() As RectangleR
'Declare Variables
Dim baseMapShape As
BaseMapShape
Dim pointShape As PointShape
Dim upperLeftLat As Double
Dim upperLeftLong As Double |