Created
April 18, 2014 17:41
-
-
Save sconnelley/11055750 to your computer and use it in GitHub Desktop.
Google simple marker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple Google Markers | |
ex: var marker = new stamen.simpleMarker(map,latlng); | |
*/ | |
(function(exports) { | |
var stamen = exports.stamen || (exports.stamen = {}); | |
stamen.simpleMarker = function(map, latlng) { | |
this.div_ = null; | |
this.visible_ = false; | |
this.latlng = latlng; | |
this.setMap(map); | |
} | |
stamen.simpleMarker.prototype = new google.maps.OverlayView(); | |
stamen.simpleMarker.prototype.draw = function() { | |
if (this.visible_) { | |
var proj = this.getProjection(); | |
var pos = proj.fromLatLngToDivPixel(this.latlng); | |
this.div_.style.top = pos.y + 'px'; | |
this.div_.style.left = pos.x + 'px'; | |
} | |
}; | |
stamen.simpleMarker.prototype.onAdd = function() { | |
this.div_ = document.createElement('DIV'); | |
d3.select(this.div_).classed('pulse', true); | |
this.visible_ = true; | |
var panes = this.getPanes(); | |
panes.overlayImage.appendChild(this.div_); | |
this.draw(); | |
}; | |
stamen.simpleMarker.prototype.remove = function() { | |
this.setMap(null); | |
}; | |
// Not sure if this is needed... | |
stamen.simpleMarker.prototype.onRemove = function() { | |
console.log('Marker onRemove.....'); | |
if (this.div_ && this.div_.parentNode) { | |
this.div_.parentNode.removeChild(this.div_); | |
this.div_ = null; | |
this.visible_ = false; | |
} | |
}; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment