Google maps object

This should be simple, I am adding a marker but there is a var called location that I think is an object.
I have this in a function.


    marker = new google.maps.Marker({
      position: location,
      map: map
    });
    markersArray.push(marker);

// the alert shows the correct location, lat lon.
alert(location);

// however replace has the error "Object doesn't support this property or method"
var lat_lon = location.replace(/3/i,"");

location is passed to the function as latLon as an on click event.

Thanks for looking.

You’re trying to do a replace, which is a method of the String class.

If you want to replace a value in the lat_lon you will probably need to access one of the properties of the object first (and possibly convert it to a string first).

E.g:


lat_lon.latitude.replace(/3/i, "")

btw you might want to check what the actual property is that you want to modify