Reputation: 71
I am building a travel organiser application in ASP.NET / C#.
At the moment, the user types in their destination, and my application sends the latitude and longitude to the Google Places API, which returns a list of hotels in the destination city.
The application then plots markers on Google Map (v3) for the hotels, but strangely only for some (small) cities. If I try a major city, or even a large town, the map just won't appear at all.
If 20 results are returned for hotels in Reykjavik, the hotels will be shown without a problem. If 20 results are returned for Dublin, Paris, or Glasgow.. (I think you get the picture!), the map won't show.
I have noticed that hotels in these small cities seem to be in a fairly concentrated area, so I have tried zooming out for larger cities, but that still won't work.
Does anybody have any idea why this would be?
Many thanks.
Upvotes: 0
Views: 228
Reputation: 71
I found the solution to this problem.
The issue was that I was not escaping apostrophe characters when I was reading in hotel and bar names from the Yelp API.
The reason that some cities were displaying and others were not is down to the general language used in that particular locale. Places like Dublin and Paris tend to have a higher number of instances of businesses with an apostrophe in their name (eg. "O'Haras, O'Reillys, L'Entre Potes, etc..), than say Reykjavik or Oslo, which was causing the map script to crash only in certain cities.
For those who didn't know, like me, you can escape apostophes using a backslash.
alert('O\'Neils Bar, Dublin');
Upvotes: 0