User:Jgirault/Kartodeveloper/helpers/GeoJSON.js

(function ( mw, $ ) {

mw.Kartodeveloper.helpers.GeoJSON = (function ( module ) {

module.Point = (function {			var Feature = function  {				this.latitude = null;				this.longitude = null;				this.props = {};				this.customProps = {};			};

Feature.prototype.setLatLng = function ( latitude, longitude ) { this.latitude = latitude; this.longitude = longitude; };

Feature.prototype.setTitle = function ( title ) { this._setProperty( 'title', title ); };

Feature.prototype.setDescription = function ( description ) { this._setProperty( 'description', description ); };

Feature.prototype.setMarkerColor = function ( hexcode ) { this._setProperty( 'marker-color', hexcode ); };

Feature.prototype.setMarkerSize = function ( size ) { this._setProperty( 'marker-size', size ); };

Feature.prototype.setMarkerSymbol = function ( symbol ) { this._setProperty( 'marker-symbol', symbol ); };

Feature.prototype.getProperties = function { return $.extend( {}, this.props, this.customProps ); };

Feature.prototype._setProperty = function ( propName, propValue ) { this.customProps[ propName ] = propValue; };

Feature.prototype._hasProperties = function { return Object.keys( this.customProps ).length > 0 || Object.keys( this.props ).length > 0; };

Feature.prototype.getGeoJSON = function { var feature = this; var geoJson = { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ feature.longitude, feature.latitude ]					}				};

if ( this._hasProperties ) { geoJson.properties = this.getProperties; }

return geoJson; };

return Feature; });

return module; })( {} );

})( mediaWiki, jQuery );