User:Jgirault/Kartodeveloper/helpers/SinglePointMap.js

(function ( mw, $ ) {

var mapId = 0; mw.Kartodeveloper.helpers.SinglePointMap = (function {

var Map = function ( container, latitude, longitude, options ) { this.container = container; this.latitude = latitude; this.longitude = longitude; this.options = options || {}; this.map = null; this.mapId = mapId++; };

Map.prototype.draw = function { var deferred = $.Deferred, that = this;

mw.loader.using( [ 'ext.kartographer.style', 'ext.kartographer.box' ], function {

var kartoBox = mw.loader.require( 'ext.kartographer.box' ), map, dataGroups = {}, marker; marker = new mw.Kartodeveloper.helpers.GeoJSON.Point; marker.setLatLng( that.latitude, that.longitude ); if ( that.options.title ) { marker.setTitle( that.options.title ); }				if ( that.options.description ) { marker.setDescription( that.options.description ); }				marker.setMarkerColor( '3366cc' ); dataGroups[ 'SinglePointMap' + that.mapId ] = marker.getGeoJSON;

mw.config.set( 'wgKartographerLiveData', 					$.extend( mw.config.get( 'wgKartographerLiveData' ) || {}, dataGroups )				); map = kartoBox.map( {					container: that.container,					center: [ +that.latitude, +that.longitude ],					zoom: 11,					dataGroups: [ 'SinglePointMap' + that.mapId ],					allowFullScreen: true				} );

deferred.resolve; } );

return deferred.promise; };

return Map;

});

})( mediaWiki, jQuery );