@nativescript-community/ui-mapbox 7.0.0-alpha.14.3191a7b → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/common.d.ts +18 -2
- package/common.js +9 -2
- package/expression/expression-parser.ios.d.ts +2 -2
- package/expression/expression-parser.ios.js +28 -13
- package/index.android.d.ts +5 -12
- package/index.android.js +11 -97
- package/index.ios.d.ts +68 -241
- package/index.ios.js +1171 -2001
- package/layers/layer-factory.ios.d.ts +7 -7
- package/layers/layer-factory.ios.js +46 -100
- package/layers/parser/property-parser.d.ts +1 -1
- package/layers/parser/property-parser.ios.d.ts +0 -2
- package/layers/parser/property-parser.ios.js +0 -149
- package/markers/Marker.android.d.ts +0 -7
- package/markers/Marker.android.js +7 -81
- package/markers/Marker.common.d.ts +2 -0
- package/markers/Marker.common.js +31 -0
- package/markers/MarkerManager.android.d.ts +7 -0
- package/markers/MarkerManager.android.js +88 -22
- package/package.json +3 -3
- package/platforms/ios/Podfile +3 -1
- package/platforms/ios/Resources/default_pin.png +0 -0
- package/platforms/ios/src/MapboxBridge.swift +1505 -0
- package/platforms/ios/src/NativeExpressionParser.swift +33 -0
- package/platforms/ios/src/NativeLayerFactory.swift +108 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/typings/Mapbox.ios.d.ts +2 -3242
- package/typings/mapbox.android.d.ts +7177 -5481
- package/typings/mapbox.bridge.ios.d.ts +128 -0
- package/platforms/android/ui_mapbox.aar +0 -0
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { LayerCommon, LayerType } from '../common';
|
|
2
|
-
export declare class LayerFactory {
|
|
3
|
-
static createLayer(style: any, source: any): Promise<LayerCommon>;
|
|
4
|
-
private static parseProperties;
|
|
5
|
-
}
|
|
6
2
|
export declare class Layer implements LayerCommon {
|
|
3
|
+
mapboxView: MapView;
|
|
7
4
|
id: string;
|
|
8
|
-
|
|
9
|
-
constructor(instance: MGLStyleLayer);
|
|
10
|
-
type(): LayerType;
|
|
5
|
+
constructor(mapboxView: MapView, id: string);
|
|
11
6
|
visibility(): boolean;
|
|
12
7
|
show(): void;
|
|
13
8
|
hide(): void;
|
|
@@ -16,4 +11,9 @@ export declare class Layer implements LayerCommon {
|
|
|
16
11
|
getFilter(): any[];
|
|
17
12
|
setProperty(name: string, value: any): void;
|
|
18
13
|
getProperty(name: string): any;
|
|
14
|
+
type(): LayerType;
|
|
15
|
+
}
|
|
16
|
+
export declare class LayerFactory {
|
|
17
|
+
static createLayer(mapboxView: MapView, style: any, belowLayerId: string): Promise<LayerCommon>;
|
|
18
|
+
static applyLayerProperties(mapboxView: MapView, layer: any, properties: Record<string, any>): void;
|
|
19
19
|
}
|
|
@@ -1,120 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
switch (style.type) {
|
|
7
|
-
case 'line':
|
|
8
|
-
nativeLayer = MGLLineStyleLayer.alloc().initWithIdentifierSource(style.id, source);
|
|
9
|
-
break;
|
|
10
|
-
case 'circle':
|
|
11
|
-
nativeLayer = MGLCircleStyleLayer.alloc().initWithIdentifierSource(style.id, source);
|
|
12
|
-
break;
|
|
13
|
-
case 'fill':
|
|
14
|
-
nativeLayer = MGLFillStyleLayer.alloc().initWithIdentifierSource(style.id, source);
|
|
15
|
-
break;
|
|
16
|
-
case 'symbol':
|
|
17
|
-
nativeLayer = MGLSymbolStyleLayer.alloc().initWithIdentifierSource(style.id, source);
|
|
18
|
-
break;
|
|
19
|
-
case 'raster':
|
|
20
|
-
nativeLayer = MGLRasterStyleLayer.alloc().initWithIdentifierSource(style.id, source);
|
|
21
|
-
break;
|
|
22
|
-
default:
|
|
23
|
-
throw new Error(`Unknown layer type: ${style.type}`);
|
|
24
|
-
}
|
|
25
|
-
if (style.minzoom !== undefined) {
|
|
26
|
-
nativeLayer.minimumZoomLevel = style.minzoom;
|
|
27
|
-
}
|
|
28
|
-
if (style.maxzoom !== undefined) {
|
|
29
|
-
nativeLayer.maximumZoomLevel = style.maxzoom;
|
|
30
|
-
}
|
|
31
|
-
if (style['source-layer']) {
|
|
32
|
-
nativeLayer.sourceLayerIdentifier = style['source-layer'];
|
|
33
|
-
}
|
|
34
|
-
const layerProperties = this.parseProperties(style.type, Object.assign(style.paint || {}, style.layout || {})); // TODO: handle defaults
|
|
35
|
-
for (const propKey in layerProperties) {
|
|
36
|
-
if (Object.prototype.hasOwnProperty.call(layerProperties, propKey)) {
|
|
37
|
-
nativeLayer[propKey] = layerProperties[propKey];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const layer = new Layer(nativeLayer);
|
|
41
|
-
return layer;
|
|
42
|
-
}
|
|
43
|
-
static parseProperties(layerType, propertiesObject) {
|
|
44
|
-
return PropertyParser.parsePropertiesForLayer(propertiesObject);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
// src/ui-mapbox/layer-factory.ios.ts
|
|
2
|
+
// TypeScript shim that exports LayerFactory (TS API) while delegating to native NativeLayerFactory when available.
|
|
3
|
+
// This preserves the TS export name 'LayerFactory' as requested.
|
|
4
|
+
import { Trace } from '@nativescript/core';
|
|
5
|
+
import { CLog, CLogTypes } from '../common';
|
|
47
6
|
export class Layer {
|
|
48
|
-
constructor(
|
|
49
|
-
this.
|
|
50
|
-
this.id =
|
|
51
|
-
}
|
|
52
|
-
type() {
|
|
53
|
-
if (this.instance instanceof MGLFillStyleLayer) {
|
|
54
|
-
return 'fill';
|
|
55
|
-
}
|
|
56
|
-
if (this.instance instanceof MGLLineStyleLayer) {
|
|
57
|
-
return 'line';
|
|
58
|
-
}
|
|
59
|
-
if (this.instance instanceof MGLSymbolStyleLayer) {
|
|
60
|
-
return 'symbol';
|
|
61
|
-
}
|
|
62
|
-
if (this.instance instanceof MGLCircleStyleLayer) {
|
|
63
|
-
return 'circle';
|
|
64
|
-
}
|
|
65
|
-
if (this.instance instanceof MGLHeatmapStyleLayer) {
|
|
66
|
-
return 'heatmap';
|
|
67
|
-
}
|
|
68
|
-
if (this.instance instanceof MGLFillExtrusionStyleLayer) {
|
|
69
|
-
return 'fill-extrusion';
|
|
70
|
-
}
|
|
71
|
-
if (this.instance instanceof MGLRasterStyleLayer) {
|
|
72
|
-
return 'raster';
|
|
73
|
-
}
|
|
74
|
-
if (this.instance instanceof MGLHillshadeStyleLayer) {
|
|
75
|
-
return 'hillshade';
|
|
76
|
-
}
|
|
77
|
-
if (this.instance instanceof MGLBackgroundStyleLayer) {
|
|
78
|
-
return 'background';
|
|
79
|
-
}
|
|
80
|
-
// there is no sky layer in the Mapbox iOS SDK
|
|
81
|
-
return null;
|
|
7
|
+
constructor(mapboxView, id) {
|
|
8
|
+
this.mapboxView = mapboxView;
|
|
9
|
+
this.id = id;
|
|
82
10
|
}
|
|
83
11
|
visibility() {
|
|
84
|
-
return
|
|
12
|
+
return true;
|
|
85
13
|
}
|
|
86
14
|
show() {
|
|
87
|
-
this.
|
|
15
|
+
NativeLayerFactory.setLayerVisibility(this.mapboxView, this.id, true);
|
|
88
16
|
}
|
|
89
17
|
hide() {
|
|
90
|
-
this.
|
|
18
|
+
NativeLayerFactory.setLayerVisibility(this.mapboxView, this.id, false);
|
|
91
19
|
}
|
|
92
20
|
getNativeInstance() {
|
|
93
|
-
return
|
|
21
|
+
return null;
|
|
94
22
|
}
|
|
95
23
|
setFilter(filter) {
|
|
96
|
-
|
|
97
|
-
// MGLVectorStyleLayer is the base type of many layer types. Predicates only supported on vector style layers.
|
|
98
|
-
// See https://docs.mapbox.com/ios/maps/api/6.3.0/Classes/MGLVectorStyleLayer.html
|
|
99
|
-
this.instance.predicate = ExpressionParser.parseJson(filter);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
throw new Error('Set filter only support for vector layer.');
|
|
103
|
-
}
|
|
24
|
+
// Not implemented here - recommend using addLayer with JSON via Mapbox.addLayer
|
|
104
25
|
}
|
|
105
26
|
getFilter() {
|
|
106
|
-
return
|
|
27
|
+
return null;
|
|
107
28
|
}
|
|
108
29
|
setProperty(name, value) {
|
|
109
|
-
|
|
110
|
-
for (const propKey in properties) {
|
|
111
|
-
if (Object.prototype.hasOwnProperty.call(properties, propKey)) {
|
|
112
|
-
this.instance[propKey] = properties[propKey];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
30
|
+
NativeLayerFactory.setLayerProperty(this.mapboxView, this.id, name, value);
|
|
115
31
|
}
|
|
116
32
|
getProperty(name) {
|
|
117
|
-
return
|
|
33
|
+
return NativeLayerFactory.getLayerProperty(this.mapboxView, this.id, name);
|
|
34
|
+
}
|
|
35
|
+
type() {
|
|
36
|
+
return NativeLayerFactory.getLayerType(this.mapboxView, this.id);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Export a TS LayerFactory that matches the old TS API but delegates to NativeLayerFactory
|
|
40
|
+
export class LayerFactory {
|
|
41
|
+
static async createLayer(mapboxView, style, belowLayerId) {
|
|
42
|
+
const styleJson = typeof style === 'string' ? style : JSON.stringify(style);
|
|
43
|
+
if (Trace.isEnabled()) {
|
|
44
|
+
CLog(CLogTypes.info, 'createLayer:', belowLayerId, JSON.stringify(style));
|
|
45
|
+
}
|
|
46
|
+
const id = style.id || 'layer_' + Date.now();
|
|
47
|
+
if (NativeLayerFactory.createLayer(mapboxView, id, styleJson, belowLayerId)) {
|
|
48
|
+
return new Layer(mapboxView, id);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error('failed to create layer');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static applyLayerProperties(mapboxView, layer, properties) {
|
|
55
|
+
try {
|
|
56
|
+
// NativeLayerFactory.applyLayerProperties(layer.id, properties);
|
|
57
|
+
// if ((global as any).NativeLayerFactory && (global as any).NativeLayerFactory.setLayerProperty) {
|
|
58
|
+
for (const k of Object.keys(properties)) {
|
|
59
|
+
NativeLayerFactory.setLayerProperty(mapboxView, layer.id, k, properties[k]);
|
|
60
|
+
}
|
|
61
|
+
// }
|
|
62
|
+
}
|
|
63
|
+
catch (e) { }
|
|
118
64
|
}
|
|
119
65
|
}
|
|
120
66
|
//# sourceMappingURL=layer-factory.ios.js.map
|
|
@@ -1,152 +1,3 @@
|
|
|
1
|
-
import { Color } from '@nativescript/core';
|
|
2
|
-
function toCamelCase(s) {
|
|
3
|
-
return s.replace(/([-_][a-z])/gi, ($1) => $1.toUpperCase().replace('-', '').replace('_', ''));
|
|
4
|
-
}
|
|
5
|
-
const styleExtras = {
|
|
6
|
-
// padding
|
|
7
|
-
iconTextFitPadding: {
|
|
8
|
-
iosType: 'edgeinsets'
|
|
9
|
-
},
|
|
10
|
-
// offsets
|
|
11
|
-
iconOffset: {
|
|
12
|
-
iosType: 'vector'
|
|
13
|
-
},
|
|
14
|
-
textOffset: {
|
|
15
|
-
iosType: 'vector'
|
|
16
|
-
},
|
|
17
|
-
lineOffset: {
|
|
18
|
-
iosType: 'vector'
|
|
19
|
-
},
|
|
20
|
-
// translates
|
|
21
|
-
fillTranslate: {
|
|
22
|
-
iosType: 'vector'
|
|
23
|
-
},
|
|
24
|
-
lineTranslate: {
|
|
25
|
-
iosType: 'vector'
|
|
26
|
-
},
|
|
27
|
-
iconTranslate: {
|
|
28
|
-
iosType: 'vector'
|
|
29
|
-
},
|
|
30
|
-
textTranslate: {
|
|
31
|
-
iosType: 'vector'
|
|
32
|
-
},
|
|
33
|
-
circleTranslate: {
|
|
34
|
-
iosType: 'vector'
|
|
35
|
-
},
|
|
36
|
-
fillExtrusionTranslate: {
|
|
37
|
-
iosType: 'vector'
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const keysMap = {
|
|
41
|
-
'circle-pitch-scale': 'circleScaleAlignment',
|
|
42
|
-
'circle-translate': 'circleTranslation',
|
|
43
|
-
'circle-translate-anchor': 'circleTranslationAnchor',
|
|
44
|
-
'fill-antialias': 'fillAntialiased',
|
|
45
|
-
'fill-translate': 'fillTranslation',
|
|
46
|
-
'fill-translate-anchor': 'fillTranslationAnchor',
|
|
47
|
-
'icon-allow-overlap': 'iconAllowsOverlap',
|
|
48
|
-
'icon-keep-upright': 'keepsIconUpright',
|
|
49
|
-
'icon-ignore-placement': 'iconIgnoresPlacement',
|
|
50
|
-
'icon-image': 'iconImageName',
|
|
51
|
-
'icon-rotate': 'iconRotation',
|
|
52
|
-
'icon-rotate-alignment': 'iconRotationAlignment',
|
|
53
|
-
'icon-translate': 'iconTranslation',
|
|
54
|
-
'icon-translate-anchor': 'iconTranslationAnchor',
|
|
55
|
-
'icon-size': 'iconScale',
|
|
56
|
-
'line-translate': 'lineTranslation',
|
|
57
|
-
'line-translate-anchor': 'lineTranslationAnchor',
|
|
58
|
-
'line-dasharray': 'lineDashPattern',
|
|
59
|
-
'text-allow-overlap': 'textAllowsOverlap',
|
|
60
|
-
'text-field': 'text',
|
|
61
|
-
'text-font': 'textFontNames',
|
|
62
|
-
'text-justify': 'textJustification',
|
|
63
|
-
'text-ignore-placement': 'textIgnoresPlacement',
|
|
64
|
-
'text-keep-upright': 'keepsTextUpright',
|
|
65
|
-
'text-max-angle': 'maximumTextAngle',
|
|
66
|
-
'text-max-width': 'maximumTextWidth',
|
|
67
|
-
'text-rotate': 'textRotation',
|
|
68
|
-
'text-rotate-alignment': 'textRotationAlignment',
|
|
69
|
-
'text-size': 'textFontSize',
|
|
70
|
-
'text-translate': 'textTranslation',
|
|
71
|
-
'text-translate-anchor': 'textTranslationAnchor',
|
|
72
|
-
'raster-hue-rotate': 'rasterHueRotation',
|
|
73
|
-
'raster-resampling': 'rasterResamplingMode',
|
|
74
|
-
'raster-brightness-min': 'maximumRasterBrightness',
|
|
75
|
-
'raster-brightness-max': 'minimumRasterBrightness'
|
|
76
|
-
};
|
|
77
|
-
function transformValue(key, value, _styleType) {
|
|
78
|
-
if (_styleType === 'color') {
|
|
79
|
-
const color = value instanceof Color ? value : new Color(value);
|
|
80
|
-
return color.ios;
|
|
81
|
-
}
|
|
82
|
-
else if (_styleType === 'vector') {
|
|
83
|
-
const vector = CGVectorMake(value[0], value[1]);
|
|
84
|
-
return NSExpression.expressionWithMGLJSONObject(NSValue.valueWithCGVector(vector));
|
|
85
|
-
}
|
|
86
|
-
else if (_styleType === 'edgeinsets') {
|
|
87
|
-
const edgeInsets = new UIEdgeInsets({
|
|
88
|
-
top: value[0],
|
|
89
|
-
left: value[1],
|
|
90
|
-
bottom: value[2],
|
|
91
|
-
right: value[3]
|
|
92
|
-
});
|
|
93
|
-
return NSExpression.expressionWithMGLJSONObject(NSValue.valueWithUIEdgeInsets(edgeInsets));
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
switch (key) {
|
|
97
|
-
case 'raster-resampling':
|
|
98
|
-
if (value === 'linear') {
|
|
99
|
-
return 0 /* MGLRasterResamplingMode.Linear */;
|
|
100
|
-
}
|
|
101
|
-
else if (value === 'nearest') {
|
|
102
|
-
return 1 /* MGLRasterResamplingMode.Nearest */;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
default:
|
|
108
|
-
return value;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
1
|
export class PropertyParser {
|
|
113
|
-
static parsePropertiesForLayer(propertiesObject) {
|
|
114
|
-
const nProperties = {};
|
|
115
|
-
if (propertiesObject) {
|
|
116
|
-
Object.keys(propertiesObject).forEach((k) => {
|
|
117
|
-
const actualKey = keysMap[k] || toCamelCase(k);
|
|
118
|
-
const value = propertiesObject[k];
|
|
119
|
-
const rValue = transformValue(k, value, styleExtras[k]?.iosType);
|
|
120
|
-
if (Array.isArray(value)) {
|
|
121
|
-
nProperties[actualKey] = NSExpression.expressionWithMGLJSONObject(rValue);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
nProperties[actualKey] = NSExpression.expressionForConstantValue(rValue);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return nProperties;
|
|
129
|
-
}
|
|
130
|
-
static propertyValueFromLayer(layer, key) {
|
|
131
|
-
const actualKey = keysMap[key] || toCamelCase(key);
|
|
132
|
-
const nValue = layer[actualKey];
|
|
133
|
-
if (!nValue) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
if (nValue.expressionType === 0 /* NSExpressionType.ConstantValueExpressionType */) {
|
|
137
|
-
if (nValue.constantValue instanceof UIColor) {
|
|
138
|
-
return Color.fromIosColor(nValue.constantValue);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
return nValue.constantValue;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
const expressionObj = nValue.mgl_jsonExpressionObject;
|
|
146
|
-
const data = NSJSONSerialization.dataWithJSONObjectOptionsError(expressionObj, 0);
|
|
147
|
-
const expression = NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding);
|
|
148
|
-
return JSON.parse(expression);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
2
|
}
|
|
152
3
|
//# sourceMappingURL=property-parser.ios.js.map
|
|
@@ -7,14 +7,12 @@ export declare class AndroidMarker {
|
|
|
7
7
|
icon: android.graphics.Bitmap;
|
|
8
8
|
title?: string;
|
|
9
9
|
snippet?: string;
|
|
10
|
-
preventNextUpdateOffsetX?: boolean;
|
|
11
10
|
pointAnnotation: com.mapbox.maps.plugin.annotation.generated.PointAnnotation;
|
|
12
11
|
viewAnnotation: android.view.View;
|
|
13
12
|
view: StackLayout;
|
|
14
13
|
anchor: com.mapbox.maps.ViewAnnotationAnchorConfig;
|
|
15
14
|
layerId: string;
|
|
16
15
|
prepared: boolean;
|
|
17
|
-
private static readonly MARKER_PADDING_PX;
|
|
18
16
|
constructor(opts: {
|
|
19
17
|
position: com.mapbox.geojson.Point;
|
|
20
18
|
icon: android.graphics.Bitmap;
|
|
@@ -26,10 +24,5 @@ export declare class AndroidMarker {
|
|
|
26
24
|
*/
|
|
27
25
|
prepareAnnotationMarker(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager, layerId: string): void;
|
|
28
26
|
update(pointAnnotationManager: com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager): void;
|
|
29
|
-
/**
|
|
30
|
-
* Build a NativeScript view to use as info window.
|
|
31
|
-
* Then attach it to Mapbox via ViewAnnotationManager.
|
|
32
|
-
*/
|
|
33
|
-
prepareViewAnnotation(mapView: com.mapbox.maps.MapView, onInfoWindowClick: any): void;
|
|
34
27
|
destroy(): void;
|
|
35
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Trace } from '@nativescript/core';
|
|
2
2
|
import { CLog, CLogTypes } from '../common';
|
|
3
3
|
/**
|
|
4
4
|
* Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window.
|
|
@@ -38,91 +38,17 @@ export class AndroidMarker {
|
|
|
38
38
|
// 2. Update the annotation via the manager
|
|
39
39
|
pointAnnotationManager.update(this.pointAnnotation);
|
|
40
40
|
if (this.view) {
|
|
41
|
-
this.view.getViewById('title')
|
|
42
|
-
|
|
41
|
+
const title = this.view.getViewById('title');
|
|
42
|
+
title.text = this?.title || '';
|
|
43
|
+
const subtitle = this.view.getViewById('subtitle');
|
|
44
|
+
subtitle.text = this?.snippet;
|
|
45
|
+
subtitle.visibility = this?.snippet ? 'visible' : 'collapse';
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Build a NativeScript view to use as info window.
|
|
47
|
-
* Then attach it to Mapbox via ViewAnnotationManager.
|
|
48
|
-
*/
|
|
49
|
-
prepareViewAnnotation(mapView, onInfoWindowClick) {
|
|
50
|
-
// --- Step 1: Create a NativeScript view tree
|
|
51
|
-
const view = new StackLayout();
|
|
52
|
-
view.className = 'info-window';
|
|
53
|
-
view.padding = AndroidMarker.MARKER_PADDING_PX;
|
|
54
|
-
view.backgroundColor = '#FFFFFF';
|
|
55
|
-
view.width = 'auto'; // WRAP_CONTENT
|
|
56
|
-
view.height = 'auto'; // WRAP_CONTENT
|
|
57
|
-
view.borderRadius = 12;
|
|
58
|
-
view['shadowColor'] = '#000';
|
|
59
|
-
view['shadowOpacity'] = 0.25;
|
|
60
|
-
view['shadowRadius'] = 8;
|
|
61
|
-
if (this.title) {
|
|
62
|
-
const titleLabel = new Label();
|
|
63
|
-
titleLabel.id = 'title';
|
|
64
|
-
titleLabel.text = this.title;
|
|
65
|
-
titleLabel.className = 'info-window-title';
|
|
66
|
-
titleLabel.fontSize = 16;
|
|
67
|
-
titleLabel.fontWeight = 'bold';
|
|
68
|
-
view.addChild(titleLabel);
|
|
69
|
-
}
|
|
70
|
-
if (this.snippet) {
|
|
71
|
-
const snippetLabel = new Label();
|
|
72
|
-
snippetLabel.id = 'snippet';
|
|
73
|
-
snippetLabel.text = this.snippet;
|
|
74
|
-
snippetLabel.className = 'info-window-snippet';
|
|
75
|
-
snippetLabel.fontSize = 14;
|
|
76
|
-
snippetLabel.color = new Color('#555');
|
|
77
|
-
view.addChild(snippetLabel);
|
|
78
|
-
}
|
|
79
|
-
view._setupAsRootView(Utils.android.getApplicationContext());
|
|
80
|
-
view.parent = Application.getRootView();
|
|
81
|
-
view._isAddedToNativeVisualTree = true;
|
|
82
|
-
view.callLoaded();
|
|
83
|
-
const nativeView = view.nativeViewProtected;
|
|
84
|
-
view.on('tap', onInfoWindowClick);
|
|
85
|
-
const frameLayout = new android.widget.FrameLayout(view._context);
|
|
86
|
-
const layoutParams = new android.widget.FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
87
|
-
frameLayout.addView(nativeView);
|
|
88
|
-
frameLayout.setLayoutParams(layoutParams);
|
|
89
|
-
frameLayout.measure(android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED), android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED));
|
|
90
|
-
frameLayout.layout(0, 0, nativeView.getMeasuredWidth(), nativeView.getMeasuredHeight());
|
|
91
|
-
// frameLayout.setLayoutParams(new android.widget.FrameLayout.LayoutParams(nativeView.getMeasuredWidth(), nativeView.getMeasuredHeight()));
|
|
92
|
-
// --- Step 3: Prepare view annotation options
|
|
93
|
-
const ViewAnnotationAnchor = com.mapbox.maps.ViewAnnotationAnchor;
|
|
94
|
-
const anchor = new com.mapbox.maps.ViewAnnotationAnchorConfig.Builder()
|
|
95
|
-
.anchor(ViewAnnotationAnchor.BOTTOM)
|
|
96
|
-
.offsetY((this.pointAnnotation.getIconImageBitmap()?.getHeight() ?? 0) + AndroidMarker.MARKER_PADDING_PX)
|
|
97
|
-
.build();
|
|
98
|
-
this.anchor = anchor;
|
|
99
|
-
const viewAnnotationOptions = new com.mapbox.maps.ViewAnnotationOptions.Builder()
|
|
100
|
-
.visible(java.lang.Boolean.valueOf(true))
|
|
101
|
-
// .allowOverlap(java.lang.Boolean.valueOf(true))
|
|
102
|
-
// .width(java.lang.Double.valueOf(frameLayout.getMeasuredWidth()))
|
|
103
|
-
// .height(java.lang.Double.valueOf(frameLayout.getMeasuredHeight()))
|
|
104
|
-
.allowOverlapWithPuck(java.lang.Boolean.valueOf(true))
|
|
105
|
-
.ignoreCameraPadding(java.lang.Boolean.valueOf(true))
|
|
106
|
-
// .priority(java.lang.Long.valueOf(0))
|
|
107
|
-
.selected(java.lang.Boolean.valueOf(true))
|
|
108
|
-
.annotatedFeature(com.mapbox.maps.AnnotatedFeature.valueOf(this.pointAnnotation.getGeometry()))
|
|
109
|
-
.variableAnchors(java.util.Arrays.asList([anchor]))
|
|
110
|
-
.build();
|
|
111
|
-
// --- Step 4: Add the view to Mapbox’s ViewAnnotationManager
|
|
112
|
-
com.nativescript.mapbox.ViewAnnotationManager.addViewAnnotation(mapView, frameLayout, viewAnnotationOptions);
|
|
113
|
-
// --- Step 5: Store references
|
|
114
|
-
this.viewAnnotation = frameLayout;
|
|
115
|
-
this.view = view;
|
|
116
|
-
this.prepared = true;
|
|
117
|
-
}
|
|
118
48
|
destroy() {
|
|
119
|
-
|
|
120
|
-
this.view._tearDownUI();
|
|
121
|
-
this.view = null;
|
|
122
|
-
}
|
|
49
|
+
this.view = null;
|
|
123
50
|
this.viewAnnotation = null;
|
|
124
51
|
this.icon = null;
|
|
125
52
|
}
|
|
126
53
|
}
|
|
127
|
-
AndroidMarker.MARKER_PADDING_PX = 10;
|
|
128
54
|
//# sourceMappingURL=Marker.android.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Color, Label, StackLayout } from '@nativescript/core';
|
|
2
|
+
const MARKER_PADDING_PX = 10;
|
|
3
|
+
export function createInfoWindowView(title, snippet) {
|
|
4
|
+
const view = new StackLayout();
|
|
5
|
+
view.className = 'mapbox-info-window';
|
|
6
|
+
view.padding = MARKER_PADDING_PX;
|
|
7
|
+
view.backgroundColor = 'white';
|
|
8
|
+
view.width = 'auto'; // WRAP_CONTENT
|
|
9
|
+
view.height = 'auto'; // WRAP_CONTENT
|
|
10
|
+
view.borderRadius = 12;
|
|
11
|
+
view['shadowColor'] = '#000';
|
|
12
|
+
view['shadowOpacity'] = 0.25;
|
|
13
|
+
view['shadowRadius'] = 8;
|
|
14
|
+
const titleLabel = new Label();
|
|
15
|
+
titleLabel.id = 'title';
|
|
16
|
+
titleLabel.text = title;
|
|
17
|
+
titleLabel.className = 'mapbox-info-window-title';
|
|
18
|
+
titleLabel.fontSize = 16;
|
|
19
|
+
titleLabel.fontWeight = 'bold';
|
|
20
|
+
view.addChild(titleLabel);
|
|
21
|
+
const subtitle = new Label();
|
|
22
|
+
subtitle.id = 'subtitle';
|
|
23
|
+
subtitle.text = snippet;
|
|
24
|
+
subtitle.className = 'mapbox-info-window-snippet';
|
|
25
|
+
subtitle.fontSize = 14;
|
|
26
|
+
// subtitle.visibility = snippet ? 'visible' : 'collapse';
|
|
27
|
+
subtitle.color = new Color('#555');
|
|
28
|
+
view.addChild(subtitle);
|
|
29
|
+
return view;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Marker.common.js.map
|
|
@@ -3,6 +3,7 @@ import { AndroidMarker } from './Marker.android';
|
|
|
3
3
|
* MarkerManager (Native Android Mapbox SDK version)
|
|
4
4
|
*/
|
|
5
5
|
export declare class MarkerManager {
|
|
6
|
+
private static readonly MARKER_PADDING_PX;
|
|
6
7
|
private mapView;
|
|
7
8
|
private map;
|
|
8
9
|
private pointAnnotationManager;
|
|
@@ -11,6 +12,7 @@ export declare class MarkerManager {
|
|
|
11
12
|
private static readonly ADDITIONAL_EDGE_PADDING_PX;
|
|
12
13
|
private selectedMarker;
|
|
13
14
|
private onInfoWindowTapped;
|
|
15
|
+
private _reusableCalloutView;
|
|
14
16
|
private onMapClickListener;
|
|
15
17
|
private onPointClickListener;
|
|
16
18
|
onViewAnnotationUpdatedListener: com.mapbox.maps.viewannotation.OnViewAnnotationUpdatedListener;
|
|
@@ -19,6 +21,11 @@ export declare class MarkerManager {
|
|
|
19
21
|
adjustViewAnnotationXOffset(marker: AndroidMarker): void;
|
|
20
22
|
updateMarker(marker: AndroidMarker): void;
|
|
21
23
|
addMarker(marker: AndroidMarker): AndroidMarker;
|
|
24
|
+
/**
|
|
25
|
+
* Build a NativeScript view to use as info window.
|
|
26
|
+
* Then attach it to Mapbox via ViewAnnotationManager.
|
|
27
|
+
*/
|
|
28
|
+
prepareViewAnnotation(marker: AndroidMarker, onInfoWindowClick: any): void;
|
|
22
29
|
removeMarker(marker: AndroidMarker): void;
|
|
23
30
|
selectMarker(marker: AndroidMarker, deselectIfSelected?: boolean, update?: boolean): void;
|
|
24
31
|
deselectMarker(marker: AndroidMarker): void;
|