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.
preguntado el 08 de noviembre de 11 a las 12:11
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 y luego 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.
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!