Jeremy Geerdes :: Effective Website Design & Development
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:

searchRadiusThe radius that you want to confine your search results to (default: none)
searchRadiusUnitThe 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)
  • KILOMETERS
  • METERS
  • CENTIMETERS
  • MILES
  • FEET
  • INCHES
noResultsStringString to display when there are no results (default: "No results available")
maxZoomLevelMaximum zoom level
suppressMapPanAndZoomWhen true, the map will not be adjusted to show all results (default: false)
suppressMapPanWhen true, the map will not move to center of results cluster (default: false)
suppressMapZoomWhen true, the map will not zoom to fit all results in window (default: false)
suppressDetailsWhen true, result details will not be shown
resultSetSizeSpecifies the result set size to return from Google search (default: LARGE_RESULTSET)
anchorSpecifies 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)
  • TOP_LEFT
  • TOP_CENTER
  • TOP_RIGHT
  • BOTTOM_LEFT
  • BOTTOM_CENTER
  • BOTTOM_RIGHT
noIWOpenOnHoverWhen true, marker infowindows will not open while hovering over listing item (default: false)
idleOpacityOpacity when idle, specified in decimal format (e.g., .5=50% opacity) (default: .5)
activeOpacityOpacity when active, specified in decimal format (e.g., .9=90% opacity) (default: .9)
directionsHintHint to be used in empty directions fields (default: "Directions from...")
directionsButtonTextText to include in directions submit buttons (default: "->")
searchHintText 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:

  1. 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.
  2. 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.
  3. You do not in any way obscure any links that the copyright holder deems fit to include (e.g., attribution links)
  4. 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.