0

Eu tenho um construtor e eu queria criar um objeto a partir dele. Mas, ta dando Uncaught TypeError: Map is not a constructor.

Eu só queria saber o porque?

var mapa = null;

    var Map = (function (ol, $) {

        function Map(paramsMap) {
            this.layers = {};
            this.overlayes = {};
            this.olMap = new ol.Map(paramsMap);
        }

        Map.prototype.getResolution = function () {
            return this.olMap.getView().getResolution();
        }

    })(ol, jQuery);

    mapa = new Map({
        target: 'map',
        view: new ol.View({
            center: ol.proj.transform([-51.1, -12.0], 'EPSG:4326', 'EPSG:3857'),
            zoom: 6,
            minZoom: 4,
            maxZoom: 19
        }),
    });

1
  • Escreva sua pergunta em português, vc está no PT Stackoverflow.
    – hugocsl
    6/04/2018 às 20:48

1 Resposta 1

0

Faltou só o return:

var mapa = null;

var Map = (function (ol, $) {

    function Map(paramsMap) {
        this.layers = {};
        this.overlayes = {};
        this.olMap = new ol.Map(paramsMap);
    }

    Map.prototype.getResolution = function () {
        return this.olMap.getView().getResolution();
    }

    //retorno da função
    return Map;

})(ol, jQuery);

mapa = new Map({
    target: 'map',
    view: new ol.View({
        center: ol.proj.transform([-51.1, -12.0], 'EPSG:4326', 'EPSG:3857'),
        zoom: 6,
        minZoom: 4,
        maxZoom: 19
    }),
});
1
  • Aaaaaah, obrigada.
    – Babiruz
    9/04/2018 às 15:27

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .