google maps - how to pass query string with 2 values in mvc -
i want send 2 values (longitude , latitude)while click row. when click row in table should redirect web page , show marker in google map.how can pass dynamic values in query string
code
@model list<smartpond.models.assetdetailsviewmodel> @{ viewbag.title = "details"; layout = "~/views/shared/_layout.cshtml"; } <div> <table> <tbody> @foreach (var device in model.select(x => x.deviceid).distinct().tolist()) { foreach (var item in model.where(x => x.deviceid == device).select((value, i) => new { i, value })) { <tr class="tr_@item.value.deviceid"> <td>@(item.i + 1)</td> <td>@item.value.deviceid</td> <td><a href="@url.action("marker", "tracker")">@item.value.latitude</a></td> <td><a href="@url.action("marker", "tracker")">@item.value.longitude</a></td> <td>@item.value.time</td> <td>@item.value.battery</td> </tr> } } </tbody> </table> </div>
use javascript,
$("tr").click(function() { var tabledata = $(this).children("td").map(function() { return $(this).text(); }).get(); var latitude= $.trim(tabledata[3]); var longitude= $.trim(tabledata[4])); //3 latitude , 4 longitude //then use ajax pass parameter function $.ajax({ type: 'post', url: 'mywebform.aspx/getlatlong', contenttype: 'application/json; charset=utf-8', data: { lat: latitude, long: longitude }, datatype: 'json', success: {}, error: {} });
//it hit getlatlong method in mywebform.aspx
Comments
Post a Comment