Yubin Qiu Yubin Qiu - 5 months ago 26
Javascript Question

Javascript - Returning a value from google map click listener event

I have integrated the 'overlapping marker spiderfier'

https://github.com/jawj/OverlappingMarkerSpiderfier

http://jawj.github.io/OverlappingMarkerSpiderfier/bin/oms.js

However I am trying to get a value upon click. Here is my initialized code.

oms.addListener('click', function(marker, event)
{
console.log("Hello")
}


The code above currently works in this order to my knowledge.

1) On click, it passes the marker and event to the source file.

2) All clustered marker within the set radius will split

3) Click on the separated marker and it loads "Hello"




What I want is.

1) Invoke a click event on load and passes the marker and event to the source file -> Clustered marker within the set radius will split (OnLoad)

2) Click on the separated marker and it loads "Hello"

Answer

Maybe I misunderstood, but something like this should do the trick :

One.js

var a = 1;
var b = 2;
var calc = new calculator();
console.log(calc.add(a, b));

Two.js

this['calculator'] = (function() {
      function add(a, b) {
           return a+b;
      }
}