angularjs - Leaflet Marker message on click ajax call -
i have marker on leafletjs on click need invoke ajax call , then
markers.push({ id: 'abc_' + j, lat: abclatlonoptions[j][0], lng: abclatlonoptions[j][1], layer: 'abc', icon: { iconurl: icons['abc'].icon, iconsize: [16, 16], popupanchor: [0, 0], }, message: complieabcmessage(lat, lon, starttime, eta, calculatedeta, speed) }
now depending on lat , lon need retrieve data , show. above function works, problem have 1000's of markers , loop through markers , while adding markers function complieabcmessage invoked , ajax invoked, don't want happen
how can avoid function being called when adding markers , invoke onclick?
update 1:
function complieabcmessage(lat, lon, starttime, eta, calculatedeta, speed) { var tide_level = 7.5; var tidewindowrequest = $.ajax({ type: "get", async: false, url: "https://api.sealevelresearch.com/1/predictions/tide-windows/liverpool-gladstone-dock/?start=" + starttime+ "z&end=" + eta+ "z&tide_level=" + tide_level, contenttype: "application/json; charset=utf-8" }); return tidewindowrequest; }
@muzaffar here [jsfiddle][1] solution
[1]: enter code here
http://jsfiddle.net/d2p19vn4/3/
Comments
Post a Comment