Show google maps based on address in MVC / jquery

I need to show google map based on contact address in asp.net (MVC) C # application.

I have a contact list in my application. When a user views a specific contact, I need to show the google map of the contact address aside from the contact browsing page.

How can I implement this function using jquery in MVC?

+4
source share
3 answers

You can use the jQuery Google Maps plugin for this, however it does not yet have support for converting an address to a location, as this requires latitude and longitude in front.

+1
source

The first thing you probably want to do is get the latitude and longitude of the contact address. You can either access the geoCode api, or do it in real time or get it and save it in the database when you first create a new contact. I highly recommend it later, and you'll save a ton of headaches if you don't need to look for geoCode to find each page.

Then attach your latitude and longitude to the ViewModel so that you can work with these values ​​in your view. Set latitude and longitude to a couple of javascript variables and you will go well.

Take a look at the “hello world” for google maps api and you should have all the information you need. Just set the parameters for what you want and use your latitude and longitude.

You can’t do much with jQuery here, as you will mainly use the Google api. The only real advantage would probably be to put things in $ (funcion () {... so you don’t have to execute the function on the body of onload = ...

+1
source

Perhaps MVCMaps may be useful to you. It can be used for both Bing Maps and Google Maps.

Visit http://mvcmaps.codeplex.com/ .

0
source

All Articles