Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Maps API in .NET 3.5 ASP.NET MVC application

I have an ASP.NET MVC application which is pretty simple so far, but I want to add a driving directions page to the clients location. I see plenty of examples using the traditional code behind model but none with ASP.NET MVC. The application uses master pages and content pages.

I'm pretty new to ASP.NET MVC, so bear with me. Any examples of doing this would be much appreciated.

PS: I'm not totally against integrating a standard code behind type page in the application if needs be.

like image 719
MikeD Avatar asked Feb 28 '09 16:02

MikeD


2 Answers

I think tvanfosson is correct; you should look at JavaScript examples. The fact that you're using ASP.NET MVC won't really affect your Google Maps code. Write the Google maps code in one of your view content pages just as you would in a standard ASP.NET application, or even just a plain HTML + JavaScript application. The only difference is that you will want to dynamically add JavaScript variables or parameters so your Google Maps code can use it.

I think you should not put any of your logic in a code-behind file. It will keep your project cleaner to keep logic in the controller, and using a code-behind won't really help you here. Instead have your controller perform the logic and hand the results to the view in the ViewData.

like image 117
Bryan Avatar answered Oct 26 '22 23:10

Bryan


I'd probably look for examples that interact through Javascript rather than via .NET interface. Check out the Google Maps API documentation at http://code.google.com/apis/maps/documentation/index.html, examples at http://code.google.com/apis/maps/documentation/examples/index.html.

like image 25
tvanfosson Avatar answered Oct 26 '22 23:10

tvanfosson