M. Coutinho
M. Coutinho

Reputation: 305

Javascript: How can I force a string with decimal value to use point instead a comma?

I have for example:

 var locations = new google.maps.LatLng('@item.latitude', '@item.longitude', false);

@item.latitude value is for example: "43,321"

but i need it to be: 43.321

I need to force decimal separator as point not comma. How can I do this?

Upvotes: 1

Views: 259

Answers (1)

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35983

try this:

    var lat = '@item.latitude';
    var lng = '@item.longitude';
    var locations = new google.maps.LatLng(lat.replace(',','.'), lng.replace(',','.'), false);

Upvotes: 1

Related Questions