The below sets a marker if I hard-code the latitude and longitude.
I want to instead pass it dynamically using place (an associative array) but I can't seem to make it work (I get errors saying I need to pass a number). I'm suspecting that I'm accessing the array incorrectly but can't find the right permutation of quotes and braces.
Any thoughts?
/**
* Adds marker for place to map.
*/
function addMarker(place)
{
// alert (JSON.stringify(place.latitude));
// TODO
var myLatLng = {lat: place["latitude"], lng: place["longitude"]};
// var myLatLng = {lat: place.latitude, lng: place.longitude};
// console.log(place);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: "Hello, world!"
});
marker.setMap(map);
}