-
Notifications
You must be signed in to change notification settings - Fork 8
geoloqi.maps Documentation
This namespace contains tools for creating complex interactions and applications with Google Maps.
Using these tools requires google maps with the geometry library.
<script type="text/javascript" src="https://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>
Parameters
map
This is the default google.maps.Map object you want to use for geoloqi.maps objects. Objects will be created on this map by default. If you have set this you will want to pass map: null
to create hidden objects.
Contains small helper functions for google maps.
This will zoom and center the default map to the accommodate a circle drawn with center
and radius
Parameters
center
A google.maps.LatLng
object.
radius
Radius of the circle in meters
returns the radius of a circle that will fill percent
of the height of the default map
Returns integer
styles are visual themes that are applied to your geoloqi.map.pin
objects. You can define styles for pins, handles, circles, and lines here. This will help you keep styles consistant across large applications.
This will define a new style, use the new style by passing "style_name" to the style option on geoloqi.maps.pin
objects.
Parameters
style_name
A string representing the title of the style.
styleObject
An object representing the style. Check the demo files for examples of style objects
NOTE: You can also define options for the Infobox library in your style.
makeDefault
Boolean. Optional. Defaults to False.
If true this style will be made the default style after it is defined.
Returns the style object of the given name.
Returns
object
Sets the default style for all geoloqi.maps.pin
objects to the defined style.
Creates a basic pin.
Options Sample { position: goggle.maps.LatLng() || {lat: int, lng: int} autopan: bool, draggable: bool, style: string, map: google.maps.Map || null, events: { eventname: function(){} } }
position
Required, can be a google.maps.LatLng
object or a object literal with latitude
and longitude
properties.
draggable
Boolean. Optional. Defaults to true.
autopan
Boolean. Optional. Defaults to false.
If true the map will recenter on the pin every time the user drags it.
style
String. Optional. Defaults to "default"
map
By default pin objects are create on the map set by geoloqi.maps.setDefault()
method. This allows you to override that and create pins on differnet (or no) map.
NOTE ON OPTIONS: These options are passed into the google.maps.Marker
object to create the pin. So you can also set any options that google.maps.Marker
accepts.
Properties
marker
A google.maps.Marker
object. Some methods below are aliased to this object so instead of basic.marker.setPosition(latLng) you can so basic.setPosition(latLng)
.
Methods
onMap
Will return true
if this pin is on a map. Otherwise will return false
.
centerHere
Will center the map on this pin.
showOnMap(map)
Shows the marker on the default map or the map
.
removeFromMap
Hides the marker by removing it from the map.
setDraggable(bool)
Set the markers draggable property to bool
getDraggable()
returns a bool representing if the marker is draggable
toggleDraggable()
Toggles the draggable state of the marker
moveTo(position, autopan)
Moves the pin to position
, position
can be a google.map.LatLng
or an object literal with lat
and lng
properties. If autopan
is true the map will pan to the new location.
setPosition(latLng)
Alias for this.marker.setPosition
, however it accepts an object literal with lat
and lng
properties
getPosition(latLng)
Alias for this.marker.getPosition. Returns a google.maps.LatLng
object
getMap
returns the google.maps.Map object this object is assigned to
getLat
Returns an integer representing the latitude.
getLng
Returns an integer representing the longitude.
setMap(map)
Alias for this.marker.setMap()
Options { position: goggle.maps.LatLng() || {lat: int, lng: int} autopan: bool, draggable: bool, style: string, radius: integer, editableRadius: bool map: google.maps.Map || null }
In addition to the options for geoloqi.maps.pins.Basic
google.maps.pins.WithRadius
accepts 2 new parameters.
radius
Integer. Optional. Defaults to radius set in style.
The radius of the circle in meters.
editableRadius
Boolean. Optional. Defaults to true.
If true the radius of this circle is user editable. Shows a resize handle.
Parameters
marker
A geoloqi.maps.pins.Basic
holding main pin
handle
A google.maps.Marker
representing the handle for editing the radius
line
A google.maps.Polyline
connecting the handle
to the marker
isLocked
Boolean true is this pin can be dragged and its radius changed by the user.
Methods
Also has all methods from geoloqi.maps.pins.Basic
hideCircles()
Removes the circles from the map.
showCircles()
Shows circles on map.
getRadius()
Returns the radius of the outermost circle.
setupCircles(radius, showOnMap)
Recreates the circles at the radis
. Optionaly will show the circles on the map. showOnMap
defaults to the state of the pin (visible or not). it will show the circles if the pin is shown and hide the circles if the pin is hidden.
updateHandle()
Updates the position of the handle. Generally this happens automatically.
updateLine()
Updates the position of the line. Generally this happens automatically.
hideHandle()
Removes the line and handle from the map.
showHandle()
Shows the line and handle on map.
fitCircles(integer)
Will fit the circles to a ideal size for the map. Defaults to 50% of the map height.
lockPin()
Removes the line and handle from the map also sets draggable to false.
unlockPin()
Shows the line and handle one the map. Makes it so users can drag the pin.
toggleLock()
Toggles if the pin is locked or not.
NOTE ABOUT INFOBOXES: geoloqi.maps.pins.WithInfobox
and geoloqi.maps.pins.WithInfoboxAndRadius
supports both standard google.maps.InfoWindow
and Infobox
which is a part of the Google Maps v3 Utility Library.
Infobox can be found here http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.8/
Options { position: goggle.maps.LatLng() || {lat: int, lng: int} autopan: bool, draggable: bool, style: string, opened: bool, toggleInfoOnClick: bool, content: string || InfoBox || InfoWindow, openAfterDrag : bool map: google.maps.Map || null }
In addition to the options for geoloqi.maps.pins.Basic
geoloqi.maps.pins.WithInfobox
accepts 3 new parameters.
opened
Boolean. Optional. Defaults to true.
Should this infobox/info window be opened when it is created.
toggleInfoOnClick
Boolean. Optional. Defaults to true.
Should this infobox/infowindow be opened/closed when the marker is clicked.
content
string || InfoBox || InfoWindow. Optional. Defaults to null.
Content to display in the Infobox or InfoWindow or pass in an InfoBox
or InfoWindow
object.
openAfterDrag
If true reopen the Infobox after the user drags the marker or the handle if false this infox will remain visible when objects are dragged.
Parmas
marker
A geoloqi.maps.pins.Basic
holding main pin
info
The Infobox
or google.maps.InfoWindow
object
Methods
hide()
Hides the Infobox
or google.maps.InfoWindow
by setting display none.
show()
Shows the Infobox
or google.maps.InfoWindow
if it was hidden.
open()
Opens the Infobox
or google.maps.InfoWindow
at this pin.
Close()
Closes the Infobox
or google.maps.InfoWindow
remvoving it form the map.
toggleInfo()
Toggles the visibility of the Infobox
or google.maps.InfoWindow
with show()
or hide()
setContent(html)
sets the content of Infobox
or google.maps.InfoWindow
to html
getContent
Returns html representing the content of the infobox.
setInfo(Infobox or InfoWindow, open)
assigns a new Infobox
or google.maps.InfoWindow
to this object. Will show or hide the infobox/infobox based on open
(Defaults to false);
This object is a combination of geoloqi.maps.pins.Basic
geoloqi.maps.pins.WithRadius
and geoloqi.maps.pins.WithInfobox
It has all the methods, and properties and accepts all the options.
Options { lat: integer, lng: integer, autopan: bool, draggable: bool, style: string, opened: bool, toggleInfoOnClick: bool, radius: integer, editableRadius: bool map: google.maps.Map || null }
When Creating a Pin You can define several events that will be triggered. Just pass and object with the following properties.
All Pins
- dragstart
- dragend
- drag
- click
- position_changed
- map_changed
- create
- show
- hide
PinWithRadius
- lock
- unlock
- radius_changed
PinWithInfoBox
- open
- close