Alpha Release- Static Google Maps Kit
 
Static Google Maps Kit is an implementation for "Google Static Maps API" in C#
 
feature in beta release
  • Supporting "implicit positioning," determining the correct center and zoom level implicitly, based on evaluation of the position of elements.
  • providing util methods to calculate Zoom & Center

 

CtpGglMap.Impl.StaticGMap gmap = new CtpGglMap.Impl.StaticGMap();
gmap.Height = 666;
gmap.Width = 922;
gmap.Sensor = false;
gmap.AutoFit = true;

//markers
GMarker markj = new GMarker() { Point = new GeoPointImpl(40.714728, -73.998672), Label = "J" };
markj.SetMap(gmap);

GMarker markj2 = new GMarker() { Point = new GeoPointImpl(40.714728, -73.998672), Label = "M" };
markj2.SetMap(gmap);

GMarker marke = new GMarker() { Point = new GeoPointImpl(40.715748, -73.996672), Label = "E" };
marke.SetMap(gmap);

GMarker markf = new GMarker() { Point = new GeoPointImpl(40.714728, -73.994672), Label = "F" };
markf.SetMap(gmap);

GMarker markf2 = new GMarker() { Point = new GeoPointImpl(40.715748, -73.992672), Label = "F" };
markf2.SetMap(gmap);

 

feature in alpha release
  • Supporting map item as Gmarker, Polyline, Polygon,...
  • Supporting Calculating Pixel Coordinates for Markers

 

 

 //create gmap object & set its properties
CtpGglMap.Impl.StaticGMap gmap = new CtpGglMap.Impl.StaticGMap();
gmap.Center = new GeoPointImpl(40.714728, -73.998672);
gmap.Zoom = 14;
gmap.Height = 400;
gmap.Width = 400;
gmap.Sensor = false;

//markers
GMarker markj = new GMarker() { Point =new GeoPointImpl(40.714728, -73.998672), Label="J" };
markj.SetMap(gmap);

GMarker marke = new GMarker() { Point = new GeoPointImpl(40.715748, -73.996672), Label = "E" };
marke.SetMap(gmap);

GMarker markf = new GMarker() { Point = new GeoPointImpl(40.714728, -73.994672), Label = "F" };
markf.SetMap(gmap);

GMarker markf2 = new GMarker() { Point = new GeoPointImpl(40.715748, -73.992672), Label = "F" };
markf2.SetMap(gmap);

//Polyline & Polygon
GPath path = new GPath() { Color="0x0000ff", Weight="2", FillColor="0x0000ff"};
path.AddPoint(new GeoPointImpl(40.714728, -73.998672));
path.AddPoint(new GeoPointImpl(40.715748, -73.996672));
path.AddPoint(new GeoPointImpl(40.714728, -73.994672));
path.AddPoint(new GeoPointImpl(40.715748, -73.992672));
path.SetMap(gmap);

//getting Gmarker pixel coordinates
StringBuilder sb = new StringBuilder();
foreach (IMapItem item in gmap.GetItems())
{
if (item != null && item.GetType() == typeof(GMarker))
{
GMarker marker = item as GMarker;
//Pin Head Offset
int pinhead_offset = 12;
sb.Append(String.Format(" <area shape='circle'; coords='{0},{1},14' onclick='onAreaClick(\"{2}\")' />", marker.PixelXY.X,
marker.PixelXY.Y - pinhead_offset, marker.Label));
}
}

this.imap.InnerHtml = sb.ToString();

//save the fetched stream into an image object
using (Stream imageSteam = gmap.Fetch())
{
using (System.Drawing.Image _Image = System.Drawing.Image.FromStream(imageSteam))
{
if (_Image != null)
{
String filepath = MapPath("/tmp/gmap.jpg");
_Image.Save(filepath);
}
}
}
}

 

 

 

 

Result:

Last edited Feb 10, 2011 at 8:36 AM by jebberwocky, version 4

Comments

No comments yet.