Created
February 5, 2014 13:50
-
-
Save brucemcpherson/8823982 to your computer and use it in GitHub Desktop.
custom code class for googlemapping.xlsm ramblings.mcpher.com
This file contains hidden or 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
function cCustomMapping(options) { | |
// customize one of these for specific behavior during map usage | |
// the functions below must do at least as shown in this skeleton - add your own in addition. | |
var self = this; | |
var pOptions = options, | |
pData, pMap, pParams, pDb; | |
self.getOptions = function () { | |
return pOptions; | |
}; | |
self.setData = function (data) { | |
pData = data; | |
return pData; | |
}; | |
self.getData = function () { | |
return pData; | |
}; | |
self.afterResetBoundingBox = function (bounds) { | |
// called when map size is adjusted to bounds | |
return bounds; | |
}; | |
self.beforeMapRendering = function (myOptions) { | |
// make any map rendering adjustments here | |
return myOptions; | |
}; | |
self.afterMapRendering = function (theMap) { | |
// store map opject | |
pMap = theMap; | |
return pMap; | |
}; | |
self.afterMarkerCreate = function (cj) { | |
// play around with marker info window etc. | |
// here I'm adding an input box to collect comments when infobox | |
var c = document.createElement("div"); | |
c.innerHTML = "Comments"; | |
var ci = document.createElement("input"); | |
ci.setAttribute("id", "cjinput" + cj.childIndex); | |
ci.setAttribute("type", "text"); | |
c.appendChild(ci); | |
// now append this to the existing content | |
var content = cj.infowindow.getContent(); | |
if (content) { | |
content.appendChild(c); | |
} else { | |
content = c; | |
} | |
cj.infowindow.setContent(content); | |
// capture change event - what we'll do here is to update dead drop | |
mcpherAddEvent(ci, "change", function (e) { | |
// we have a change - record the update via the dead drop | |
if (pDb) { | |
pDb.createObject({ | |
uniqueId: cj.uniqueId, | |
type: 'comment', | |
title: cj.title, | |
cj: cj.childIndex, | |
comments: e.srcElement.value | |
}); | |
// empty batch - we'll do it immediately - it'll happen aynch anyway | |
pDb.finalFlush() | |
.done(function (data) {}) | |
.fail(function (data) { | |
alert("failed to flush to deaddrop"); | |
}); | |
} | |
}, false, true); | |
return cj; | |
}; | |
self.setParams = function (qParams) { | |
// play around with parameters | |
pParams = qParams; | |
// we can also get deaddrop key from the data | |
pParams.deaddrop = pParams.deaddrop || self.getData().framework.control.deaddrop; | |
// we'll also open the deaddrop if we need one | |
if (pParams.deaddrop) { | |
pDb = getScriptDb(pParams.deaddrop, "messages"); | |
if (!pDb) { | |
alert("could not get a handle for deaddrop " + pParams.deaddrop); | |
} | |
} | |
return pParams; | |
}; | |
self.getParams = function () { | |
return pParams; | |
}; | |
self.markerOnClick = function (cj) { | |
// when a marker is clicked | |
return cj; | |
}; | |
self.markerAfterClick = function (cj) { | |
// affter a marker click is processed | |
return cj; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment