Information Technology Reference
In-Depth Information
LocalResult.prototype.html = function() {
var me = this;
var container = document.createElement("div");
container.className = "unselected";
container.appendChild(me.result_.html.cloneNode(true));
return container;
}
GSearch.setOnLoadCallback(prepareMap);
</script>
</head>
<body>
<p>Move Me! Transit Search Example</p>
<div style="width: 330px;">
<input type="text" id="searchtext" style="width: 240px;"/>
<input type="button" value="Find" onclick="execSearch()"/>
<div style="position: absolute; left: 440px;">
<div id="resultlist">
</div>
</div>
<div id="map" style="height: 450px;"></div>
</div>
</body>
</html>
First, let's get the easy stuff out of the way. You should already recognize several
JavaScript functions from our geolocation introduction in chapter 9. Our old friends
supportsGeo() and changeDiv() are present, performing the same geolocation support
detection functions, and <div> content changing functions respectively.
Our example code slightly changes the way we're invoking some of the publicly
available services we're consuming. In this case, because we've elected to use Google's
Maps API and its Search API, we've refactored loading Google's JavaScript libraries to
first load the base framework as follows
<script
src=" http://www.google.com/jsapi?key=AIzaSyBU-TWQkYc-ynkeYIrd_aP0UFdyRieCyR0"
type="text/javascript">
</script>
Then, in our own JavaScript, we use Google's google.load() function to additionally
load the Maps API and Search API. If you choose another service or set of services such
as Bing, Yahoo, Baidu, or something else, loading APIs would change to match the
appropriate invocation for those services. For our example, the code is very simple:
google.load('maps' , '3', {"other_params":"sensor=false"});
google.load('search', '1');
NOTE: You can revert to using the Google Maps version 2 API should you be more familiar with it,
but you'll see repeated warnings that it is deprecated when you use websites relying on that
version of the API.
 
Search WWH ::




Custom Search