Skip to content

benignware/jquery-placepicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery-placepicker

A simple placepicker component for the google-maps api.

Demo

Usage

Include dependencies. Be sure to add Google Places.

<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
<script src="js/jquery.placepicker.min.js"></script>
<input class="placepicker" size="40"/>
$(".placepicker").placepicker();

Advanced usage

Integrating a map view

This example shows how to integrate a collapsible map-view using bootstrap.

Include Bootstrap Collapsible and styles.

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group">
  <input class="placepicker form-control" data-map-container-id="collapseOne"/>
</div>
<div id="collapseOne" class="collapse">
  <div class="placepicker-map thumbnail"></div>
</div>
$(".placepicker").placepicker();
.placepicker-map {
  min-height: 250px;
}

Options

TypeNameDescription
HTMLdata-latitudePreset the map's latitude
HTMLdata-longitudePreset the map's longitude
HTMLdata-latitude-inputSet the DOM ID of the input field to populate with the latitude
HTMLdata-longitude-inputSet the DOM ID of the input field to populate with the longitude
HTMLdata-map-container-idSet the ID of the element containing the map's destination element. Configuring this will automatically inject an open/close button to show/hide the map. The container must have Bootstrap's "collapse" CSS class.
JavaScriptmapMap selector or map-element
JavaScriptmapOptionsAn object with google maps api options
JavaScriptplaceChangedThis callback is fired when location changed

Methods

NameDescriptionReturn
reloadReloads mapvoid
resizeResizes mapvoid
geoLocationSet value to html5 geo-locationvoid
getLocationReturns an object containing the current locationvoid
getLatLngReturns an object of type google.maps.LatLng containing the current location LatLng