Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

js maps 2d array


 / Published in: Other
 

  1. var locations=new Array(3);
  2. for (i=0; i <3; i++){
  3. locations[i]=new Array(3);
  4. }
  5.  
  6. locations[0][0]="dumap";
  7. locations[0][1]="56.467043";
  8. locations[0][2]="-2.864299";
  9.  
  10. locations[1][0]="edmap";
  11. locations[1][1]="55.936787";
  12. locations[1][2]="-3.208029";
  13.  
  14. locations[2][0]="inmap";
  15. locations[2][1]="57.479016";
  16. locations[2][2]="-4.224894";
  17.  
  18. for (i=0; i<locations.length; i++){
  19.  
  20. var el = locations[i][0];
  21. if ($('#'+el).length){
  22. var myLatlng = new google.maps.LatLng(locations[i][1],locations[i][2]);
  23. var myOptions =
  24. {
  25. zoom: 11,
  26. center: myLatlng,
  27. mapTypeId: google.maps.MapTypeId.ROADMAP
  28. }
  29.  
  30. var map = new google.maps.Map(document.getElementById(el), myOptions);
  31.  
  32. var marker = new google.maps.Marker(
  33. {
  34. position: myLatlng,
  35. map: map,
  36. title:"KLMP"
  37. });
  38. }
  39. }

Report this snippet  

You need to login to post a comment.