locked
Using geocoding in asp.net mvc and want to transfer latitude and longitude from JS to some function in controller. RRS feed

  • Question

  • I am using Geo-coding feature of Google maps to access latitude and longitude of a location in my Razor view in asp.net mvc application.

    I want to pass that Latitude and longitude to a function in controller. But nothing is happening. Below is my code snippet.

    ////////////////////////

    if (status == google.maps.GeocoderStatus.OK) {

                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        [0].geometry.location

                    });

            latitude = results[0].geometry.location.lat();
            longitude = results[0].geometry.location.lng();   // I want to pass these value of latitude and longitude a function list_places() in UserController.

           $.post("/User/list_places",
                    {
                        lati: latitude,
                        longi : longitude
                    
                    });

    ////// Function in controller.

    public ActionResult list_places(string usernameid, string lati, string longi)
            {
                list_placesModels list_place = new list_placesModels();
                list_place.Latitude = lati;
                list_place.Longitude = longi;
                return View(list_place);
           }

    • Moved by Jason Dot Wang Friday, March 8, 2013 2:20 AM This thread is about ASP.NET
    Wednesday, March 6, 2013 2:53 PM

Answers

  • I got my problem solved.

    http://stackoverflow.com/questions/15267922/using-ajax-post-to-transfer-data-from-js-to-a-function-in-controller-in-asp-net?noredirect=1#comment21548408_15267922

    • Marked as answer by twoface21 Friday, March 8, 2013 5:00 PM
    Friday, March 8, 2013 4:59 PM

All replies

  • Hi twoface21,

    This forum  only support  JScript .NET . As your issue is more about javascript, I'd suggest you to ask in :ASP.NET HTML, CSS and JavaScriptforum  for better support. You may have more luck getting answers there.

    Thanks for your support and  understanding !

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 8, 2013 2:19 AM
  • I got my problem solved.

    http://stackoverflow.com/questions/15267922/using-ajax-post-to-transfer-data-from-js-to-a-function-in-controller-in-asp-net?noredirect=1#comment21548408_15267922

    • Marked as answer by twoface21 Friday, March 8, 2013 5:00 PM
    Friday, March 8, 2013 4:59 PM