javascript - Search function on Map -
basically trying search function onemap application. here html:
<div id='top-bar'> <table> <tr> <td style='width:90%;'><input placeholder='enter address' id='search-box' type='text'/></td> <td id='search-button'><img id='search-icon' src='img/search.png' width='20' height='20' onclick='getsearchdata()'/></td> <td id='searchresults'></td> </tr> </table> </div>
and here javascript:
function getsearchdata() { var basicsearch = new basicsearch; var searchtext = document.getelementbyid("search-box").value; basicsearch.searchval = searchtext; basicsearch.returngeom = '1'; basicsearch.getsearchresults(displaydata); } function displaydata(resultdata){ var results = resultdata.results; if (results=='no results'){ document.getelementbyid('searchresults').innerhtml = "no result(s) found"; return false } else{ var htmlstr = "<table>"; htmlstr = htmlstr + "<tr><th>search value </th></tr>"; (var = 0; < results.length; i++) { var row = results[i]; htmlstr = htmlstr + "<tr>"; htmlstr = htmlstr + "<td>"; htmlstr = htmlstr + "<a href='javascript:zoomto("+ row.x +","+ row.y +")'>" + row.searchval + "</a>"; htmlstr = htmlstr + "</td>"; htmlstr = htmlstr + "</tr>"; } htmlstr = htmlstr + "</table>"; document.getelementbyid('searchresults').innerhtml = htmlstr; } } function zoomto(xval,yval){ map.showlocation(xval,yval); }
however, when try perform search, told me basicsearch not defined thought 1 of onemap api library?
i guide site: api documentation guides? in advance.
Comments
Post a Comment