Home » Javascript » Uncaught TypeError in google map api's common.js library

Uncaught TypeError in google map api's common.js library

Posted by: admin June 30, 2018 Leave a comment

Questions:
var myGoogleMap = (function () {
    return {
        init: function (widget) {
            myPage.onReady(window, "google", function () {
                var container = widget.find(".google-map-container");
                var configs = container.config("map");
                if (container.is(".initialized")) {
                    return;
                }
                container.loader(false)
                var myCenter = new google.maps.LatLng(+configs.lat, +configs.lng);
                var map = new google.maps.Map(container[0], {
                    center: myCenter,
                    zoom: configs.zoom,
                    mapTypeId: 'roadmap'
                });
                if(configs.radius) {
                    var circle = new google.maps.Circle({
                        center: myCenter,
                        radius: configs.radius,
                        strokeColor: "#005b9a",
                        strokeOpacity: 0.5,
                        strokeWeight: 1,
                        fillColor: "#5094f0",
                        fillOpacity: 0.2
                    });
                    circle.setMap(map);
                }
                var marker = new google.maps.Marker({
                    position: myCenter,
                    icon: configs.pin ? app.baseUrl + configs.pin : undefined
                });
                marker.setMap(map);
                var popupText = widget.find(".popup-text").val()
                if(popupText) {
                    var infoWindow = new google.maps.InfoWindow({
                        content: popupText
                    });
                    marker.addListener('click', function() {
                        infoWindow.open(map, marker);
                    });
                }
                container.addClass("initialized")
            });
        }
    }
})();

$(function () {
    $(".widget-googleMap").each(function () {
        myGoogleMap.init($(this))
    })
});
Answers: