@mint-ui/map 0.1.3-beta → 0.1.5-beta

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/README.md CHANGED
@@ -1,7 +1,9 @@
1
- <h1>@mint-ui/map</h1>
1
+ # @mint-ui/map
2
2
 
3
- **@mint-ui**
4
- React map library
3
+ - React map library
4
+ - Control various map with one interface
5
+ - Google, Naver map supported now
6
+ - Typescript supported
5
7
 
6
8
  ## Installation
7
9
 
@@ -11,5 +13,41 @@ yarn add @mint-ui/map
11
13
  npm install @mint-ui/map
12
14
  ```
13
15
 
14
- ### Document / Reference Site
16
+ ## Examples
17
+
18
+ ``` javascript
19
+ ...
20
+ ...
21
+
22
+ import { MapMarkerWrapper, MintMap, Position } from '@mint-ui/map'
23
+
24
+ const root = ReactDOM.createRoot(
25
+ document.getElementById('root')
26
+ )
27
+
28
+ function MyMapComponent(){
29
+
30
+ return <MintMap
31
+ mapType={'google'}
32
+ mapKey={'YOUR_GOOGLE_MAP_KEY'}
33
+ mapId='YOUR_GOOGLE_MAP_ID' //Use advanced markers in Google maps
34
+ base={{center:new Position(-25.344, 131.031), zoomLevel:12}}
35
+ >
36
+ {/* Your marker */}
37
+ <MapMarkerWrapper position={new Position(-25.344, 131.031)}>
38
+
39
+ {/* Your marker elements */}
40
+ <div style={{width:'10px', height:'10px', background:'red', borderRadius:'10px'}}></div>
41
+
42
+ </MapMarkerWrapper>
43
+
44
+ </MintMap>
45
+
46
+ }
47
+
48
+ root.render((<MyMapComponent/>))
49
+
50
+ ```
51
+
52
+ ## Document / Reference Site
15
53
  - To be continue...
@@ -26,7 +26,13 @@ export declare class Position {
26
26
  export declare class Bounds {
27
27
  nw: Position;
28
28
  se: Position;
29
- constructor(nw: Position, se: Position);
29
+ ne: Position;
30
+ sw: Position;
31
+ constructor(nw?: Position, se?: Position, ne?: Position, sw?: Position);
32
+ static fromNWSE(nw: Position, se: Position): Bounds;
33
+ static fromNESW(ne: Position, sw: Position): Bounds;
34
+ private covertNWSEtoNESW;
35
+ private covertNESWtoNWSE;
30
36
  getCenter(): Position;
31
37
  includes(positions: Position[]): boolean;
32
38
  includesOnlyOnePoint(positions: Position[]): boolean;
@@ -29,11 +29,41 @@ var Position = function () {
29
29
  }();
30
30
 
31
31
  var Bounds = function () {
32
- function Bounds(nw, se) {
32
+ function Bounds(nw, se, ne, sw) {
33
+ if (!(nw && se || ne && sw)) {
34
+ throw new Error('nw/se or ne/sw needed');
35
+ }
36
+
33
37
  this.nw = nw;
34
38
  this.se = se;
39
+ this.ne = ne;
40
+ this.sw = sw;
41
+
42
+ if (nw && se) {
43
+ this.covertNWSEtoNESW(nw, se);
44
+ } else if (ne && sw) {
45
+ this.covertNESWtoNWSE(ne, sw);
46
+ }
35
47
  }
36
48
 
49
+ Bounds.fromNWSE = function (nw, se) {
50
+ return new Bounds(nw, se, undefined, undefined);
51
+ };
52
+
53
+ Bounds.fromNESW = function (ne, sw) {
54
+ return new Bounds(undefined, undefined, ne, sw);
55
+ };
56
+
57
+ Bounds.prototype.covertNWSEtoNESW = function (nw, se) {
58
+ this.ne = new Position(nw.lat, se.lng);
59
+ this.sw = new Position(se.lat, nw.lng);
60
+ };
61
+
62
+ Bounds.prototype.covertNESWtoNWSE = function (ne, sw) {
63
+ this.nw = new Position(ne.lat, sw.lng);
64
+ this.se = new Position(sw.lat, ne.lng);
65
+ };
66
+
37
67
  Bounds.prototype.getCenter = function () {
38
68
  return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
39
69
  };
@@ -396,7 +396,7 @@ var GoogleMintMapController = function (_super) {
396
396
  };
397
397
 
398
398
  GoogleMintMapController.prototype.fromGoogleBounds = function (bounds) {
399
- return new MintMap.Bounds(new MintMap.Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()), new MintMap.Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
399
+ return MintMap.Bounds.fromNESW(new MintMap.Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()), new MintMap.Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
400
400
  };
401
401
 
402
402
  GoogleMintMapController.prototype.getCurrBounds = function () {
@@ -404,7 +404,7 @@ var NaverMintMapController = function (_super) {
404
404
  }
405
405
 
406
406
  var bounds = this.map.getBounds();
407
- return new MintMap.Bounds(new MintMap.Position(bounds.getMin().y, bounds.getMin().x), new MintMap.Position(bounds.getMax().y, bounds.getMax().x));
407
+ return MintMap.Bounds.fromNWSE(new MintMap.Position(bounds.getMin().y, bounds.getMin().x), new MintMap.Position(bounds.getMax().y, bounds.getMax().x));
408
408
  };
409
409
 
410
410
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
package/dist/index.es.js CHANGED
@@ -718,7 +718,7 @@ var NaverMintMapController = function (_super) {
718
718
  }
719
719
 
720
720
  var bounds = this.map.getBounds();
721
- return new Bounds(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
721
+ return Bounds.fromNWSE(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
722
722
  };
723
723
 
724
724
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
@@ -1127,7 +1127,7 @@ var GoogleMintMapController = function (_super) {
1127
1127
  };
1128
1128
 
1129
1129
  GoogleMintMapController.prototype.fromGoogleBounds = function (bounds) {
1130
- return new Bounds(new Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()), new Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
1130
+ return Bounds.fromNESW(new Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()), new Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
1131
1131
  };
1132
1132
 
1133
1133
  GoogleMintMapController.prototype.getCurrBounds = function () {
@@ -1171,11 +1171,41 @@ var Position = function () {
1171
1171
  }();
1172
1172
 
1173
1173
  var Bounds = function () {
1174
- function Bounds(nw, se) {
1174
+ function Bounds(nw, se, ne, sw) {
1175
+ if (!(nw && se || ne && sw)) {
1176
+ throw new Error('nw/se or ne/sw needed');
1177
+ }
1178
+
1175
1179
  this.nw = nw;
1176
1180
  this.se = se;
1181
+ this.ne = ne;
1182
+ this.sw = sw;
1183
+
1184
+ if (nw && se) {
1185
+ this.covertNWSEtoNESW(nw, se);
1186
+ } else if (ne && sw) {
1187
+ this.covertNESWtoNWSE(ne, sw);
1188
+ }
1177
1189
  }
1178
1190
 
1191
+ Bounds.fromNWSE = function (nw, se) {
1192
+ return new Bounds(nw, se, undefined, undefined);
1193
+ };
1194
+
1195
+ Bounds.fromNESW = function (ne, sw) {
1196
+ return new Bounds(undefined, undefined, ne, sw);
1197
+ };
1198
+
1199
+ Bounds.prototype.covertNWSEtoNESW = function (nw, se) {
1200
+ this.ne = new Position(nw.lat, se.lng);
1201
+ this.sw = new Position(se.lat, nw.lng);
1202
+ };
1203
+
1204
+ Bounds.prototype.covertNESWtoNWSE = function (ne, sw) {
1205
+ this.nw = new Position(ne.lat, sw.lng);
1206
+ this.se = new Position(sw.lat, ne.lng);
1207
+ };
1208
+
1179
1209
  Bounds.prototype.getCenter = function () {
1180
1210
  return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1181
1211
  };
package/dist/index.umd.js CHANGED
@@ -724,7 +724,7 @@
724
724
  }
725
725
 
726
726
  var bounds = this.map.getBounds();
727
- return new Bounds(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
727
+ return Bounds.fromNWSE(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
728
728
  };
729
729
 
730
730
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
@@ -1133,7 +1133,7 @@
1133
1133
  };
1134
1134
 
1135
1135
  GoogleMintMapController.prototype.fromGoogleBounds = function (bounds) {
1136
- return new Bounds(new Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()), new Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
1136
+ return Bounds.fromNESW(new Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()), new Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
1137
1137
  };
1138
1138
 
1139
1139
  GoogleMintMapController.prototype.getCurrBounds = function () {
@@ -1177,11 +1177,41 @@
1177
1177
  }();
1178
1178
 
1179
1179
  var Bounds = function () {
1180
- function Bounds(nw, se) {
1180
+ function Bounds(nw, se, ne, sw) {
1181
+ if (!(nw && se || ne && sw)) {
1182
+ throw new Error('nw/se or ne/sw needed');
1183
+ }
1184
+
1181
1185
  this.nw = nw;
1182
1186
  this.se = se;
1187
+ this.ne = ne;
1188
+ this.sw = sw;
1189
+
1190
+ if (nw && se) {
1191
+ this.covertNWSEtoNESW(nw, se);
1192
+ } else if (ne && sw) {
1193
+ this.covertNESWtoNWSE(ne, sw);
1194
+ }
1183
1195
  }
1184
1196
 
1197
+ Bounds.fromNWSE = function (nw, se) {
1198
+ return new Bounds(nw, se, undefined, undefined);
1199
+ };
1200
+
1201
+ Bounds.fromNESW = function (ne, sw) {
1202
+ return new Bounds(undefined, undefined, ne, sw);
1203
+ };
1204
+
1205
+ Bounds.prototype.covertNWSEtoNESW = function (nw, se) {
1206
+ this.ne = new Position(nw.lat, se.lng);
1207
+ this.sw = new Position(se.lat, nw.lng);
1208
+ };
1209
+
1210
+ Bounds.prototype.covertNESWtoNWSE = function (ne, sw) {
1211
+ this.nw = new Position(ne.lat, sw.lng);
1212
+ this.se = new Position(sw.lat, ne.lng);
1213
+ };
1214
+
1185
1215
  Bounds.prototype.getCenter = function () {
1186
1216
  return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1187
1217
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mint-ui/map",
3
- "version": "0.1.3-beta",
3
+ "version": "0.1.5-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "browser": "./dist/index.umd.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "repository": "https://github.com/dev-rsquare/mint-ui-map",
9
9
  "author": "RSQUARE",
10
- "keywords": ["react", "map", "google", "naver", "library"],
10
+ "keywords": ["react", "map", "google", "naver", "library", "typescript"],
11
11
  "license": "MIT",
12
12
  "private": false,
13
13
  "devDependencies": {