User:Jgirault/Kartodeveloper/helpers/SinglePointMap.js

(function ( mw, $ ) {

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; };

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;

map = kartoBox.map( {					container: that.container,					center: [ +that.latitude, +that.longitude ],					zoom: 11,					allowFullScreen: true				} );

// TODO: this should not be required

// Bind the "ready" hook map.doWhenReady( function {

var 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' );

map.addDataLayer( marker.getGeoJSON ); deferred.resolve; } );			} );

return deferred.promise; };

return Map;

});

})( mediaWiki, jQuery );