gulpfile.js:const gulp = require('gulp');
const babel = require('gulp-babel');
const watch = require('gulp-watch');
const rename = require("gulp-rename");
const browserify = require('gulp-browserify');
const babelify = require("babelify");
gulp.task('js', () => {
gulp.src('public/js/dev/app.js')
.pipe(browserify({
transform: ['babelify'],
}))
.pipe(gulp.dest('./public/js'))
});
gulp.task('watch:js', () => {
gulp.watch(['public/js/dev/app.js','public/js/modules/*.js'], ['js']);
});
//...
app.js:var Map = require('../modules/map.js');
var map = new Map('map',[43.2317986,44.749744]);
modules/map.js:class Map
{
constructor(id,arr) {
this.map_id = id;
this.latlong = arr;
this.map = null;
const tinyIcon = L.Icon.extend({
options: {
iconSize: [32, 32],
iconAnchor: [12, 36],
popupAnchor: [0, -30]
}
});
const me = new tinyIcon({ iconUrl: 'https://cdn3.iconfinder.com/data/icons/iconka-buddy-set/128/male_dummy_128.png' });
const guest = new tinyIcon({ iconUrl: 'https://cdn3.iconfinder.com/data/icons/iconka-buddy-set/128/ninja_128.png' });
getLatLong => ( () => {
console.log('asd');
})
// this.map = L.map(this.map_id).setView([latlong[0], latlong[1]], 12);
//
// L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(this.map);
//
// const userMarker = L.marker([56.326944, 44.0075], {
// icon: redIcon
// });
}
setMarker(){
return 0;
}
getLatLong(callback){
navigator.geolocation.getCurrentPosition(position => {
callback(position);
});
}
}
Когда создаю объект класса
Map. Выводит в консоли эту ошибку:
app.js:4 Uncaught TypeError: Map is not a constructor
Вот сам пример на
локальном сервере.