www.webdeveloper.com
Results 1 to 2 of 2

Thread: arrowheads on polylines from a select box

  1. #1
    Join Date
    Nov 2010
    Posts
    1,102

    arrowheads on polylines from a select box

    Hi,

    I'm trying to write a function that will show arrowheads on polylines selected from a dropdown menu in a google map. I only want the arrowheads that belong to the line shown to be displayed.

    I have got it working using check boxes, and the dropdown shows the lines, but am having trouble tweaking the code to get the arrows to show up as well. You can see the working checkboxes here: http://www.xelawho.com/map/zonesarrowstest.htm

    I posted this on the googlemaps forum, but they basically told me it was a javascript problem... any advice hugely appreciated.

  2. #2
    Join Date
    Nov 2010
    Posts
    1,102

    a snippet

    Hi again,

    so, looking through the other posts on the forum I notice that alot of people post code snippets instead of links. I'm not whining about not getting a reply to my query, just hoping to go with the flow and hopefully get one

    so here's what I think is the relevant code. Thanks in advance for any help.

    Code:
    var h = 0;
    
       function createArrow(point,icon,category) {
            var arrows = new GMarker(point,icon);
    		map.addOverlay(arrows);
    		arrows.hide(); 
    		arrows.mycategory = category;                                 
            pts.push(arrows);
    		}
    
    var select_html = '<select onChange="handleSelected2(this)" + "selclick(this)">' +  
                            '<option selected> - Select a bus route - <\/option>';
    
    	  function showsel(category) {
            for (var v=0; v<pts.length-1; v++) {
    		 if (pts[v].mycategory == category) {
                pts[v].show();
    		  }
            }
          }
    	  
          function hidesel(category) {
    	  for (var v=0; v<pts.length-1; v++) {
    		 if (pts[v].mycategory == category) {
                pts[v].hide();
    		  }
            }
    }
    	  
    	 function selclick(option,category) {
            if (option.selected) {
              showsel(category);
            } else {
              hidesel(category);
            }
    		}					
    						
    						 function handleSelected2(opt,category) {     
      for (var h = 0; h <gpolylines.length; h++) {
    		  gpolylines[h].hide();
            }
            var h = opt.selectedIndex - 1; 
            if (h > -1) {
              gpolylines[h].show();
    		  }
    		  for (var v=0; v<pts.length; v++) {
                   selclick(category); 		
    			   }
    }	
    
     GDownloadUrl("allzonesencoded.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
    
    var lines = xmlDoc.documentElement.getElementsByTagName("line");
    
    for (var i=0; i< pts.length; i++) {
    		var category = lines[a].getAttribute("category");
    		}
    
    select_html += '<\/select>' ;
            document.getElementById("selection2").innerHTML = select_html;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles