I am using SimpleSchema for a Building document (see below). I am trying to show the latitude and longitude for the building in a table but the latitude and longitude don’t show up. How do I access the latitude and longitude?
...
<tbody>
{{#each all_buildings}}
<tr data-id="{{_id}}" >
<td>{{name}}</td>
<td>{{address}}</td>
<td>{{region}}</td>
<td>{{location.coordinates.[1]}}</td> <!-- shows blank -->
<td>{{location.coordinates.[0]}}</td> <!-- shows blank -->
</tr>
{{/each}}
</tbody>
The code for my schemas is below:
Buildings = new Meteor.Collection("Buildings");
Schemas.Buildings = new SimpleSchema({
'name': {
type: String,
label: 'What is the name of the building?',
max: 200,
unique: true
},
'address': {
type: String,
label: "What is the street address?",
max: 200,
optional: true
},
'region': {
type: String,
allowedValues: ['Fort Simpson','Fort Smith','Yellowknife'],
label: "What region is the building in?",
autoform: {
firstOption: false,
options: 'allowed'
},
optional: false
},
'location': {
type: Schemas.Locations
}
});
Buildings.attachSchema(Schemas.Buildings);
Schemas.Locations = new SimpleSchema({
'type': {
type: String,
allowedValues: ["Point"]
},
'coordinates': {
type: Array,
minCount: 2,
maxCount: 2
},
'coordinates.$': {
type: Number,
decimal: true,
custom: function() {
if(!(0 <= this.value[0] <= 90))
return 'lonOutOfRange';
if(!(-180 <= this.value[1] <= 0))
return 'latOutOfRange';
}
}
});
Schemas.Locations.messages = {
lonOutOfRange: "Longitude out of range. Must be a positive number",
latOutOfRange: "Latitude out of range. Must be a negative number"
}