Skip to content

Commit 82ca1b8

Browse files
committed
Add LatLonField spatial type
1 parent ddd12fd commit 82ca1b8

File tree

3 files changed

+25340
-2
lines changed

3 files changed

+25340
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This map field currently ONLY shows in details view - BUT editing will be coming
77
You can use this Map Field with three different sort of spatial data:
88
* GeoJSON String property
99
* Latitude and Longitude properties
10+
* Latitude and Longitude both in a single text field
1011
* Core Laravel Spatial Types
1112
* Point
1213
* LineString
@@ -31,6 +32,7 @@ To specify what sort of spatial data you are passing to this field you MUST set
3132
```
3233
These are the valid Spatial Types
3334
* LatLon
35+
* LatLonField (single field)
3436
* GeoJSON
3537
* Point
3638
* LineString
@@ -71,6 +73,12 @@ Map::make('Some Point Location')
7173
->longitude('longitude_field_name'),
7274
```
7375

76+
## Latitude & Longitude (in single fields)
77+
```php
78+
Map::make('Some Point Location', 'coordinate_field_name')
79+
->spatialType('LatLonField'),
80+
```
81+
7482
## Set the Height
7583
```php
7684
Map::make('Some Point Field', 'point_field_name')

dist/js/field.js

Lines changed: 25323 additions & 1 deletion
Large diffs are not rendered by default.

resources/js/components/MapDetail.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ export default {
9797
this.value[this.latitude_field],
9898
]
9999
}
100+
}else if(this.type == "LatLonField"){
101+
let coords = this.value.split(/[ ,]+/).filter(Boolean);
102+
return {
103+
type: 'Point',
104+
coordinates: [
105+
coords[1],
106+
coords[0]
107+
]
108+
}
100109
}else if(this.type == "GeoJSON"){
101110
return JSON.parse(this.value)
102111
}else{
@@ -105,7 +114,6 @@ export default {
105114
}
106115
},
107116
mounted() {
108-
109117
this.$nextTick(() => {
110118
this.map = this.$refs.map.mapObject
111119

0 commit comments

Comments
 (0)