You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An ember-cli add-on for easy integration with Google Maps.
Each object displayed on map is inserted via child component,
so you can easily declare which marker and when to display on map
using {{#if}} and {{#each}} on template level.
Installation
ember install ember-g-map
Configuration
You must define the size of the canvas in which the map is displayed.
Simply add something similar to this to your styles:
.g-map-canvas {
width:600px;
height:400px;
}
In config/environment.js you can specify additional Google Maps libraries
to be loaded along with this add-on (check the full list here)
and optional API key for your application (additional info could be found here).
Mandatory context attribute ties child-elements
with the main g-map component. You can set simple title appearing on click
using title attribute and marker label using label.
These Info Windows will be open right after component is rendered
and will be closed forever after user closes them. You can specify
optional onClose action to tear down anything you need when Info Window
has been closed by user.
{{#g-maplat=37.7833lng=-122.4167zoom=12as |context|}}{{#g-map-infowindowcontextlat=37.7733lng=-122.4067}}
<h1>Info Window with Block</h1>
<p>Text with {{bound}} variables</p>
<button{{action"do"}}>Do</button>
{{/g-map-infowindow}}{{g-map-infowindowcontextlat=37.7733lng=-122.4067title="Blockless form"message="Plain text."}}{{g-map-infowindowcontextlat=37.7733lng=-122.4067title="With action set"onClose="myOnCloseAction"}}{{g-map-infowindowcontextlat=37.7733lng=-122.4067title="With closure action set"onClose=(action"myOnCloseAction")}}{{/g-map}}
Map fits to show all initial Markers
markersFitMode attribute overrides lat, lng, zoom settings.
markersFitMode value can be one of:
'init' - which will make the map fit the markers on creation.
'live' - which will keep the map keep fitting the markers as they are added,
removed or moved.
Markers can have bound Info Windows activated on click.
To properly bind Info Window with Marker you should call g-map-marker
in block form and set context of Info Window to the one provided by Marker.
{{#g-maplat=37.7833lng=-122.4167zoom=12as |context|}}{{g-map-markercontextlat=37.7933lng=-122.4167}}{{#g-map-markercontextlat=37.7833lng=-122.4267as |markerContext|}}{{#g-map-infowindowmarkerContext}}
<h2>Bound Info Window</h2>
{{/g-map-infowindow}}{{/g-map-marker}}{{/g-map}}
Grouped Markers with Info Windows
Additionally you can specify parameter group which ensures that only
one Info Window is open at each moment for Markers of each group.
Proxy g-map-address-marker component takes address string as parameter
and translates it to lat/lng under the hood.
Optional onLocationChange action hook will send you back coordinates
of the latest address search result and the raw array of
google.maps.places.PlaceResult objects provided by places library.
Other optional parameters are the same as for g-map-marker.
Requires places library to be specified in environment.js.
{{#g-maplat=37.7833lng=-122.4167zoom=12as |context|}}{{g-map-address-markercontextaddress="San Francisco, Russian Hill"}}{{#g-map-address-markercontextaddress="Delft, The Netherlands"}}{{#g-map-infowindowmarkerContext}}
Works in block form too.
{{/g-map-infowindow}}{{/g-map-address-marker}}{{g-map-address-markercontextaddress=searchedAddressonLocationChange=(action"onLocationChangeHandler")}}{{g-map-address-markercontextaddress=anotherSearchedAddressonLocationChange="onLocationChangeHandler"}}{{/g-map}}