Jeremy's [Semi] Advanced Google Maps Local Search Control
Contents
jGMLSC.js is a custom Google Maps/Local Search Control designed to be more flexible than Google's, and maybe a little prettier.
To use, call yourMap.addControl(new jeremy.jGMLSC(options?)); Some example code (essentially a modified version of Google's Hello World of Google Maps) is provided below:
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://www.google.com/jsapi?key=YOUR_API_KEY_HERE"
type="text/javascript"></script>
<script type="text/javascript">
google.load('maps','2',{nooldnames:1});
google.load('search','1',{nooldnames:1});
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new jeremy.jGMLSC());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body onunload="google.maps.Unload();">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
The following options can be specified using object literal:
| searchRadius | The radius that you want to confine your search results to (default: none) |
| searchRadiusUnit | The unit in which you have specified searchRadius, specified with the following syntax: {abbr:"unit_abbreviation",label:"unit_label",ratio:"meters_per_unit"} Built in choices: jeremy.jGMLSC.units["..."] (default: MILES)
|
| noResultsString | String to display when there are no results (default: "No results available") |
| maxZoomLevel | Maximum zoom level |
| suppressMapPanAndZoom | When true, the map will not be adjusted to show all results (default: false) |
| suppressMapPan | When true, the map will not move to center of results cluster (default: false) |
| suppressMapZoom | When true, the map will not zoom to fit all results in window (default: false) |
| suppressDetails | When true, result details will not be shown |
| resultSetSize | Specifies the result set size to return from Google search (default: LARGE_RESULTSET) |
| anchor | Specifies location to anchor control, specified as object literal with following syntax: {ga:G_ANCHOR_TOP_LEFT,x:hor_offset,y:vert_offset} PLEASE NOTE that ga must be specified in the proper Google namespace (i.e., G* or google.*.*). ALTERNATIVELY, use jeremy.jGMLSC.findInGoogleNamespace(). Built in choices: jeremy.jGMLSC.anchors["..."] (default: TOP_CENTER)
|
| noIWOpenOnHover | When true, marker infowindows will not open while hovering over listing item (default: false) |
| idleOpacity | Opacity when idle, specified in decimal format (e.g., .5=50% opacity) (default: .5) |
| activeOpacity | Opacity when active, specified in decimal format (e.g., .9=90% opacity) (default: .9) |
| directionsHint | Hint to be used in empty directions fields (default: "Directions from...") |
| directionsButtonText | Text to include in directions submit buttons (default: "->") |
| searchHint | Text to include in search box (default: 'Search the map...') |
Permission to use this script on your own site is given, free of charge, provided the following conditions are met:
- The associated Javascript file(s) are not alterned in any way except to (a) save them to your own server and/or (b) adjust the value of style_url to specify the appropriate location of the necessary stylesheet.
- Your site does not contain pornographic, illegal, or otherwise immoral material, or promote or condone the same. Such material shall include, but not be limited to, content pertaining to abortion, homosexuality, transsexuality, bisexuality, and other forms of adultery.
- You do not in any way obscure any links that the copyright holder deems fit to include (e.g., attribution links)
- You have obtained written permission from the copyright holder by emailing jgeerdes@mchsi.com with an explanation of the application's purpose
© 2006 Jeremy R. Geerdes
All rights reserved.
All rights reserved.
