Reputation: 715
I have the following problem. I have embedded a map using Google Maps' API. My intention is to bring some values from a .txt (cordenates), put them into a list, and then display them in the Map, with lines between each point. I have no problem doing this if I put the values manually in the list. But when I try to get them from the .txt file, the map is not shown in my page (the place where it should be is blank). BUT if I check in the source code the Script, it doesn't appear to have any problem... each point is shown as it should inside of the Script. This is a part from my View:
def base (request):
analyze_results('testing')
with open('data.txt') as f:
for line in f:
words = line.split()
points.append(words[1]+','+words[3])
return render_to_response('base.html', {'points': points, 'user_data': user_data})
points = []
If I manually asign the points list, and take away the
with open('data.txt') as f:
for line in f:
words = line.split()
points.append(words[1]+','+words[3])
it works perfectly.
Do you know what may be the problem?
Upvotes: 0
Views: 138
Reputation: 6779
I looked at your question history to learn more about what you're doing, and it looks like you have to clean up your text data before passing it to Google Maps. What's happening is the LatLng is being created as:
new google.maps.LatLng(38.4397984,061.1720742)
Notice that there's a '0' before 61.1720742, this is giving me "unexpected number" error in Chrome when I test it. You need to remove that zero. Also, the coordinates are "South" and "West", so you need to add a minus sign "-" to conform to Google Maps' LatLng format.
P.S. you can try strip('0')
to remove the 0, for example, '061.172000'.strip('0')
-> '61.172'
Upvotes: 1