Aktywne Wpisy

gracjan-rozenek +119

wsciekly_bobr +27
#wykop30plus jakie pamietacie najlepsze afery na wykop? Rozruszajmy ten serwis, jade do pracy io sie nudz.. tylko prosze bez zbozowej. #pytanie
Skopiuj link
Skopiuj link

Regulamin
Reklama
Kontakt
O nas
FAQ
Osiągnięcia
Ranking
kodzik: (tak, wiem, że adres z-----y, potem wypluję go prawilnie ;) )
Place.schema.pre('save',function
```**```
(next) {
```**```
if
```**```
(!
```**```
this
```**```
.location.lat ||
```**```
this
```**```
.isModified(
```_```
'location'
```_```
)) {
```**```
var
```**```
address =
```**```
this
```**```
.location.street
+
```_```
' '
```_```
+
```**```
this
```**```
.location.number
+
```_```
', '
```_```
+
```**```
this
```**```
.location.city,
``````
geocoderProvider =
```_```
'google'
```_```
,
httpAdapter =
```_```
'https'
```_```
,
``````
extra = {
apiKey:
```_```
'blabla'
```_```
,
formatter:
```**```
null
```**```
},
lat, lng;
``````
```**```
var
```**```
geocoder = require(
```_```
'node-geocoder'
```_```
).getGeocoder(geocoderProvider, httpAdapter, extra);
geocoder.geocode(address)
.then(
```**```
function
```**```
(res) {
lat = res[0].latitude;
lng = res[0].longitude;
``````
```**```
this
```**```
.location.lat = lat;
```**```
this
```**```
.location.lng = lng;
``````
```**```
this
```**```
.save(
```**```
function
```**```
(err){
console.log(lat)
console.log(err)
})
})
.
```**```
catch
```**```
(
```**```
function
```**```
(err) {
console.log(err);
});
}
next();
});
#webdev