Skip to content

Commit

Permalink
Nativescript Angular 2 issue while using MapBox inside the HTML #56
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Nov 16, 2016
1 parent f4e8f38 commit 2e2414e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Could be rendered by a definition like this:
</Page>
```

All currently supported options for your XML based map are (__don't__ use other properties!):
All currently supported options for your XML based map are (__don't__ use other properties - if you need styling wrap the map in a `ContentView` and apply things like `width` to that container!):

|option|default|description
|---|---|---
Expand Down
35 changes: 13 additions & 22 deletions mapbox.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,24 @@ var Mapbox = (function (_super) {
Object.defineProperty(Mapbox.prototype, "ios", {
get: function () {
if (!this._ios) {
this._ios = UIView.new();
}
if (!this.mapView && this.config.accessToken) {
var settings = mapbox.merge(this.config, mapbox.defaults);
if (settings.accessToken === undefined) {
setTimeout(function() {
var dialogs = require("ui/dialogs");
dialogs.alert("Please set the 'accessToken' property because now the map will be entirely black :)");
}, 0);
}

MGLAccountManager.setAccessToken(settings.accessToken);

if (settings.delay) {
this._ios = UIView.new();
var that = this;
setTimeout(function() {
that.mapView = MGLMapView.alloc().initWithFrameStyleURL(CGRectMake(0, 0, that._ios.frame.size.width, that._ios.frame.size.height), mapbox._getMapStyle(settings.style));
that.mapView.delegate = that._delegate = MGLMapViewDelegateImpl.new().initWithCallback(function() {});
mapbox._setMapboxMapOptions(that.mapView, settings);
that._ios.addSubview(that.mapView);
that.notifyMapReady();
}, settings.delay);
var that = this;

} else {
this._ios = this.mapView = MGLMapView.alloc().initWithFrameStyleURL(CGRectMake(0, 0, 1, 1), mapbox._getMapStyle(settings.style));
this._ios.delegate = this._delegate = MGLMapViewDelegateImpl.new().initWithCallback(function() {});
mapbox._setMapboxMapOptions(this._ios, settings);
this.notifyMapReady();
}
var drawMap = function() {
that.mapView = MGLMapView.alloc().initWithFrameStyleURL(CGRectMake(0, 0, that._ios.frame.size.width, that._ios.frame.size.height), mapbox._getMapStyle(settings.style));
that.mapView.delegate = that._delegate = MGLMapViewDelegateImpl.new().initWithCallback(function() {});
mapbox._setMapboxMapOptions(that.mapView, settings);
that._ios.addSubview(that.mapView);
that.notifyMapReady();
};

setTimeout(drawMap, settings.delay);
}
return this._ios;
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-mapbox",
"version": "2.2.3",
"version": "2.2.4",
"description": "Native Maps, by Mapbox.",
"main": "mapbox.js",
"typings": "mapbox.d.ts",
Expand Down

0 comments on commit 2e2414e

Please sign in to comment.