Skip to content

Commit

Permalink
Fix dropped pin for [crouton_map] shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Nov 5, 2023
1 parent 1e96a80 commit c41bb2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions croutonjs/src/js/crouton-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ function Crouton(config) {
.then(function() {
self.reset();
self.render();
self.initMap(function() {
self.addCurrentLocationPin(latitude, longitude);
croutonMap.reload(self.meetingData, self.formatsData);
croutonMap.initMap(function() {
croutonMap.addCurrentLocationPin(latitude, longitude);
});
});
};
Expand Down
19 changes: 11 additions & 8 deletions croutonjs/src/js/crouton-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function CroutonMap(config) {
}
};

self.addCurrentLocationPin = function(latitude, longitude) {
CroutonMap.prototype.addCurrentLocationPin = function(latitude, longitude) {
var latlng = new google.maps.LatLng(latitude, longitude);
self.map.setCenter(latlng);

Expand All @@ -39,11 +39,9 @@ function CroutonMap(config) {

self.addToMapObjectCollection(currentLocationMarker);

// TODO: needs to show on click only
/*var infowindow = new google.maps.InfoWindow({
"content": 'Current Location',
"position": latlng,
}).open(self.map, currentLocationMarker);*/
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent('Current Location');
infoWindow.open(self.map, currentLocationMarker);
};

self.findMarkerById = function(id) {
Expand Down Expand Up @@ -202,14 +200,18 @@ CroutonMap.prototype.render = function(domElementName) {
self.domElementName = domElementName;
this.loadGapi('croutonMap.renderMap');
}
CroutonMap.prototype.reload = function(meetingData, formatsData) {
this.meetingData = meetingData;
this.formatsData = formatsData;
}
CroutonMap.prototype.initialize = function(domElementName, meetingData, formatsData, handlebarMapOptions=null) {
this.meetingData = meetingData;
this.formatsData = formatsData;
this.handlebarMapOptions = handlebarMapOptions;
this.domElementName = domElementName;
this.loadGapi('croutonMap.initMap');
}
CroutonMap.prototype.initMap = function(callback) {
CroutonMap.prototype.initMap = function(callback=null) {
var self = this;
if (self.map == null) {
var mapOpt = { zoom: 3, maxZoom: 17 };
Expand All @@ -220,7 +222,8 @@ CroutonMap.prototype.initMap = function(callback) {
};
self.map = new google.maps.Map(document.getElementById(self.domElementName), mapOpt );
}
self.fillMap(callback);
self.fillMap();
if (callback) callback();
}
CroutonMap.prototype.fillMap = function(filteredIds=null) {
var self = this;
Expand Down

0 comments on commit c41bb2c

Please sign in to comment.