Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions packages/rocketchat-mapview/client/mapview.coffee

This file was deleted.

27 changes: 27 additions & 0 deletions packages/rocketchat-mapview/client/mapview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* MapView is a named function that will replace geolocation in messages with a Google Static Map
* @param {Object} message - The message object
*/

function MapView(message) {

// get MapView settings
const mv_googlekey = RocketChat.settings.get('MapView_GMapsAPIKey');

if (message.location) {

// GeoJSON is reversed - ie. [lng, lat]
const [longitude, latitude] = message.location.coordinates;

// confirm we have an api key set, and generate the html required for the mapview
if (mv_googlekey && mv_googlekey.length) {
message.html = `<a href="https://maps.google.com/maps?daddr=${ latitude },${ longitude }" target="_blank"><img src="https://maps.googleapis.com/maps/api/staticmap?zoom=14&size=250x250&markers=color:gray%7Clabel:%7C${ latitude },${ longitude }&key=${ mv_googlekey }" /></a>`;
} else {
message.html = `<a href="https://maps.google.com/maps?daddr=${ latitude },${ longitude }" target="_blank">${ TAPi18n.__('Shared_Location') }</a>`;
}
}

return message;
}

RocketChat.callbacks.add('renderMessage', MapView, RocketChat.callbacks.priority.HIGH);
5 changes: 2 additions & 3 deletions packages/rocketchat-mapview/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Package.describe({
Package.onUse(function(api) {
api.use([
'ecmascript',
'coffeescript',
'rocketchat:lib'
]);

api.addFiles('server/settings.coffee', 'server');
api.addFiles('server/settings.js', 'server');

api.addFiles('client/mapview.coffee', 'client');
api.addFiles('client/mapview.js', 'client');

});
3 changes: 0 additions & 3 deletions packages/rocketchat-mapview/server/settings.coffee

This file was deleted.

4 changes: 4 additions & 0 deletions packages/rocketchat-mapview/server/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Meteor.startup(function() {
RocketChat.settings.add('MapView_Enabled', false, {type: 'boolean', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_Enabled', i18nDescription: 'MapView_Enabled_Description'});
return RocketChat.settings.add('MapView_GMapsAPIKey', '', {type: 'string', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_GMapsAPIKey', i18nDescription: 'MapView_GMapsAPIKey_Description'});
});