Skip to content

Commit

Permalink
Adds options to enable/disable map controls
Browse files Browse the repository at this point in the history
(zoombar, scalebar, mapsettings)
  • Loading branch information
mmarcon committed Nov 20, 2015
1 parent e7249e9 commit 73d4e9e
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 96 deletions.
6 changes: 3 additions & 3 deletions dist/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
<div id="map" class="map"></div>
<div id="other_map" class="map"></div>

<script src="https://cdn.rawgit.com/mmarcon/jhere/jsla3/dist/jhere.min.js"></script>
<script src="../out/jhere.js"></script>
<script>
/* globals jHERE: true */
var map = jHERE(document.querySelector('#map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}})
var map = jHERE(document.querySelector('#map'), {zoom: 14, center: {lat: 52.5, lng: 18.3}})
.zoom(10).type('terrain', 'base').marker({lat: 52.5, lng: 13.3}, {tap: function() {
map.bubble(this.getPosition(), {content: 'foo', onclose: function(){console.log('closed');}});
}}).on('tap', function(e){
console.log(e.geo);
});
jHERE(document.querySelector('#other_map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}}).zoom(15);
jHERE(document.querySelector('#other_map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}, enable: ['zoombar']}).zoom(15);
</script>
</body>
</html>
140 changes: 90 additions & 50 deletions dist/jhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,84 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _modulesCore = __webpack_require__(1);
__webpack_require__(1);

var _modulesCore = __webpack_require__(2);

var _modulesCore2 = _interopRequireDefault(_modulesCore);

window.jHERE = _modulesCore2['default'];

/***/ },
/* 1 */
/***/ function(module, exports) {

/*
Copyright (c) 2015 Massimiliano Marcon, http://marcon.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

//Object.assign polyfill from
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
'use strict';

if (!Object.assign) {
Object.defineProperty(Object, 'assign', {
enumerable: false,
configurable: true,
writable: true,
value: function value(target) {
'use strict';
if (target === undefined || target === null) {
throw new TypeError('Cannot convert first argument to object');
}

var to = Object(target);
for (var i = 1; i < arguments.length; i++) {
var nextSource = arguments[i];
if (nextSource === undefined || nextSource === null) {
continue;
}
nextSource = Object(nextSource);

var keysArray = Object.keys(nextSource);
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
var nextKey = keysArray[nextIndex];
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
if (desc !== undefined && desc.enumerable) {
to[nextKey] = nextSource[nextKey];
}
}
}
return to;
}
});
}

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

/*
Expand Down Expand Up @@ -114,15 +179,15 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _loader = __webpack_require__(2);
var _loader = __webpack_require__(3);

var _loader2 = _interopRequireDefault(_loader);

var _config = __webpack_require__(3);
var _config = __webpack_require__(4);

var config = _interopRequireWildcard(_config);

var _utils = __webpack_require__(4);
var _utils = __webpack_require__(5);

var d = document;

Expand Down Expand Up @@ -151,7 +216,7 @@
return new jHERE(element, options);
}
this.el = element;
this.options = (0, _utils.extend)(config.defaults, options);
this.options = Object.assign({}, config.defaults, options);
this._init();
};

Expand Down Expand Up @@ -184,14 +249,27 @@
JH._makemap = function () {
var self = this;
var Behavior = H.mapevents.Behavior;
var enabled = self.options.enable;

self.platform = new H.service.Platform({
app_id: self.options.credentials.appId,
app_code: self.options.credentials.authToken,
useHTTPS: true
});
self.layers = self.platform.createDefaultLayers();
self.map = new H.Map(self.el, self.layers.normal.map, self.options);
self.ui = new H.ui.UI(self.map);
self.ui = H.ui.UI.createDefault(self.map, self.layers);

if (! ~enabled.indexOf('zoombar')) {
self.ui.getControl('zoom').setVisibility(false);
}
if (! ~enabled.indexOf('scalebar')) {
self.ui.getControl('scalebar').setVisibility(false);
}
if (! ~enabled.indexOf('settings')) {
self.ui.getControl('mapsettings').setVisibility(false);
}

//TODO: look at the options {enabled: Behavior.DRAGGING, Behavior.WHEELZOOM, Behavior.DBLTAPZOOM}
new Behavior(new H.mapevents.MapEvents(self.map));
self.mc = new H.map.Group();
Expand Down Expand Up @@ -470,7 +548,7 @@
module.exports = exports['default'];

/***/ },
/* 2 */
/* 3 */
/***/ function(module, exports) {

/*
Expand Down Expand Up @@ -548,7 +626,7 @@
module.exports = exports['default'];

/***/ },
/* 3 */
/* 4 */
/***/ function(module, exports) {

/*
Expand Down Expand Up @@ -596,7 +674,8 @@
credentials: defaultCredentials,
zoom: 12,
center: { lat: 52.49, lng: 13.37 },
type: 'map'
type: 'map',
enable: ['zoombar', 'scalebar', 'settings']
};

exports.defaults = defaults;
Expand All @@ -618,56 +697,17 @@
exports.supportedEvents = supportedEvents;

/***/ },
/* 4 */
/* 5 */
/***/ function(module, exports) {

/*
Copyright (c) 2015 Massimiliano Marcon, http://marcon.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.extend = extend;
exports.isFn = isFn;
exports.Runner = Runner;

function extend(target) {
target = target || {};

for (var _len = arguments.length, source = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
source[_key - 1] = arguments[_key];
}

source.forEach(function (s) {
Object.keys(s).forEach(function (k) {
target[k] = s[k];
});
});
return target;
}

function isFn(f) {
return typeof f === 'function';
}
Expand Down
2 changes: 1 addition & 1 deletion dist/jhere.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/jhere.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<script src="../dist/jhere.min.js"></script>
<script>
/* globals jHERE: true */
var map = jHERE(document.querySelector('#map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}})
var map = jHERE(document.querySelector('#map'), {zoom: 14, center: {lat: 52.5, lng: 18.3}})
.zoom(10).type('terrain', 'base').marker({lat: 52.5, lng: 13.3}, {tap: function() {
map.bubble(this.getPosition(), {content: 'foo', onclose: function(){console.log('closed');}});
}}).on('tap', function(e){
console.log(e.geo);
});
jHERE(document.querySelector('#other_map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}}).zoom(15);
jHERE(document.querySelector('#other_map'), {zoom: 14, center: {lat: 52.5, lng: 13.3}, enable: ['zoombar']}).zoom(15);
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jHERE",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Maps made easy.",
"main": "index.js",
"directories": {
Expand Down
Loading

0 comments on commit 73d4e9e

Please sign in to comment.