You can not do that.
Export the function first using a module pattern. It is currently private and when you reference it from DOM you need entry point.
Question
Can not invoke the child method from the parent method. Any help is much appreciated.
CHILD METHOD : getPointInfo()
PARENT METHOD : createPolygon()
Can not call a child method from the parent method. Actually child method is in the infoWindow object of google maps API V3.
function createPolygon(polygon) {
var clat = 0;
var clng = 0;
var polygonShape =[];
var content = "<div><label><b>Name : </b></label>"
+ document.getElementById('Name').value
+ '</br><label><b>Region Name : </b></label><input type="text" size="20" id="region_name"/></br><label align="top"><b>Description : </b></label><textarea id="region_desc" cols="20" rows="3"></textarea><br/><input type="button" value="Save Region" onclick="getPointInfo();"/><br/>'
+ '<b>-----INFO-----</b>';
var polygonPath = function() {
var contents = content;
var vert = polygon.getPath();
vert.forEach(function(xy, i) {
var contentString = '<br/><b>Lat :</b> ' + xy.lat().toFixed(6) + '<b>Long : </b>'
+ xy.lng().toFixed(6);
contents = contents + contentString;
clat = xy.lat();
clng = xy.lng();
var vertex = {
"lat" : xy.lat().toFixed(6),
"lng" : xy.lng().toFixed(6)
};
polygonShape.push(vertex);
});
this.infoWindow = new google.maps.InfoWindow({
content : contents,
position : new google.maps.LatLng(clat,clng),
maxWidth : 400
});
drawingTool.setDrawingMode(null);
this.infoWindow.open(map);
};
polygonPath();
function getPointInfo() {
var RegionName = document.getElementById('region_name').value;
var RegionDesc = document.getElementById('region_desc').value;
this.infoWindow.close();
polygonJson = {
data : polygonShape,
regionName : RegionName,
regionDescription : RegionDesc
};
console.log(Object.toJSON(polygonJson));
};
}
Solution
You can not do that.
Export the function first using a module pattern. It is currently private and when you reference it from DOM you need entry point.