-
-
Save leviathan/896438 to your computer and use it in GitHub Desktop.
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
// Initialize namespaces --------------------- | |
if (!window.mm) { | |
mm = {}; | |
} | |
// avoid window. use this if you "think" you are in root closure. makes encapsulation possible and code executable without DOM (like node...) | |
if (!this.mm) { | |
mm = {}; | |
} | |
// or (freaky) don't try to understand! ;) | |
mm = this.mm || {}; | |
// Writing constructors or general functions in namespace: | |
// Instead: | |
function MapEditor(mapContainerId) { | |
// private properties | |
var i18n = null; | |
var googleMapOptions = { | |
... | |
// do: | |
mm.MapEditor = function(mapContainerId) { | |
... | |
instance = new mm.MapEditor(...) | |
// var xy; is only local to current function call, but all called functions get it too! | |
// From the JS Godfather: http://www.crockford.com/javascript/private.html | |
// How to make a Polyline editable with draggable edges | |
function ExtPolyline() { | |
// delegate instead of subclasses, because subclasses of google's polyline don't work too well | |
var googlePolyline = new google.maps.Polyline(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment