更新。
我试过你说的。功能是。
[HttpPost]
public ActionResult populate_place(string lati, string longi)
{
list_placesModels list_place = new list_placesModels();
list_place.Latitude = lati;
list_place.Longitude = longi;
return View();
}
但知道它没有显示新的视图。我不知道为什么?仍然显示旧视图。它不会重定向到新视图。未显示新视图。它仍然保持相同的观点。
////////////
我正在使用 Google 地图的地理编码功能来访问我在 asp.net mvc 应用程序中的 Razor 视图中的某个位置的纬度和经度。
我想将该纬度和经度传递给控制器中的函数。但什么都没有发生。下面是我的代码片段。
JS代码:
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker( {
map: map,
[0].geometry.location
});
// I want to pass these value of latitude and longitude a function
// list_places() in UserController.
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
$.post("/User/list_places",
{
lati: latitude,
longi : longitude
});
控制器:
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);
}