Skip to content

Commit fa49346

Browse files
committed
fixed playground, resolve type issues by completing Provider implementation
Signed-off-by: Tim Deubler <[email protected]>
1 parent 18deb88 commit fa49346

16 files changed

+517
-10
lines changed

packages/editor/src/features/area/AreaShape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class AreaShape extends Feature<'Point'> {
286286
}
287287

288288
this.__ = {
289-
area: area,
289+
area,
290290
pointerdown: onMouseDown,
291291
pressmove: moveShape,
292292
pointerup: releaseShape,

packages/editor/src/features/area/HeightKnob.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ class HeightKnob extends Feature<'Point'> {
182182
this.update(this.geometry.coordinates[2]);
183183
this.__.overlay.showFeature(this);
184184
}
185+
186+
getArea(): Area {
187+
return this.__.area;
188+
}
185189
}
186190

187191
export {HeightKnob};

packages/editor/src/features/area/VirtualShape.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {AreaShape} from './AreaShape';
2525
let UNDEF;
2626

2727
export class VirtualAreaShape extends Feature {
28-
private __: { [name: string]: any };
28+
private __: {
29+
area: Area;
30+
[name: string]: any
31+
};
2932

3033
constructor(area: Area, x: number, y: number, indexData: number[], polygonTools) {
3134
const internalEditor: InternalEditor = area._e();
@@ -113,17 +116,15 @@ export class VirtualAreaShape extends Feature {
113116
}
114117

115118
shapePnt.__ = {
116-
119+
area,
117120
pointerdown: onMouseDown,
118-
119121
pressmove: moveAddShape,
120-
121122
pointerup: releaseAddShape,
122-
123123
pointerenter: hoverShapePnt,
124-
125124
pointerleave: hoverShapePnt
126-
127125
};
128126
}
127+
getArea(): Area {
128+
return this.__.area;
129+
}
129130
}

packages/playground/examples/editor/add_contextmenu.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,53 @@ class MyProvider extends SpaceProvider {
8787
writeZLevels(navlink, zLevel) {
8888
navlink.prop('zLevels', zLevel);
8989
}
90+
// #################### Buildings/Extruded Polygons ####################
91+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
92+
93+
// to obtain the height of a Building the respective attribute reader must be implemented.
94+
readFeatureHeight(feature) {
95+
return feature.properties.height;
96+
}
97+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
98+
writeFeatureHeight(feature, heightMeter) {
99+
feature.properties.height = heightMeter;
100+
}
101+
// ######################## Address, Place ########################
102+
// Following functions are only necessary if you want to edit Address or Place.
103+
104+
// In addition to a simple Marker, a Place CAN, while an Address MUST have a routing point.
105+
// A routing point of a Place or Address is a geo position (routingPosition) intended for routing purposes and references
106+
// to a navlink (routingLink).
107+
// In this example, we get routingPosition from features's properties 'routingPoint' and routingLink from 'routingLink'.
108+
109+
// Get coordinate of routing point, its format is: [longitude, latitude, altitude].
110+
// This position should always be on the geometry of referenced Navlink.
111+
readRoutingPosition(feature) {
112+
return feature.prop('routingPoint');
113+
}
114+
// Get id of referenced Navlink for Address or Place. Place becomes floating if this function does not return a Navlink id properly.
115+
readRoutingLink(feature) {
116+
return feature.prop('routingLink');
117+
}
118+
// This function is called to write updated coordinate on referenced Navlink when routing position is changed.
119+
// Format of routing position: [longitude, latitude, altitude].
120+
writeRoutingPosition(feature, position) {
121+
feature.prop('routingPoint', position);
122+
}
123+
// This function is called to write new Navlink reference when routingLink is changed.
124+
// For example, drag routing point from one Navlink to another will change routingLink.
125+
// In this example, Navlink id is updated when routingLink changes.
126+
writeRoutingLink(feature, navlink) {
127+
feature.prop('routingLink', navlink ? navlink.id : navlink);
128+
}
129+
// This function is called by editor API to get the provider in which referenced Navlink of Address/Place is located.
130+
// A map/provider setup where all features (Place/Address and referenced Navlink) are provided by the same provider
131+
// (single-provider-setup), this function just needs to return id of the provider itself.
132+
// However, in case of multi-provider-setup, Navlinks can be separated from Address/Place data and distributed across
133+
// multiple providers, this function needs to return id of provider which contains the referenced Navlink.
134+
readRoutingProvider(location) {
135+
return this.id;
136+
}
90137
}
91138

92139
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/add_remove_object_layer.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ class MyProvider extends SpaceProvider {
114114
writeZLevels(navlink, zLevel) {
115115
navlink.prop('zLevels', zLevel);
116116
}
117+
// #################### Buildings/Extruded Polygons ####################
118+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
119+
120+
// to obtain the height of a Building the respective attribute reader must be implemented.
121+
readFeatureHeight(feature) {
122+
return feature.properties.height;
123+
}
124+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
125+
writeFeatureHeight(feature, heightMeter) {
126+
feature.properties.height = heightMeter;
127+
}
117128
}
118129

119130
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/change_road_name.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,53 @@ class MyProvider extends SpaceProvider {
8989
writeZLevels(navlink, zLevel) {
9090
navlink.prop('zLevels', zLevel);
9191
}
92+
// ######################## Address, Place ########################
93+
// Following functions are only necessary if you want to edit Address or Place.
94+
95+
// In addition to a simple Marker, a Place CAN, while an Address MUST have a routing point.
96+
// A routing point of a Place or Address is a geo position (routingPosition) intended for routing purposes and references
97+
// to a navlink (routingLink).
98+
// In this example, we get routingPosition from features's properties 'routingPoint' and routingLink from 'routingLink'.
99+
100+
// Get coordinate of routing point, its format is: [longitude, latitude, altitude].
101+
// This position should always be on the geometry of referenced Navlink.
102+
readRoutingPosition(feature) {
103+
return feature.prop('routingPoint');
104+
}
105+
// Get id of referenced Navlink for Address or Place. Place becomes floating if this function does not return a Navlink id properly.
106+
readRoutingLink(feature) {
107+
return feature.prop('routingLink');
108+
}
109+
// This function is called to write updated coordinate on referenced Navlink when routing position is changed.
110+
// Format of routing position: [longitude, latitude, altitude].
111+
writeRoutingPosition(feature, position) {
112+
feature.prop('routingPoint', position);
113+
}
114+
// This function is called to write new Navlink reference when routingLink is changed.
115+
// For example, drag routing point from one Navlink to another will change routingLink.
116+
// In this example, Navlink id is updated when routingLink changes.
117+
writeRoutingLink(feature, navlink) {
118+
feature.prop('routingLink', navlink ? navlink.id : navlink);
119+
}
120+
// This function is called by editor API to get the provider in which referenced Navlink of Address/Place is located.
121+
// A map/provider setup where all features (Place/Address and referenced Navlink) are provided by the same provider
122+
// (single-provider-setup), this function just needs to return id of the provider itself.
123+
// However, in case of multi-provider-setup, Navlinks can be separated from Address/Place data and distributed across
124+
// multiple providers, this function needs to return id of provider which contains the referenced Navlink.
125+
readRoutingProvider(location) {
126+
return this.id;
127+
}
128+
// #################### Buildings/Extruded Polygons ####################
129+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
130+
131+
// to obtain the height of a Building the respective attribute reader must be implemented.
132+
readFeatureHeight(feature) {
133+
return feature.properties.height;
134+
}
135+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
136+
writeFeatureHeight(feature, heightMeter) {
137+
feature.properties.height = heightMeter;
138+
}
92139
}
93140

94141
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/create_address.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ class MyProvider extends SpaceProvider {
124124
writeZLevels(navlink, zLevel) {
125125
navlink.prop('zLevels', zLevel);
126126
}
127+
// #################### Buildings/Extruded Polygons ####################
128+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
129+
130+
// to obtain the height of a Building the respective attribute reader must be implemented.
131+
readFeatureHeight(feature) {
132+
return feature.properties.height;
133+
}
134+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
135+
writeFeatureHeight(feature, heightMeter) {
136+
feature.properties.height = heightMeter;
137+
}
127138
}
128139

129140
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/create_navlink.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,53 @@ class MyProvider extends SpaceProvider {
8282
writeZLevels(navlink, zLevel) {
8383
navlink.prop('zLevels', zLevel);
8484
}
85+
// #################### Buildings/Extruded Polygons ####################
86+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
87+
88+
// to obtain the height of a Building the respective attribute reader must be implemented.
89+
readFeatureHeight(feature) {
90+
return feature.properties.height;
91+
}
92+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
93+
writeFeatureHeight(feature, heightMeter) {
94+
feature.properties.height = heightMeter;
95+
}
96+
// ######################## Address, Place ########################
97+
// Following functions are only necessary if you want to edit Address or Place.
98+
99+
// In addition to a simple Marker, a Place CAN, while an Address MUST have a routing point.
100+
// A routing point of a Place or Address is a geo position (routingPosition) intended for routing purposes and references
101+
// to a navlink (routingLink).
102+
// In this example, we get routingPosition from features's properties 'routingPoint' and routingLink from 'routingLink'.
103+
104+
// Get coordinate of routing point, its format is: [longitude, latitude, altitude].
105+
// This position should always be on the geometry of referenced Navlink.
106+
readRoutingPosition(feature) {
107+
return feature.prop('routingPoint');
108+
}
109+
// Get id of referenced Navlink for Address or Place. Place becomes floating if this function does not return a Navlink id properly.
110+
readRoutingLink(feature) {
111+
return feature.prop('routingLink');
112+
}
113+
// This function is called to write updated coordinate on referenced Navlink when routing position is changed.
114+
// Format of routing position: [longitude, latitude, altitude].
115+
writeRoutingPosition(feature, position) {
116+
feature.prop('routingPoint', position);
117+
}
118+
// This function is called to write new Navlink reference when routingLink is changed.
119+
// For example, drag routing point from one Navlink to another will change routingLink.
120+
// In this example, Navlink id is updated when routingLink changes.
121+
writeRoutingLink(feature, navlink) {
122+
feature.prop('routingLink', navlink ? navlink.id : navlink);
123+
}
124+
// This function is called by editor API to get the provider in which referenced Navlink of Address/Place is located.
125+
// A map/provider setup where all features (Place/Address and referenced Navlink) are provided by the same provider
126+
// (single-provider-setup), this function just needs to return id of the provider itself.
127+
// However, in case of multi-provider-setup, Navlinks can be separated from Address/Place data and distributed across
128+
// multiple providers, this function needs to return id of provider which contains the referenced Navlink.
129+
readRoutingProvider(location) {
130+
return this.id;
131+
}
85132
}
86133

87134
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/create_place.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ class MyProvider extends SpaceProvider {
122122
writeZLevels(navlink, zLevel) {
123123
navlink.prop('zLevels', zLevel);
124124
}
125+
// #################### Buildings/Extruded Polygons ####################
126+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
127+
128+
// to obtain the height of a Building the respective attribute reader must be implemented.
129+
readFeatureHeight(feature) {
130+
return feature.properties.height;
131+
}
132+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
133+
writeFeatureHeight(feature, heightMeter) {
134+
feature.properties.height = heightMeter;
135+
}
125136
}
126137

127138
let backgroundLayer = new MVTLayer({

packages/playground/examples/editor/crossing_detect.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class MyProvider extends SpaceProvider {
99
detectFeatureClass(feature) {
1010
return feature.properties.featureClass;
1111
}
12-
13-
1412
// ######################## Navlink ########################
1513
// Following functions are only necessary if you want to edit Navlink.
1614

@@ -89,6 +87,53 @@ class MyProvider extends SpaceProvider {
8987
writeZLevels(navlink, zLevel) {
9088
navlink.prop('zLevels', zLevel);
9189
}
90+
// #################### Buildings/Extruded Polygons ####################
91+
// Following functions are only necessary if you want to edit Buildings (Extruded Polygons).
92+
93+
// to obtain the height of a Building the respective attribute reader must be implemented.
94+
readFeatureHeight(feature) {
95+
return feature.properties.height;
96+
}
97+
// the Attribute writer stores the modified height and must be implemented to enable height-editing of the building.
98+
writeFeatureHeight(feature, heightMeter) {
99+
feature.properties.height = heightMeter;
100+
}
101+
// ######################## Address, Place ########################
102+
// Following functions are only necessary if you want to edit Address or Place.
103+
104+
// In addition to a simple Marker, a Place CAN, while an Address MUST have a routing point.
105+
// A routing point of a Place or Address is a geo position (routingPosition) intended for routing purposes and references
106+
// to a navlink (routingLink).
107+
// In this example, we get routingPosition from features's properties 'routingPoint' and routingLink from 'routingLink'.
108+
109+
// Get coordinate of routing point, its format is: [longitude, latitude, altitude].
110+
// This position should always be on the geometry of referenced Navlink.
111+
readRoutingPosition(feature) {
112+
return feature.prop('routingPoint');
113+
}
114+
// Get id of referenced Navlink for Address or Place. Place becomes floating if this function does not return a Navlink id properly.
115+
readRoutingLink(feature) {
116+
return feature.prop('routingLink');
117+
}
118+
// This function is called to write updated coordinate on referenced Navlink when routing position is changed.
119+
// Format of routing position: [longitude, latitude, altitude].
120+
writeRoutingPosition(feature, position) {
121+
feature.prop('routingPoint', position);
122+
}
123+
// This function is called to write new Navlink reference when routingLink is changed.
124+
// For example, drag routing point from one Navlink to another will change routingLink.
125+
// In this example, Navlink id is updated when routingLink changes.
126+
writeRoutingLink(feature, navlink) {
127+
feature.prop('routingLink', navlink ? navlink.id : navlink);
128+
}
129+
// This function is called by editor API to get the provider in which referenced Navlink of Address/Place is located.
130+
// A map/provider setup where all features (Place/Address and referenced Navlink) are provided by the same provider
131+
// (single-provider-setup), this function just needs to return id of the provider itself.
132+
// However, in case of multi-provider-setup, Navlinks can be separated from Address/Place data and distributed across
133+
// multiple providers, this function needs to return id of provider which contains the referenced Navlink.
134+
readRoutingProvider(location) {
135+
return this.id;
136+
}
92137
}
93138

94139
let backgroundLayer = new MVTLayer({

0 commit comments

Comments
 (0)