Get localsearch in maps v2 api to search a default value on load

烈酒焚心 提交于 2019-12-08 08:19:49

问题


<!DOCTYPE html>
<html>
<head>
<title>RJI Events</title>

<link rel="stylesheet" type="text/css" href="stylesheets/scrollbar.css">

<link rel="stylesheet" type="text/css" href="stylesheets/app.css">

<style type="text/css">

 @import url("http://www.google.com/uds/css/gsearch.css");
  @import url("gmlocalsearch.css");
</style>

<script type="text/javascript" src="jslibs/cubiq-iscroll/iscroll.js"></script>

<script src="jslibs/jquery-1.6.4.min.js" type="text/javascript"></script>

<script src="jslibs/jquery-ui-1.8.14.custom/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>

<script src="jslibs/cubiq-iscroll/iscroll.js" type="text/javascript"></script>

<script src="jslibs/phonegap-1.0.0.js" type="text/javascript"></script>

<script src="jslibs/handlebars.1.0.0.beta.3.js" type="text/javascript"></script>

<script src="app/start.js" type="text/javascript"></script>

<script>    
var myScroll;
function OnLoad() {
//GSearch.execute("google");
//I feel like it should go here 
}

function loaded() {
    myScroll = new iScroll('wrapper', { scrollbarClass: 'myScrollbar' });
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
</script>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyCrw28V3lIOj9Rav9_7fVWrB2sKUzoqKkc" 
type="text/javascript"></script>
<script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>

<script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
<script type="text/javascript">

function initialize() {
  if (GBrowserIsCompatible()) {    
    // Create and Center a Map
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(38.95, -92.32), 15);
   // bind a search control to the map, suppress result list
    map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT));
  }
}

GSearch.setOnLoadCallback(initialize);
</script>
</head>
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
<div id="header"><a href="http://rjionline.org">Event Name</a></div>
<div id="wrapper">
    <div id="scroller">
        <div id="map_canvas" style="width:99%;height:500px"></div>
    </div>
</div>
<div id="footer">
<div id="footerInfo">
    <div id="footerEvents-active"><a class = "footer-link" href = "index.php">Events</a></div> 
    <div class="footerSpacer">|</div>
    <div id="footerRJI"><a class = "footer-link" href = "aboutRJI.html">RJI</a></div>
    <div class="footerSpacer">|</div>
    <div id="footerAbout"><a class = "footer-link" href = "about-us">About</a></div>
</div>
</div>    
</body>
</html>

Im sort of new to stack overflow, so sorry if im not specific enough. Im using the localsearch from here http://code.google.com/apis/ajax/playground/#localsearch and would like to have it have a default search value, and search it on load like in this example http://code.google.com/apis/ajax/playground/#center_localsearch. Thank you, i appreciate all of the help. Also, this is for a mobile phone app, although if it works in the browser it will work on the phone

来源:https://stackoverflow.com/questions/8336626/get-localsearch-in-maps-v2-api-to-search-a-default-value-on-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!