Search code examples
google-maps-api-3persian

persian city name in Distance Matrix API


How can I change the language? I mean how to write city names (origin,destination) in Persian? like this: destination = "تهران، ایران"

Below code works correctly:

<script src="http://maps.google.com/maps/api/js?sensor=true&language=fa"></script>
<script type="text/javascript">
var origin = "Karaj",
destination = "Tehran",
service = new google.maps.DistanceMatrixService();

But I want Persian names:

<script src="http://maps.google.com/maps/api/js?sensor=true&language=fa"></script>
<script type="text/javascript">
var origin = "کرج",
destination = "تهران",
service = new google.maps.DistanceMatrixService();

This doesn't work. What should I do?


Solution

  • Use a suitable encoding for the page(usually UTF-8)

    http://jsfiddle.net/doktormolle/9fsjM/