My code does not work. I need to compare the value of the array to the value that was entered and return the latitude and longitude values in order to plot this point on the map, but only get the error Cannot read property Latitude of undefined.
var auto1 = [{"Latitude": 42.389, "Longitude": -8.567, title: "test"}];
var digit = document.getElementById('searchmap');
var ret = digit.value;
function search(namek, myarray){
for(var i=0; i<myarray.length; i++){
if(myarray[i].title === namek){
return myarray[i];
} else{ return false;
}
}
}
var obj = search(ret,auto1);
function showauto(){
var retu = new google.maps.LatLng(obj.Latitude,obj.Longitude);
map.setCenter(retu);
}
I want map.setCenter(retu) works. Thanks