Untitled-1.gif

Features

How to use

In this part of article, I don't want you to explain how I created this control. Instead I want you to start using it.

Requirements

Follow below steps in order to use it in your ASP.Net website.

Untitled-2.gif

Now we will add reference to Ajax library. If you are already using Ajax controls in your application, you can skip following 4 steps.

Adding Ajax Framework to your website

Note: Make sure that version of System.Web.Extension library is same as what you have selected when you added reference.

<httpHandlers>
  <remove path="*.asmx" verb="*"/>
  <add path="*.asmx" verb="*"
  type="System.Web.Script.Services.ScriptHandlerFactory,
   System.Web.Extensions,  Version=1.0.61025.0,
   Culture=neutral,
   PublicKeyToken=31BF3856AD364E35"
  validate="false"/>
  <add path="*_AppService.axd" verb="*"
  type="System.Web.Script.Services.ScriptHandlerFactory,
   System.Web.Extensions, Version=1.0.61025.0,
   Culture=neutral,
   PublicKeyToken=31BF3856AD364E35"
  validate="false"/>
  <add path="ScriptResource.axd" verb="GET,HEAD"
  type="System.Web.Handlers.ScriptResourceHandler,
   System.Web.Extensions, Version=1.0.61025.0,
   Culture=neutral,
   PublicKeyToken=31BF3856AD364E35"
  validate="false"/>
</httpHandlers>

<httpModules>
  <add name="ScriptModule"
  type="System.Web.Handlers.ScriptModule,
   System.Web.Extensions,
   Version=1.0.61025.0, Culture=neutral,
   PublicKeyToken=31BF3856AD364E35"/>
</httpModules>   

Adding Google Map control to your webpage

Let's add few pushpins on this map. For that you will have to add some code in Page_Load() event of your page.

Passing parameters to Google Map control

You can add as many pushpins as you wish. Now run website again and you should see pushpins on map.

Untitled-7.gif

Assigning custom icon to pushpins

Up to this point, I have explained you basics of using Google Map control. Now let's implement some advanced functionality.

Let's say we want to move pushpins when user do some action. For example when a user clicks on a button. For that, follow below steps.

Creating Interactive Map

You can create interactive map using Google Map control. You can move pushpins when user clicks on a button. Here is how you can do it.

Auto refreshing map and GPS Navigation

You can use Ajax Framewor's timer control in similar way as button control (I have explained above). On Timer_Tick() event you can specify new latitude longitude for all pushpins. This way Map will move all pushpins automatically after specified time delay. You can hook up any GPS service with this control to create GPS Navigation system.

Creating Polylines with Google Map control

Untitled-12.gif

Create points for polyline

GooglePoint GP1 = new GooglePoint();
GP1.ID = "GP1";
GP1.Latitude = 43.65669;
GP1.Longitude = -79.44268;
GP1.InfoHTML = "This is point 1";
GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1);

GooglePoint GP2 = new GooglePoint();
GP2.ID = "GP2";
GP2.Latitude = 43.66619;
GP2.Longitude = -79.44268;
GP2.InfoHTML = "This is point 2";
GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2);

GooglePoint GP3 = new GooglePoint();
GP3.ID = "GP3";
GP3.Latitude = 43.67689;
GP3.Longitude = -79.43270;
GP3.InfoHTML = "This is point 3";
GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3);
Create polyline between points GP1, GP2 and GP3

//Define polyline
GooglePolyline PL1 = new GooglePolyline();
PL1.ID = "PL1";
//Give Hex code for line color
PL1.ColorCode = "#0000FF";
//Specify width for line
PL1.Width = 5;

//Add points
PL1.Points.Add(GP1);
PL1.Points.Add(GP2);
PL1.Points.Add(GP3);

Add Polyline to Google Map control,

GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);

Creating Polygons with Google Map control

Untitled-13.gif

Create points for polyline,

//Define Points for polygon
GooglePoint GP1 = new GooglePoint();
GP1.ID = "GP1";
GP1.Latitude = 43.66675;
GP1.Longitude = -79.4042;

GooglePoint GP2 = new GooglePoint();
GP2.ID = "GP2";
GP2.Latitude = 43.67072;
GP2.Longitude = -79.38677;

//Define GP3,GP4,GP5,GP6 and GP7 in similar way
GooglePoint GP7 = new GooglePoint();
GP7.ID = "GP7";
GP7.Latitude = 43.66656;
GP7.Longitude = -79.40445;

//Create Polygon using above points
GooglePolygon PG1 = new GooglePolygon();
PG1.ID = "PG1";

//Give Hex code for line color
PG1.FillColor = "#0000FF";
PG1.FillOpacity = 0.4;

//Stroke is outer border of polygon.
PG1.StrokeColor = "#0000FF";
PG1.StrokeOpacity = 1;
PG1.StrokeWeight = 2;

//Add points to polygon
PG1.Points.Add(GP1);
PG1.Points.Add(GP2);
PG1.Points.Add(GP3);
PG1.Points.Add(GP4);
PG1.Points.Add(GP5);
PG1.Points.Add(GP6);
PG1.Points.Add(GP7);

//Add polygon to google map control,
GoogleMapForASPNet1.GoogleMapObject.Polygons.Add(PG1);

Go through samples provided in download. I have explained all sort of circumtances in which you may want to use google map control. If you have any questions, feel free to ask.

In Part 2, I will explain you souce code of Google Map user control and how to customize it for your own use.