Discussion:
us zip code border
(too old to reply)
elven_cris
2008-05-08 17:54:08 UTC
Permalink
We are searching a map solution which allows to draw the US map whith the 5
digit zip code border (to create a custom application for a US financial
company). The problem is I cannot find a way to do it in MapPoint.
I tried to get the PostCode1 entities from MapPoint.NA and to draw them as
Polygons, but it gives me the Exception "The specified DataSource object
either does not exist, is not a Polygon datasource, or you are not authorized
to use it. Argument: specification.Polygon[0].DataSourceName".
Do you know a way to draw the zip codes border, or why is this not working?
Here is the code:
FindSpecification findZipCodes = new FindSpecification();
findZipCodes.DataSourceName = "MapPoint.NA";
findZipCodes.InputPlace = "1";
findZipCodes.Options = new FindOptions();
findZipCodes.Options.ThresholdScore = 0;
findZipCodes.EntityTypeNames = new string[] { "Postcode1" };
findZipCodes.Options.Range = new FindRange();
findZipCodes.Options.Range.StartIndex = 0;
findZipCodes.Options.Range.Count = 50;

FindResults foundZips;
foundZips = _mapPointServices.Finder.Find(findZipCodes);
Polygon[] zipPoly = new Polygon[foundZips.Results.Length];
ElementColor color = new ElementColor();
for (int i = 0; i < foundZips.Results.Length; i++)
{
Polygon poly = new Polygon();
poly.DataSourceName =
foundZips.Results[i].FoundLocation.DataSourceName;
poly.EntityID = foundZips.Results[i].FoundLocation.Entity.ID;
poly.BorderColor = color;
poly.FillColor = color;
zipPoly[i] = poly;
}
FindSpecification findSpec = new FindSpecification();
findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "1, CA";

FindResults foundResults =
_mapPointServices.Finder.Find(findSpec);

// Set up a MapOptions object.
MapOptions mo = new MapOptions();
mo.Format = new ImageFormat();
mo.Format.MimeType = "image/jpeg";
mo.Format.Height = height;
mo.Format.Width = width;
mo.ReturnType = MapReturnType.ReturnImage;
mo.Style = MapStyle.Political;

ViewByScale[] viewByScale = new ViewByScale[1];
viewByScale[0] = new ViewByScale();
viewByScale[0].CenterPoint =
foundResults.Results[0].FoundLocation.LatLong;
viewByScale[0].MapScale = scale;

// Set up a MapSpecification object.
MapSpecification spec = new MapSpecification();
spec.DataSourceName = "MapPoint.NA";
spec.Views = viewByScale;
spec.Options = mo;
spec.Polygons = zipPoly;

MapImage[] mi = _mapPointServices.Render.GetMap(spec);

return new Bitmap(new
System.IO.MemoryStream(mi[0].MimeData.Bits));
elven_cris
2008-05-09 00:20:01 UTC
Permalink
Come on peoples, nobody has nothing to say??? =))
I am searching for over a week a control which can display the us zip codes
border, and I haven't reached a solution. Am I the only one to do such a
thing? It is too obvios and nobody bothers??? Please give me an idea,
something to work with. Please!!!
Post by elven_cris
We are searching a map solution which allows to draw the US map whith the 5
digit zip code border (to create a custom application for a US financial
company). The problem is I cannot find a way to do it in MapPoint.
I tried to get the PostCode1 entities from MapPoint.NA and to draw them as
Polygons, but it gives me the Exception "The specified DataSource object
either does not exist, is not a Polygon datasource, or you are not authorized
to use it. Argument: specification.Polygon[0].DataSourceName".
Do you know a way to draw the zip codes border, or why is this not working?
FindSpecification findZipCodes = new FindSpecification();
findZipCodes.DataSourceName = "MapPoint.NA";
findZipCodes.InputPlace = "1";
findZipCodes.Options = new FindOptions();
findZipCodes.Options.ThresholdScore = 0;
findZipCodes.EntityTypeNames = new string[] { "Postcode1" };
findZipCodes.Options.Range = new FindRange();
findZipCodes.Options.Range.StartIndex = 0;
findZipCodes.Options.Range.Count = 50;
FindResults foundZips;
foundZips = _mapPointServices.Finder.Find(findZipCodes);
Polygon[] zipPoly = new Polygon[foundZips.Results.Length];
ElementColor color = new ElementColor();
for (int i = 0; i < foundZips.Results.Length; i++)
{
Polygon poly = new Polygon();
poly.DataSourceName =
foundZips.Results[i].FoundLocation.DataSourceName;
poly.EntityID = foundZips.Results[i].FoundLocation.Entity.ID;
poly.BorderColor = color;
poly.FillColor = color;
zipPoly[i] = poly;
}
FindSpecification findSpec = new FindSpecification();
findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "1, CA";
FindResults foundResults =
_mapPointServices.Finder.Find(findSpec);
// Set up a MapOptions object.
MapOptions mo = new MapOptions();
mo.Format = new ImageFormat();
mo.Format.MimeType = "image/jpeg";
mo.Format.Height = height;
mo.Format.Width = width;
mo.ReturnType = MapReturnType.ReturnImage;
mo.Style = MapStyle.Political;
ViewByScale[] viewByScale = new ViewByScale[1];
viewByScale[0] = new ViewByScale();
viewByScale[0].CenterPoint =
foundResults.Results[0].FoundLocation.LatLong;
viewByScale[0].MapScale = scale;
// Set up a MapSpecification object.
MapSpecification spec = new MapSpecification();
spec.DataSourceName = "MapPoint.NA";
spec.Views = viewByScale;
spec.Options = mo;
spec.Polygons = zipPoly;
MapImage[] mi = _mapPointServices.Render.GetMap(spec);
return new Bitmap(new
System.IO.MemoryStream(mi[0].MimeData.Bits));
Derek Chan
2008-05-09 13:58:00 UTC
Permalink
Hi,

The boundary data you are looking for is not available through MWS. You'd
have to purchase some third party polygon data containing zip boundaries,
upload it as a polygon datasource, then display it through your app. You
might want to check out a Virtual Earth solution to this at:
http://mattberseth.com/blog/2007/05/plotting_zipcode_boundaries_us.html

Regards,
--
Infusion Development
http://www.infusion.com
Post by elven_cris
Come on peoples, nobody has nothing to say??? =))
I am searching for over a week a control which can display the us zip codes
border, and I haven't reached a solution. Am I the only one to do such a
thing? It is too obvios and nobody bothers??? Please give me an idea,
something to work with. Please!!!
Post by elven_cris
We are searching a map solution which allows to draw the US map whith the 5
digit zip code border (to create a custom application for a US financial
company). The problem is I cannot find a way to do it in MapPoint.
I tried to get the PostCode1 entities from MapPoint.NA and to draw them as
Polygons, but it gives me the Exception "The specified DataSource object
either does not exist, is not a Polygon datasource, or you are not authorized
to use it. Argument: specification.Polygon[0].DataSourceName".
Do you know a way to draw the zip codes border, or why is this not working?
FindSpecification findZipCodes = new FindSpecification();
findZipCodes.DataSourceName = "MapPoint.NA";
findZipCodes.InputPlace = "1";
findZipCodes.Options = new FindOptions();
findZipCodes.Options.ThresholdScore = 0;
findZipCodes.EntityTypeNames = new string[] { "Postcode1" };
findZipCodes.Options.Range = new FindRange();
findZipCodes.Options.Range.StartIndex = 0;
findZipCodes.Options.Range.Count = 50;
FindResults foundZips;
foundZips = _mapPointServices.Finder.Find(findZipCodes);
Polygon[] zipPoly = new Polygon[foundZips.Results.Length];
ElementColor color = new ElementColor();
for (int i = 0; i < foundZips.Results.Length; i++)
{
Polygon poly = new Polygon();
poly.DataSourceName =
foundZips.Results[i].FoundLocation.DataSourceName;
poly.EntityID = foundZips.Results[i].FoundLocation.Entity.ID;
poly.BorderColor = color;
poly.FillColor = color;
zipPoly[i] = poly;
}
FindSpecification findSpec = new FindSpecification();
findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "1, CA";
FindResults foundResults =
_mapPointServices.Finder.Find(findSpec);
// Set up a MapOptions object.
MapOptions mo = new MapOptions();
mo.Format = new ImageFormat();
mo.Format.MimeType = "image/jpeg";
mo.Format.Height = height;
mo.Format.Width = width;
mo.ReturnType = MapReturnType.ReturnImage;
mo.Style = MapStyle.Political;
ViewByScale[] viewByScale = new ViewByScale[1];
viewByScale[0] = new ViewByScale();
viewByScale[0].CenterPoint =
foundResults.Results[0].FoundLocation.LatLong;
viewByScale[0].MapScale = scale;
// Set up a MapSpecification object.
MapSpecification spec = new MapSpecification();
spec.DataSourceName = "MapPoint.NA";
spec.Views = viewByScale;
spec.Options = mo;
spec.Polygons = zipPoly;
MapImage[] mi = _mapPointServices.Render.GetMap(spec);
return new Bitmap(new
System.IO.MemoryStream(mi[0].MimeData.Bits));
Loading...