Note that there are some explanatory texts on larger screens.

plurals
  1. POAssociate Load of List in Controller for Google Map?
    primarykey
    data
    text
    <p>I'm stuck in a situation where i need to Get the List in My Controller but now Currently I'm using A Kendo Grid to fetch the list that will be used in my Google Maps</p> <p>Now my question are</p> <ol> <li><p>How can i associate the LoadWorkerList in Controller Directly in my Googlemap and Add it as a Marker?</p> <p>2.How can i make A List of Markers on my Screen??</p></li> </ol> <p>This is my Javascript for my Google Maps :</p> <pre><code>&lt;script type="text/javascript"&gt; var geocoder; var map; function initialize() { var minZoomLevel = 4; var zooms = 7; geocoder = new google.maps.Geocoder(); map = new google.maps.Map(document.getElementById('map'), { zoom: minZoomLevel, center: new google.maps.LatLng(38.50, -90.50), mapTypeId: google.maps.MapTypeId.ROADMAP }); // Bounds for North America var strictBounds = new google.maps.LatLngBounds( new google.maps.LatLng(15.70, -160.50), new google.maps.LatLng(68.85, -55.90) ); // Listen for the dragend event google.maps.event.addListener(map, 'dragend', function () { if (strictBounds.contains(map.getCenter())) return; // We're out of bounds - Move the map back within the bounds var c = map.getCenter(), x = c.lng(), y = c.lat(), maxX = strictBounds.getNorthEast().lng(), maxY = strictBounds.getNorthEast().lat(), minX = strictBounds.getSouthWest().lng(), minY = strictBounds.getSouthWest().lat(); if (x &lt; minX) x = minX; if (x &gt; maxX) x = maxX; if (y &lt; minY) y = minY; if (y &gt; maxY) y = maxY; map.setCenter(new google.maps.LatLng(y, x)); }); // Limit the zoom level google.maps.event.addListener(map, 'zoom_changed', function () { if (map.getZoom() &lt; minZoomLevel) map.setZoom(minZoomLevel); }); } var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/'; function codeAddress() { var infowindow = new google.maps.InfoWindow(); var address = $('#workerGrid').find("input[name=shiftDay]"); alert(address); $.each(address, function () { var currVal = $(this).val(); address.each(function () { geocoder.geocode({ 'address': currVal }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, icon: iconBase + 'man.png', position: results[0].geometry.location, title: currVal }); var circle = new google.maps.Circle({ map: map, radius: 16093, // 10 miles in metres fillColor: '#AA0000' }); circle.bindTo('center', marker, 'center'); google.maps.event.addListener(marker, 'click', (function (marker, i) { return function () { infowindow.setContent(currVal); infowindow.open(map, marker); } })(marker, currVal)); address.push(marker); } else { alert("Geocode was not successful for the following reason: " + status); } }); }); }); return true; } window.onload = function () { initialize(); codeAddress(); } &lt;/script&gt; </code></pre> <p>and this is my Controllers Code :</p> <pre><code>public JsonResult LoadWorkerList() { var workerList = new List&lt;Worker_Address&gt;(); // check if search string has value // retrieve list of workers filtered by search criteria var list = (from a in db.Worker_Address where a.LogicalDelete == false select a).ToList(); List&lt;WorkerAddressInfo&gt; wlist = new List&lt;WorkerAddressInfo&gt;(); foreach (var row in list) { WorkerAddressInfo ci = new WorkerAddressInfo { ID = row.ID, Worker_ID = row.WorkerID, AddressLine1 = row.Address_Line1 + " " + row.Address_Line2+ " " +row.City + " "+ GetLookupDisplayValById(row.State_LookID), LogicalDelete = row.LogicalDelete }; wlist.Add(ci); } return Json(wlist.ToList().OrderBy(p =&gt; p.AddressLine1), JsonRequestBehavior.AllowGet); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload