Hey guys, I’m new with JS and I’m trying to fiddle a little with Google Maps. I found a few tutorials and [URL=“http://econym.org.uk/gmap/example_categories.htm”]source codes, so I’m copy-pasting and trying to adapt it to my needs:
Here’s what I need to do:
- Load the map at a location
- Load some markers from a file (I’m using JSON atm but I think I’ll run into some problems later on)
- Place the markers in the map
- Put some checkboxes to toggle a group of markers.
Now, I was able to do it without step number 2 (source), but I can’t load them from a file. If you see the source code in the next link (not the previous one), the features array is empty (check the console.log), maybe it’s due to variable scoping? What can I do to avoid it? Here’s the source:
http://gonzalezmora.com/test/sitepoint/gmaps/
Thanks in advance!
PS: regarding the JSON problem, I have to put some HTML code in the files (like on line 87 in main.js), should I just put everything in one line, or should I use another format instead of JSON? If so, which one do you recommend?