Google Map Direction Custom Control using C#


Using GMap Direction User Control is very easy. 
Step 1 : Download DLL File from any server

1 : Google Map Web Part.dll 
2 : Google Map Web Part.dll
Step 2 : Create new project in VS2010.
Step 3 : Add the control in the Toolbox.

Step 4 : Create one aspx page. (Application page).

Step 5 : Add Referance of Google API V3 with your key


<script 
type="text/javascript" 
src="http://maps.googleapis.com/maps/api/js?key=YourApiKeyHere&sensor=false">
</script>
Step 6 : Set Properties for Map as below in Code File
using Google_Map_Web_Part;

//set Height & Width for Direction Panel
GoogleMapDirectionControl11.HeightDirectionPanel = 400;
GoogleMapDirectionControl11.WidthDirectionPanel = 400;

//set Height & Width for Map
GoogleMapDirectionControl11.HeightMap = 400;
GoogleMapDirectionControl11.WidthMap = 400;

//set Whether to Show Direction Panel or Not
GoogleMapDirectionControl11.ShowDirectionPanel = true;

//Create Location List Object
List<GoogleMapDirectionControl.Location> locations = new List<GoogleMapDirectionControl.Location>();


//Set Locations for showing in Map
GoogleMapDirectionControl.Location loc = new GoogleMapDirectionControl.Location();
loc.latitude = "23.0395677";
loc.longitude = "72.5660045";
locations.Add(loc);

loc = new GoogleMapDirectionControl.Location();
loc.latitude = "22.689529";
loc.longitude = "72.857246";
locations.Add(loc);

loc = new GoogleMapDirectionControl.Location();
loc.latitude = "22.3073095";
loc.longitude = "73.1810976";
locations.Add(loc);

loc = new GoogleMapDirectionControl.Location();
loc.latitude = "21.195";
loc.longitude = "72.819444";
locations.Add(loc);

loc = new GoogleMapDirectionControl.Location();
loc.latitude = "20.371237";
loc.longitude = "72.90634";
locations.Add(loc);

loc = new GoogleMapDirectionControl.Location();
loc.latitude = "19.0759837";
loc.longitude = "72.8776559";
locations.Add(loc);

//Add location to the Map Control
GoogleMapDirectionControl11.setLocation(locations);

//Display Generated Map
GoogleMapDirectionControl11.setMap();
This will display the the map with directions.

Output looks like..


Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...