It has been along time since I updated this control. I got many requests for drivingdirections implementation, so I decided to release a new version.Following changes are done in this version.Here is how you canimplement directions using new version.
I guess it's pretty straight forward to understand. One more property is added as Directions in main control. You need to set ShowDirections=true and addresses in ToAddress and FromAddress. Download Source also provides a direction sample code.
Special thanks to Vincent Blain who has provided source code for direction implementation.
Version 1.5
Following changes are done in this version.
In previousversions javascript functions were embedded in GoogleMapForASPNet.ascxsource. In this version javascript functions are separated inGoogleMapAPIWrapper.js file. This is done so that javascript source canbe cached locally on client machine.
Now you can change shadow image of a marker. Following new properties are added. IconShadowImage - Defines which image should be used for shadow. Image path should be given relative to root folder.
Usuallyyou don't need to provide IconShadowWidth and IconShadowHeight propertyvalues because this control tries to find height and width of imageautomatically.
Icon and InfoWindow Anchor properties are now supported. IconAnchor_posX - This defines Icons anchor position from left. IconAnchor_posY - This defines Icons anchor position from top.
InfoWindowAnchor_posX - This defines Info Window(balloon)'s anchor position from left. InfoWindowAnchor_posY - This defines Info Window(balloon)'s anchor position from top.
SourceCode documentation for this control is released alongwith this version.Click on following link to view this documentation, Google Maps Control for ASP.Net - Part 2
Version 1.4
Following changes are done in this version.
Geocoding is now supported in this version. You can find Latitude and Longitude value based on an Address. Here is how to do it
14.lblError.Text = "Unable to geocode this address.";
15.}
Download source and see samples for detailed implementation.
Automaticboundary is now set by default. i.e.,if pushpins are movingcontinuously on map and they go outside map boundaries, map will resetit's bounds to accomodate pushpins. You can disable automatic boundaries using following code.
A bug related to Visual Studio 2008 is fixed. Old version was getting stuck in design view. This version should work fine.
control inGoogleMapControl.ascx is replaced with control. This allows users toplace control on web page itself and thus allowing them to use Ajaxcontrols before Google Map Control.
A small bug related to Satellite or Hybrid View is fixed. You can set Satellite View programatically as below,
Added a new property called RecenterMap. When it's set to true map will be re-centered and zoomed to default level on postback.
Now you can add Tooltip for markers.
Draggable pushpins are now supported.
Version 1.2
Following changes are done in this version.
A minor bug related to Polygons is fixed
Now you can enable or disable Traffic overlays.
Version 1.1
Following features are added in this version.
Now you can draw polylines and polygons with this control
Anew property GoogleMapObject.APIVersion is added with this control.This will allow users to use any version of Google Maps API. Defaultversion is 2.
Introduction
Most of usare familiar with google map. Google has provided a very reach APIs touse it in our own application. But we need some short of javascriptknowledge in order to use it. I don't know about others, but for me itwas a little difficult to use javascript along with google apis inASP.Net pages, specifically if you want to use server side functions todraw google map dynamically. For example, in my case I wanted to pulllatitude longitude information from a SQL Server database and then usethem to insert pushpins on google map. If you are familiar with Ajaxframework, you know the answer. You will have to call asp.net serverside function from javascript and use retrieved data to draw a googlemap. How simple is that? :). Atleast not for me. So I have decided towrite a user control which can take care of javascript part and allowsme to concentrate on serverside functions.
Features
Enables you to draw google map. No javascript knowledge required. Just drag and drop control on your page.
Uses Ajax calls to retrieve server side data.
Enables you to change pushpin postions on the fly. No need to refresh full map.
Enables you to change pushpin icons on the fly.
Optimized to give you best performance. i.e., only those pushpin data will be retrieved from server that are changed.
How to use
In this partof article, I don't want you to explain how I created this control.Instead I want you to start using it. To view documentation for sourcecode visit following article. Google Maps Control for ASP.Net - Part 2
Requirements
Visual Studio 2005 or higher
Microsot ASP.Net Ajax framework. You can download it from here.
Internet Explorer 7.0 or Mozilla Firefox 2.x. (Note: It may work on other browsers. I have tested on IE and Firefox only.)
Follow below steps in order to use it in your ASP.Net website.
Download source from link provided on top of the page. Extract it somewhere on your harddrive.
Openextracted folder as a website in Visual Studio and run it. When you runthis website, you will be able to navigate few samples pages.
To use this control in your application, copy following files to your ASP.Net application in same structure as shown below.
Now wewill add reference to Ajax library. If you are already using Ajaxcontrols in your application, you can skip following 4 steps.
Adding Ajax Framework to your website
Right click on your website in solution explorer and click add reference.
In AddReference window, select System.Web and System.Web.Extensions librariesand click OK. Note library versions (in below picture 1.0.61025.0. Youmay have another version. You can use any version).
Go to your web.config file and add following lines between element.
Add pushpinsfor map. This can be done by initializing GooglePoint type object. Inconstructor of GooglePoint, First argument is ID of this pushpin. Itmust be unique for each pin. Second and third arguments are latitudeand longitude.
You can add as many pushpins as you wish. Now run website again and you should see pushpins on map.
Assigning custom icon to pushpins
You canassign your own icons with google map control. For that first copy youricons in some directory under root directory of your website. You canassign icon to a pushpin as below,
1.GP.InfoHTML = "This is <font color='red'>Pushpin-1</font>";
Up tothis point, I have explained you basics of using Google Map control.Now let's implement some advanced functionality. Let's say we want tomove pushpins when user do some action. For example when a user clickson a button. For that, follow below steps.
Creating Interactive Map
You cancreate interactive map using Google Map control. You can move pushpinswhen user clicks on a button. Here is how you can do it.
Insert standard asp.net button on your web page. Write following code in click event of this button.
We areincrementing Latitude and Longitude value for Pushpin-1 here. Note thatI am using ID(In above code "1") of pushpin to set new Latitude andLongitude.
Run yourapplication and click on Button. You will note that whole page get'srefreshed (or postback). To stop it from posting back, you need to wrapthis button with an Ajax Update panel. Go to Visual Studio toolbox anddrag Ajax Updatepanel control on your page.
Move your button inside this update panel.
Now run website again and click on button. You should notice that now page is not posting back and Pushpin moves on map.
Auto refreshing map and GPS Navigation
You can useAjax Framewor's timer control in similar way as button control (I haveexplained above). On Timer_Tick() event you can specify new latitudelongitude for all pushpins. This way Map will move all pushpinsautomatically after specified time delay. You can hook up any GPSservice with this control to create GPS Navigation system.
请发表评论