Skip to content

Commit

Permalink
set the clickable area of a marker in google maps
Browse files Browse the repository at this point in the history
* the marker icons we use have a transparent fill in the bottom half of their image
  (the pointy part of the pin icon is in the center of the marker image, and there
   is a shadow "beneath" the pin that extends a bit below the pin's point).

* this change tells google maps to not change the mouse cursor when the mouse is
  hovering over that bottom half of the marker's icon (in that mostly transparent region)

* this isn't a fix for #301 but is sort of related; may help when markers are near
  bottom of screen
  • Loading branch information
techieshark committed Dec 1, 2016
1 parent 4dec958 commit 1494c57
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion js/geo/M.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,20 @@ app.M = (function() {
};

function GoogleMarker (latLng, options) {
this.marker = new google.maps.Marker({draggable: options.draggable});

var icon = options.icon;
var iconSize = L.point(icon.options.iconSize);
var iconWidth = iconSize.x;
var iconHeight = iconSize.y;

this.marker = new google.maps.Marker({
draggable: options.draggable,
// shape: "defines the clickable region of a marker image" - GMaps API
shape: {
type: "rect",
coords: [0, 0, iconWidth, iconHeight / 2], // only top half of Maki icon is the visible marker
}
});

// this.marker.infoWindow = null;
this.marker.setPosition(latLng);
Expand Down

0 comments on commit 1494c57

Please sign in to comment.