1

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?

1
  • 1
    You should format the number before sending it to JS. That's the easiest way. Commented Dec 13, 2013 at 8:59

1 Answer 1

1

try this:

    var lat = '@item.latitude';
    var lng = '@item.longitude';
    var locations = new google.maps.LatLng(lat.replace(',','.'), lng.replace(',','.'), false);
Sign up to request clarification or add additional context in comments.

3 Comments

Shouldn't that be .replace(',', '.')?
Thank you sir! I can finally go sleep in peace, after 5hours searching for the problem, i noticed that google map wasn't displaying markers because i had a point like this (43,123 , -7,123)! Obviously it was confused. I need to wait some time to accept answer :)
@veelen, yes! that way is correct one, thank you for that observation. I just copy paste, didn't notice that! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.