Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. function useTheData(doc){
  2. console.log("Starts Parse");
  3. console.log(doc[0].placemarks.length);
  4. for (var i = 0; i < doc[0].placemarks.length; i++){
  5. console.log("i: "+i+", placemark:");
  6. console.log(doc[0].placemarks[i]); //here the .marker property exists in the console
  7. console.log(".marker:");
  8. console.log(doc[0].placemarks[i].marker); //here it says it's undefined!
  9. if(doc[0].placemarks[i].polyline){ //check if it's a polyline
  10. google.maps.event.addListener(doc[0].placemarks[i].polyline, 'click', select_option);
  11. }
  12. else{
  13. console.log("### i = "+i);
  14. console.log("1");
  15. console.log(doc[0].placemarks[i].marker); //here, the exact same object, doesn't have the marker property!
  16. console.log("2");
  17. google.maps.event.addListener(doc[0].placemarks[i].marker, 'click', select_option); //Because of that, the first time the page loads, it get's stuck in the function cuz it can't access the .marker
  18. console.log("3");
  19. doc[0].placemarks[i].marker.setIcon({
  20. url: "img/bola.png",
  21. scaledSize: new google.maps.Size(10, 10),
  22. anchor: new google.maps.Point(5, 5)
  23. });
  24. console.log("4");
  25. }
  26. }
  27. console.log("End Parse");
  28. google.maps.event.addListener(map, 'click', select_option);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement