Skip to content

Commit 56e5081

Browse files
OS-giulianasilvagnbmJoaoFerreira-FrontEndOUTSYSTEMS\fmj
authored
ROU-4396: Migrate OS Maps v1.6.6 to ODC (#138)
* Update asset version to 1.6.6 Updated asset version to 1.6.6. * ROU-4222: DrawCircle AddOn does not pass coordinates when editing a shape (#132) * Fix issue with Leaflet OnDrawingChange event * Remove unnecessary arguments * Fix OnDrawChange event for Google Maps * Remove unnecessary arguments and comments * Add comments * Fix eslint errors * Fix Code smell * Removed repeated code * Add shape types * Update ShapeProviderEvent.ts * ROU-4283 - [OSMaps] - Leaflet and Google Maps - DrawCircle AddOn does not pass coordinates when editing a shape (#133) * - fix coords sended on the coordinates parameter of triggerOnDrawingChangeEvent; * - change the return location on draging end (draw marker); --------- Co-authored-by: OUTSYSTEMS\fmj <joao.maneul.ferreira@outsystems.com> * Update Images.css Includes the changes made in ROU-4361 in order to replace the base 64 for the CSS vars → --map-container-image-google and --map-container-image-leaflet * Revert "Update Images.css" This reverts commit 96154f3. * Update Images.css Includes the changes made in ROU-4361 in order to replace the base 64 for the CSS vars → --map-container-image-google and --map-container-image-leaflet --------- Co-authored-by: gbnm <goncalo.martins@outsystems.com> Co-authored-by: João Ferreira <60441552+JoaoFerreira-FrontEnd@users.noreply.github.com> Co-authored-by: OUTSYSTEMS\fmj <joao.maneul.ferreira@outsystems.com>
1 parent 8a06b93 commit 56e5081

21 files changed

Lines changed: 255 additions & 66 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "outsystems-maps",
3-
"version": "1.6.5",
3+
"version": "1.6.6",
44
"description": "Outsystems Maps",
55
"license": "BSD-3-Clause",
66
"scripts": {

src/OSFramework/Maps/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22
namespace OSFramework.Maps.Constants {
33
/* OutSystems Maps Version */
4-
export const OSMapsVersion = '1.6.5';
4+
export const OSMapsVersion = '1.6.6';
55
}

src/OSFramework/Maps/Event/DrawingTools/DrawingToolsProviderEvent.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ namespace OSFramework.Maps.Event.DrawingTools {
1313
* Method that will trigger the event with the correct parameters.
1414
* @param mapId Id of the Map that is raising the event
1515
* @param drawingToolsId Id of the DrawingTools that is raising the event
16-
* @param eventName Name of the event that got raised
1716
* @param isNewElement IsNewShape/IsNewMarker (empty if the provider event is not handled by the element creator or changer)
17+
* @param coordinates string contaning the shape coordinates
18+
* @param location string contaning the shape coordinates and other properties as circle radius
1819
*/
1920
public trigger(
2021
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2122
mapId: string,
2223
drawingToolsId: string,
23-
eventName: string,
2424
isNewElement: boolean,
2525
coordinates:
2626
| OSStructures.OSMap.Coordinates
@@ -34,7 +34,6 @@ namespace OSFramework.Maps.Event.DrawingTools {
3434
h,
3535
mapId,
3636
drawingToolsId,
37-
eventName,
3837
isNewElement,
3938
coordinates,
4039
location

src/OSFramework/Maps/Event/Shape/ShapeProviderEvent.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ namespace OSFramework.Maps.Event.Shape {
1414
* @param mapId Id of the Map that is raising the event
1515
* @param shapeId Id of the Shape that is raising the event
1616
* @param eventName Name of the event that got raised
17+
* @param coords Event properties as coordinates and location
1718
*/
1819
public trigger(
1920
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2021
mapId: string,
2122
shapeId: string,
22-
eventName: string
23+
eventName: string,
24+
coords: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
2325
): void {
2426
this.handlers
2527
.slice(0)
2628
.forEach((h) =>
27-
Helper.CallbackAsyncInvocation(h, mapId, shapeId, eventName)
29+
Helper.CallbackAsyncInvocation(
30+
h,
31+
mapId,
32+
shapeId,
33+
eventName,
34+
coords
35+
)
2836
);
2937
}
3038
}

src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,27 @@ namespace OSFramework.Maps.OSStructures.OSMap {
1717
this.Lng = lng;
1818
}
1919
}
20+
21+
export type PolylineCoordinates = {
22+
coordinates: Array<OSCoordinates>;
23+
location: Array<string>;
24+
};
25+
26+
export type CircleCoordinates = {
27+
coordinates: OSCoordinates;
28+
location: {
29+
location: string;
30+
radius: number;
31+
};
32+
};
33+
34+
export type RectangleCoordinates = {
35+
coordinates: Bounds;
36+
location: Bounds;
37+
};
38+
39+
export type OSShapeCoordinates =
40+
| PolylineCoordinates // Polyline and Polygon type
41+
| CircleCoordinates
42+
| RectangleCoordinates;
2043
}

src/OSFramework/Maps/Shape/AbstractShape.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,21 @@ namespace OSFramework.Maps.Shape {
120120
return this.shapeProviderEvents.indexOf(eventName) !== -1;
121121
}
122122

123+
protected triggerShapeChangedEvent() {
124+
const shapeLocation = this.getShapeCoordinates();
125+
126+
this.shapeEvents.trigger(
127+
// EventType
128+
OSFramework.Maps.Event.Shape.ShapeEventType.ProviderEvent,
129+
// EventName
130+
OSFramework.Maps.Helper.Constants.shapeChangedEvent,
131+
shapeLocation
132+
);
133+
}
134+
123135
protected abstract get invalidShapeLocationErrorCode(): Enum.ErrorCodes;
124136

137+
protected abstract getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates;
125138
public abstract refreshProviderEvents(): void;
126139
public abstract get shapeProviderEvents(): Array<string>;
127140
public abstract get shapeTag(): string;

src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,18 @@ namespace Provider.Maps.Google.DrawingTools {
1616
super(map, drawingTools, drawingToolsId, type, configs);
1717
}
1818

19-
/** Create the new shape element based on the configurations (already contains the locations, the bounds or the center and radius depending on the type of the new shape) */
20-
protected createShapeElement(
21-
uniqueId: string,
22-
type: OSFramework.Maps.Enum.ShapeType,
23-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
24-
configs: any
25-
): OSFramework.Maps.Shape.IShape {
26-
const _shape = Shape.ShapeFactory.MakeShape(
27-
this.map,
28-
uniqueId,
29-
type,
30-
configs
31-
);
32-
33-
// Add the onChange event to the new element
34-
this.setOnChangeEvent(_shape, _shape.config.locations);
35-
// Add the new element to the map
36-
this.map.addShape(_shape);
37-
38-
return _shape;
39-
}
40-
4119
/** Add the onChange event to the new element */
42-
protected setOnChangeEvent(
43-
_shape: OSFramework.Maps.Shape.IShape,
44-
locations: string
45-
): void {
20+
private _setOnChangeEvent(_shape: OSFramework.Maps.Shape.IShape): void {
4621
_shape.shapeEvents.addHandler(
4722
// changing the shape locations or bounds is only available via the drag-and-drop and resize, so the solution passes by adding the shape_changed event listener as the shape's OnChanged event
4823
OSFramework.Maps.Helper.Constants
4924
.shapeChangedEvent as OSFramework.Maps.Event.Shape.ShapeEventType,
50-
() => {
25+
(
26+
mapId: string,
27+
shapeId: string,
28+
eventName: string,
29+
shapeCoordinates: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
30+
) => {
5131
this.drawingTools.drawingToolsEvents.trigger(
5232
// EventType
5333
OSFramework.Maps.Event.DrawingTools
@@ -58,13 +38,38 @@ namespace Provider.Maps.Google.DrawingTools {
5838
{
5939
uniqueId: _shape.uniqueId,
6040
isNewElement: false,
61-
locations
41+
location: JSON.stringify(shapeCoordinates.location),
42+
coordinates: JSON.stringify(
43+
shapeCoordinates.coordinates
44+
)
6245
}
6346
);
6447
}
6548
);
6649
}
6750

51+
/** Create the new shape element based on the configurations (already contains the locations, the bounds or the center and radius depending on the type of the new shape) */
52+
protected createShapeElement(
53+
uniqueId: string,
54+
type: OSFramework.Maps.Enum.ShapeType,
55+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
56+
configs: any
57+
): OSFramework.Maps.Shape.IShape {
58+
const _shape = Shape.ShapeFactory.MakeShape(
59+
this.map,
60+
uniqueId,
61+
type,
62+
configs
63+
);
64+
65+
// Add the onChange event to the new element
66+
this._setOnChangeEvent(_shape);
67+
// Add the new element to the map
68+
this.map.addShape(_shape);
69+
70+
return _shape;
71+
}
72+
6873
public build(): void {
6974
super.build();
7075
}

src/Providers/Maps/Google/DrawingTools/DrawMarker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ namespace Provider.Maps.Google.DrawingTools {
3535
this.triggerOnDrawingChangeEvent(
3636
_marker.uniqueId,
3737
false,
38-
JSON.stringify(this._latLng),
39-
_marker.config.location
38+
JSON.stringify({
39+
Lat: _marker.provider.getPosition().lat(),
40+
Lng: _marker.provider.getPosition().lng()
41+
}),
42+
`${_marker.provider
43+
.getPosition()
44+
.lat()},${_marker.provider.getPosition().lng()}`
4045
)
4146
);
4247
}

src/Providers/Maps/Google/Shape/AbstractProviderShape.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,9 @@ namespace Provider.Maps.Google.Shape {
100100
}
101101
this._shapeChangedEventTimeout =
102102
setTimeout(
103-
() =>
104-
this.shapeEvents.trigger(
105-
// EventType
106-
OSFramework.Maps.Event
107-
.Shape
108-
.ShapeEventType
109-
.ProviderEvent,
110-
// EventName
111-
OSFramework.Maps.Helper
112-
.Constants
113-
.shapeChangedEvent
114-
),
103+
this.triggerShapeChangedEvent.bind(
104+
this
105+
),
115106
500
116107
);
117108
}

src/Providers/Maps/Google/Shape/Circle.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ namespace Provider.Maps.Google.Shape {
6767
.CFG_InvalidCircleShapeCenter;
6868
}
6969

70+
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.CircleCoordinates {
71+
return {
72+
coordinates: {
73+
Lat: this.providerCenter.lat,
74+
Lng: this.providerCenter.lng
75+
},
76+
location: {
77+
location: `${this.providerCenter.lat.toString()},${this.providerCenter.lng.toString()}`,
78+
radius: this.providerRadius
79+
}
80+
};
81+
}
82+
7083
public get providerCenter(): OSFramework.Maps.OSStructures.OSMap.Coordinates {
7184
const center = this.provider.get('center');
7285
if (center === undefined) {

0 commit comments

Comments
 (0)