Skip to content

Commit

Permalink
fix(#21): Regression introduced in #16 - we weren't wiriing up showin…
Browse files Browse the repository at this point in the history
…g the "InfoWindow" with the location details.

Close #21
  • Loading branch information
toepoke committed Feb 17, 2024
1 parent bd2f442 commit a4755d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
17 changes: 0 additions & 17 deletions examples/03-add-places-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ function runExample3() {
allowAdd: true,
disablePoi: true,

// Illustrating custom behaviour
// ... changing the added marker to have _some_data_
onAdd: function (m, marker) {
// note marker has "lat" and "lng" properties to use for querying google maps
marker.details.name = "Test name";
marker.details.street = "Test street";
marker.details.town = "Test town";
marker.details.area = "Test area";
marker.details.postCode = "Test postcode";
marker.details.country = "Test country";
marker.details.telNo = "Test telNo";
marker.details.website = "example.com";
marker.details.url = "http://example.com";
// pass control back to mapsed
m.showAddDialog(marker);
},

// Enables edit of custom places (to your web application, not Google Maps!)
// ... again the presence of the callback enables the functionality
onSave: function(m, newPlace) {
Expand Down
16 changes: 13 additions & 3 deletions mapsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,22 +485,31 @@
} // onPlaceEdit


/**
* Event handler for when a marker is added to the map, either
* as a new marker, or when an existing marker is added to the map.
* Shows the infoWindow for the location.
* @param {any} evt
*/
function onMarkerSelect(evt) {
var canEdit = false;
var currMarker = this;
closeTooltips();

if (currMarker.details.markerType == "new") {
canEdit = true;
if (settings.onAdd) {
settings.onAdd(_plugIn, currMarker);
}
} else {
// Custom places user has previously added can be edited
// Google places ones can't (for hopefully obvious reasons!)
var canEdit = (currMarker.details.markerType == "custom");
currMarker.showTooltip(false);
canEdit = (currMarker.details.markerType == "custom");
}

}
currMarker.showTooltip(canEdit);
}


/// <summary>
/// Internal event handler when the "Add" button is clicked
Expand All @@ -527,6 +536,7 @@
tip.find(".mapsed-lat").val(currMarker.details.lat);
tip.find(".mapsed-lng").val(currMarker.details.lng);
});

// for tooltip to be displayed
gm.event.trigger(newMarker, "click");

Expand Down

0 comments on commit a4755d8

Please sign in to comment.