Reputation: 155
I'm using ASP.NET MVC 3 Framework and I want to use Google Maps (v3) to display the location of my customers. I can take the value of their addresses/City from the database, but how can I combine these two? I'm using Razor engine.
Upvotes: 0
Views: 3202
Reputation: 2860
I suggest getting your addresses through AJAX. MVC has a lot of good JSON stuff (like JsonResult
), so you'll be able to send objects instead of parsing HTML. Since you're doing AJAX, I'm obliged to mention JQuery, I don't make AJAX calls without it. You can add the HttpPost
attribute to your JSON response function too, and even make it secure!
Upvotes: 0
Reputation: 4473
If you are new to Google Maps I would suggest reading through their documentation and looking over the examples to get an idea on how the API works.
Another good tutorial to look at is the 4 guys from Rolla article on implementing a store locator application. The article was originally written in Web Forms and then later updated to MVC. There is relevant information in both. They do not use Razor views, but they do a good job at showing how to query the Google Maps API on the server side and packaging the results in a JSON object to display on the map.
Your View will be pretty simple if you just want markers on a map. The only HTML you would need is a div to store the map.
Upvotes: 1