Skip to content

Commit 3c43daa

Browse files
authored
Merge pull request #30 from weareinlog/dev
(polyline): add some new features
2 parents 96cebda + e827731 commit 3c43daa

24 files changed

+3345
-2233
lines changed

DOCUMENTATION.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@inlog/inlog-maps](https://github.com/weareinlog/inlog-maps#readme) *4.2.7*
1+
# [@inlog/inlog-maps](https://github.com/weareinlog/inlog-maps#readme) *4.3.0*
22

33
> A library for using generic layer maps
44
@@ -1089,6 +1089,30 @@ Use this function to add more paths to a polyline
10891089

10901090

10911091

1092+
#### Map.getPolylinePath(type, condition)
1093+
1094+
Use this function to get the path of some polyline
1095+
1096+
1097+
1098+
1099+
##### Parameters
1100+
1101+
| Name | Type | Description | |
1102+
| ---- | ---- | ----------- | -------- |
1103+
| type | `string` | |   |
1104+
| condition | `any` | |   |
1105+
1106+
1107+
1108+
1109+
##### Returns
1110+
1111+
1112+
- `Array.<number>`
1113+
1114+
1115+
10921116
#### Map.removePolylineHighlight()
10931117

10941118
Use this function to clear polyline selected from the currentMap
@@ -1174,6 +1198,54 @@ Use this function to set position of polyline highlight
11741198

11751199

11761200

1201+
##### Returns
1202+
1203+
1204+
- `Void`
1205+
1206+
1207+
1208+
#### Map.getObjectPolyline(type, condition)
1209+
1210+
1211+
1212+
1213+
1214+
1215+
##### Parameters
1216+
1217+
| Name | Type | Description | |
1218+
| ---- | ---- | ----------- | -------- |
1219+
| type | `string` | |   |
1220+
| condition | `any` | |   |
1221+
1222+
1223+
1224+
1225+
##### Returns
1226+
1227+
1228+
- `object`
1229+
1230+
1231+
1232+
#### Map.addPolylineHighlightEvent(event, eventFunction)
1233+
1234+
Use this function to add events on polyline highligth / selected polyline
1235+
1236+
1237+
1238+
1239+
##### Parameters
1240+
1241+
| Name | Type | Description | |
1242+
| ---- | ---- | ----------- | -------- |
1243+
| event | `InlogMaps.PolylineEventType` | |   |
1244+
| eventFunction | `any` | |   |
1245+
1246+
1247+
1248+
11771249
##### Returns
11781250

11791251

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inlog/inlog-maps",
3-
"version": "4.2.7",
3+
"version": "4.3.0",
44
"description": "A library for using generic layer maps ",
55
"main": "index.js",
66
"types": "dist/index.d.ts",

src/map.ts

Lines changed: 77 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default class Map {
3030

3131
/**
3232
* Use this to initialize map
33-
* @param {InlogMaps.MapType} mapType
34-
* @param {any} options
33+
* @param {InlogMaps.MapType} mapType
34+
* @param {any} options
3535
* @param {string} elementId default: 'inlog-map' [nullable]
3636
* @returns {Promisse<any>}
3737
*/
@@ -199,7 +199,7 @@ export default class Map {
199199

200200
/**
201201
* This functions returns if marker exists
202-
* @param type
202+
* @param type
203203
* @param condition [nullable]
204204
* @returns {boolean}
205205
*/
@@ -210,9 +210,9 @@ export default class Map {
210210

211211
/**
212212
* Use this function to count markers by type
213-
* @param {string} type
213+
* @param {string} type
214214
* @param {boolean} onlyOnMap exclude hidden markers, default true
215-
* @param {any} condition
215+
* @param {any} condition
216216
* @returns {number}
217217
*/
218218
public countMarkers(type: string, onlyOnMap: boolean = true, condition?: any): number {
@@ -230,9 +230,9 @@ export default class Map {
230230

231231
/**
232232
* This function add new events on marker
233-
* @param {string} type
234-
* @param {InlogMaps.MarkerEventType} event
235-
* @param {any} eventFunction
233+
* @param {string} type
234+
* @param {InlogMaps.MarkerEventType} event
235+
* @param {any} eventFunction
236236
* @param {any} condition [nullable]
237237
*/
238238
public addMarkerEvent(type: string, event: MarkerEventType, eventFunction: any, condition?: any): void {
@@ -243,8 +243,8 @@ export default class Map {
243243

244244
/**
245245
* This function remove events of marker
246-
* @param {string} type
247-
* @param {InlogMaps.MarkerEventType} event
246+
* @param {string} type
247+
* @param {InlogMaps.MarkerEventType} event
248248
* @param {any} condition [nullable]
249249
*/
250250
public removeMarkerEvent(type: string, event: MarkerEventType, condition?: any): void {
@@ -257,7 +257,7 @@ export default class Map {
257257
/**
258258
* Use this function to add MarkerClusterer on the map
259259
* @param {string} type same type of markers
260-
* @param {InlogMaps.MarkerClusterConfig} config
260+
* @param {InlogMaps.MarkerClusterConfig} config
261261
*/
262262
public addMarkerClusterer(type: string, config: MarkerClustererConfig): void {
263263
this.markerClusterer[type] = this.map.addMarkerClusterer(config);
@@ -266,7 +266,7 @@ export default class Map {
266266
/**
267267
* Use this function to alter clusterer options
268268
* @param type same type of markers
269-
* @param {InlogMaps.MarkerClusterConfig} config
269+
* @param {InlogMaps.MarkerClusterConfig} config
270270
*/
271271
public alterMarkerClustererConfig(type: string, config: MarkerClustererConfig): void {
272272
if (this.markerClusterer[type]) {
@@ -394,7 +394,7 @@ export default class Map {
394394

395395
/**
396396
* This functions returns if polygon exists
397-
* @param type
397+
* @param type
398398
* @param condition [nullable]
399399
* @returns {boolean}
400400
*/
@@ -405,9 +405,9 @@ export default class Map {
405405

406406
/**
407407
* This function add new events on polygon
408-
* @param {string} type
409-
* @param {InlogMaps.PolygonEventType} event
410-
* @param {any} eventFunction
408+
* @param {string} type
409+
* @param {InlogMaps.PolygonEventType} event
410+
* @param {any} eventFunction
411411
* @param {any} condition [nullable]
412412
*/
413413
public addPolygonEvent(type: string, event: PolygonEventType, eventFunction: any, condition?: any): void {
@@ -418,8 +418,8 @@ export default class Map {
418418

419419
/**
420420
* This function remove events of polygon
421-
* @param {string} type
422-
* @param {InlogMaps.PolygonEventType} event
421+
* @param {string} type
422+
* @param {InlogMaps.PolygonEventType} event
423423
* @param {any} condition [nullable]
424424
*/
425425
public removePolygonEvent(type: string, event: PolygonEventType, condition?: any): void {
@@ -514,7 +514,7 @@ export default class Map {
514514

515515
/**
516516
* This functions returns if circle exists
517-
* @param {string} type
517+
* @param {string} type
518518
* @param {any} condition [nullable]
519519
* @returns {boolean}
520520
*/
@@ -525,7 +525,7 @@ export default class Map {
525525

526526
/**
527527
* This function return circle center
528-
* @param {string} type
528+
* @param {string} type
529529
* @param {any} condition [nullable]
530530
* @returns {number[]}
531531
*/
@@ -541,9 +541,9 @@ export default class Map {
541541

542542
/**
543543
* This function add new events on circle
544-
* @param {string} type
545-
* @param {InlogMaps.CircleEventType} event
546-
* @param {any} eventFunction
544+
* @param {string} type
545+
* @param {InlogMaps.CircleEventType} event
546+
* @param {any} eventFunction
547547
* @param {any} condition [nullable]
548548
*/
549549
public addCircleEvent(type: string, event: CircleEventType, eventFunction: any, condition?: any): void {
@@ -554,8 +554,8 @@ export default class Map {
554554

555555
/**
556556
* This function remove events of circle
557-
* @param {string} type
558-
* @param {InlogMaps.CircleEventType} event
557+
* @param {string} type
558+
* @param {InlogMaps.CircleEventType} event
559559
* @param {any} condition [nullable]
560560
*/
561561
public removeCircleEvent(type: string, event: CircleEventType, condition?: any): void {
@@ -610,7 +610,7 @@ export default class Map {
610610

611611
/**
612612
* Use this function to remove polylines
613-
* @param {string} type
613+
* @param {string} type
614614
* @param {any} condition remove polyline with the condition [nullable]
615615
*/
616616
public removePolylines(type: string, condition?: any): void {
@@ -637,7 +637,7 @@ export default class Map {
637637
/**
638638
* Use this function to alter polyline options
639639
* @param {string} type
640-
* @param {InlogMaps.PolylineOptions} options
640+
* @param {InlogMaps.PolylineOptions} options
641641
* @param {any} condition alter polyline with the condition [nullable]
642642
*/
643643
public alterPolylineOptions(type: string, options: PolylineOptions, condition?: any): void {
@@ -692,6 +692,20 @@ export default class Map {
692692
}
693693
}
694694

695+
/**
696+
* Use this function to get the path of some polyline
697+
* @param {string} type
698+
* @param {any} condition
699+
* @returns {number[]}
700+
*/
701+
public getPolylinePath(type: string, condition?: any): number[] {
702+
const polyline = this.getPolylines(type, condition);
703+
704+
if (polyline && polyline.length) {
705+
return this.map.getPolylinePath(polyline[0]);
706+
}
707+
}
708+
695709
/**
696710
* Use this function to clear polyline selected from the currentMap
697711
*/
@@ -701,9 +715,9 @@ export default class Map {
701715

702716
/**
703717
* Use this function to add listeners on polyline
704-
* @param {string} type
705-
* @param {InlogMaps.PolylineEventType} event
706-
* @param {any} eventFunction
718+
* @param {string} type
719+
* @param {InlogMaps.PolylineEventType} event
720+
* @param {any} eventFunction
707721
* @param {any} condition [nullable]
708722
*/
709723
public addPolylineEvent(type: string, event: PolylineEventType, eventFunction: any, condition?: any): void {
@@ -714,8 +728,8 @@ export default class Map {
714728

715729
/**
716730
* Use this function to remove listeners of polyline
717-
* @param {string} type
718-
* @param {InlogMaps.PolylineEventType} event
731+
* @param {string} type
732+
* @param {InlogMaps.PolylineEventType} event
719733
* @param {any} condition [nullable]
720734
*/
721735
public removePolylineEvent(type: string, event: PolylineEventType, condition?: any): void {
@@ -726,8 +740,8 @@ export default class Map {
726740

727741
/**
728742
* Use this function to set position of polyline highlight
729-
* @param {string} type
730-
* @param {number} initialIndex
743+
* @param {string} type
744+
* @param {number} initialIndex
731745
* @param {any} condition [nullable]
732746
*/
733747
public setIndexPolylineHighlight(type: string, initialIndex: number, condition?: any) {
@@ -738,6 +752,31 @@ export default class Map {
738752
}
739753
}
740754

755+
/**
756+
*
757+
* @param {string} type
758+
* @param {any} condition
759+
* @returns {object}
760+
*/
761+
public getObjectPolyline(type: string, condition?: any): object {
762+
const polylines = this.getPolylines(type, condition);
763+
764+
if (polylines && polylines.length) {
765+
return this.map.getObjectPolyline(polylines[0]);
766+
} else {
767+
return null;
768+
}
769+
}
770+
771+
/**
772+
* Use this function to add events on polyline highligth / selected polyline
773+
* @param {InlogMaps.PolylineEventType} event
774+
* @param {any} eventFunction
775+
*/
776+
public addPolylineHighlightEvent(event: PolylineEventType, eventFunction: any) {
777+
this.map.addPolylineHighlightEvent(event, eventFunction);
778+
}
779+
741780
/* Info Windows */
742781
/**
743782
* Use this function to draw popups on the currentMap
@@ -780,8 +819,8 @@ export default class Map {
780819
}
781820

782821
/**
783-
*
784-
* @param {string} type
822+
*
823+
* @param {string} type
785824
* @returns {object}
786825
*/
787826
public getObjectOpenPopup(type: string): object {
@@ -867,8 +906,8 @@ export default class Map {
867906

868907
/**
869908
* Returns the coordinates from pixels
870-
* @param {number} offsetx
871-
* @param {number} offsety
909+
* @param {number} offsetx
910+
* @param {number} offsety
872911
* @returns {number[]}
873912
*/
874913
public pixelsToLatLng(offsetx: number, offsety: number): number[] {

0 commit comments

Comments
 (0)