-
Notifications
You must be signed in to change notification settings - Fork 382
Js Methods
I encourage you to read the source, it's pretty straight forward.
The main principle is: the handler invokes builders returning model instances.
So:
- if you want to change how your objects are built, change the builders.
- if you want to change the objects you retrieve, change the models.
The first method you'd trigger from your handler is buildMap
.
the signature of the method is buildMap(options, onMapLoad)
options
are detailed in the map builder. onMapLoad
is a function to trigger after map has been created.
Example:
handler.buildMap { provider: { maxZoom: 3 }, internal: {id: 'map'} }, ->
handler.map.centerOn({ lat: 40, lng: 5 })
The handler lets you create all overlays.
Collection methods are:
addMarkers(array_of_data, options)
addCircles(array_of_data, options)
addPolylines(array_of_data, options)
addPolygons(array_of_data, options)
addKmls(array_of_data, options)
If you only have to add a single overlay:
addMarker(data, options)
addCircle(data, options)
addPolyline(data, options)
addPolygon(data, options)
addKml(data, options)
To remove markers created by the gem:
removeMarkers(markers)
removeMarker(marker)
Options example:
markers = handler.addMarkers(<%= raw @hash.to_json %>, {draggable: true});
You can find all the possible options here.
For some specific docs:
data are info expected to build our object. options are the one used by google, straight.
Check the builders to get all details, they are provided before the constructor.
Notice it's highly recommended to trigger these methods in the onMapLoad
callback so that you're sure the map is really created before you start adding overlays.