Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions addon/components/g-map/advanced-marker.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
{{yield (hash
infoWindow=(component "g-map/info-window" getContext=@getContext target=this.mapComponent))}}
{{#if (has-block)}}
<div {{this.initContent}} ...attributes>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only set this div up optionally to reduce overhead for consumers that don't want this behavior

{{yield (hash
infoWindow=(component "g-map/info-window" getContext=@getContext target=this.mapComponent))}}
</div>
{{else}}
{{yield (hash
infoWindow=(component "g-map/info-window" getContext=@getContext target=this.mapComponent))}}
{{/if}}
21 changes: 19 additions & 2 deletions addon/components/g-map/advanced-marker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import TypicalMapComponent from './typical-map-component';
import { toLatLng } from '../../utils/helpers';
import { modifier } from 'ember-modifier';

export default class AdvancedMarker extends TypicalMapComponent {
domElement = undefined;

initContent = modifier((element) => {
this.domElement = element;
});

get name() {
return 'advancedMarkers';
}
Expand All @@ -11,7 +18,12 @@ export default class AdvancedMarker extends TypicalMapComponent {
this.options.position = toLatLng(this.args.lat, this.args.lng);
}

return this.options;
return {
...this.options,
...{
content: this.domElement,
},
};
}

update(mapComponent) {
Expand All @@ -20,6 +32,11 @@ export default class AdvancedMarker extends TypicalMapComponent {
}

newMapComponent(options = {}) {
return new google.maps.marker.AdvancedMarkerElement(options);
return new google.maps.marker.AdvancedMarkerElement({
...options,
...{
content: this.domElement,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By passing our domElement in here, any event fired by Google continue to work but we also have the ability to register our own

Completely happy to clean up the way we're handling options here, mainly wanted to send this over so we could see it / discuss it

},
});
}
}