I am working on something and i ran into a small problem because a variable is not defined and I cant figure out why.The vairalbe that is pointItem which is in the first like of the marker function
towards the very end
initialLocation = {
center:{
lat: 34.04129,
lng: -118.263667
},
zoom: 14
}
points = [
{
name: "Maccheroni Republic",
street:"332 South Broadway. ",
city:"Los Angeles, ",
state:"CA ",
zip:"90013",
food:"Italian",
lat: 34.050076,
lng: -118.248646,
map: map
},
{
name:"Baco Mercat",
street:"408 South Main Street. ",
city:"Los Angeles, ",
state:"CA ",
zip:"90013",
food:"Spanish-Fusion",
lat: 34.047847,
lng: -118.247222,
map: map
},
{
name:"Mex Peru Gipsy",
street:"414 E 12th St. ",
city:"Los Angeles, ",
state:"CA ",
zip:"90015",
food:"Mexican",
lat: 34.035217,
lng: -118.255887,
map: map
},
{
name:"Pie Hole",
street:"714 Traction Ave. ",
city:"Los Angeles, ",
state:"CA ",
zip:"90013",
food:"Pie & Bakery",
lat: 34.045429,
lng: -118.236258,
map: map
},
{
name:"Stumptown Coffee",
street:"06 S Santa Fe Ave. ",
city:"Los Angeles, ",
state:"CA ",
zip:"90021",
food:"Coffee Bar",
lat: 34.033292,
lng: -118.229707,
map: map
}
]
//This is going to be the initial map craetion
var map;
function initMap(){
map = new google.maps.Map(document.getElementById('map'), {
center: initialLocation.center,
zoom: initialLocation.zoom
});
ko.applyBindings(viewModel());
}
var point = function(obj){
this.name = ko.observable(obj.name);
this.street = ko.observable(obj.street);
this.city = ko.observable(obj.city);
this.state = ko.observable(obj.state);
this.zip = ko.observable(obj.zip);
this.food = ko.observable(obj.food);
this.lat = ko.observable(obj.lat);
this.lng = ko.observable(obj.lng);
this.map = ko.observable(map);
}
viewModel = function(){
var self = this;
var marker;
this.pointsList = ko.observableArray([]);
points.forEach(function(pointItem){
self.pointsList.push(new point(pointItem));
});
marker = new google.maps.Marker({
position: new google.maps.LatLng(pointItem.lat(), pointItem.lng()),
map: map,
animation: google.maps.Animation.BOUNCE
});
placeItem.marker = marker;
}
