Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Question about showing/hiding polylines
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
iwotic  
View profile  
 More options Nov 6, 5:29 pm
From: iwotic <aunah...@gmail.com>
Date: Thu, 5 Nov 2009 22:29:27 -0800 (PST)
Local: Fri, Nov 6 2009 5:29 pm
Subject: Question about showing/hiding polylines
I am a newbie in Google Maps API, I got a question about showing and
hiding a polylines. My goal is to click a checkbox, a polyline will
show up on the map. I got this part done. However, when I uncheck the
box, I want the line to disappear. I am not sure how I can do it.
After looking around, it seems like people use removeOverlay()
and .hide() function but I couldn't get it to work.

Here is how  the checkbox in my code work:
 side_bar_html += '<form name=testform>130 East <INPUT TYPE="checkbox"
NAME="Item1" VALUE="1"  onClick="javascript:myclick()"></form>';

in the myclick(), i have this:
var polyline = new GPolyline([new GLatLng(40.110484,-88.227189),new
GLatLng(40.110418,-88.228386), new GLatLng(40.11012,-88.228865)],
"#ff0000", 5);
map.addOverlay(polyline);

This is something I want my check and uncheck box to do:
http://www.geocodezip.com/GenericMapBrowser.asp?filename=RiverWalk080...

Can some one please help me?? What should I do? Thank you!!


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile  
 More options Nov 6, 6:46 pm
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Thu, 5 Nov 2009 23:46:07 -0800 (PST)
Local: Fri, Nov 6 2009 6:46 pm
Subject: Re: Question about showing/hiding polylines
On Nov 5, 10:29 pm, iwotic <aunah...@gmail.com> wrote:

My map works.  A link to yours (that doesn't) might let me (or someone
else)   make a recommendation as to why yours doesn't.  That is why
the posting guidelines request a link to your map that shows the
problem.

  -- Larry


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin  
View profile  
 More options Nov 6, 9:25 pm
From: Martin <warwo...@gmail.com>
Date: Fri, 6 Nov 2009 02:25:26 -0800 (PST)
Local: Fri, Nov 6 2009 9:25 pm
Subject: Re: Question about showing/hiding polylines
Try something like this.

1) Add 'this.checked' to your function call:

side_bar_html += '<form name=testform>130 East <INPUT TYPE="checkbox"
NAME="Item1" VALUE="1"  onClick="myclick(this.checked)"></form>';

(No need to use 'javascript:' in that onClick handler btw).

2) Create your polyline just once - it needs to be created outside of
any functions so that 'myPolyline' is a global variable and then your
myclick() function can access it:

var myPolyline = new GPolyline([new GLatLng(40.110484,-88.227189),new
GLatLng(40.110418,-88.228386), new GLatLng(40.11012,-88.228865)],
"#ff0000", 5);

3) Update your myclick() function:

function myclick(state){
 if(state){
  // show polyline
  map.addOverlay(myPolyline);
 } else {
  // remove polyline
  map.removeOverlay(myPolyline);
 }

}

Martin.

On 6 Nov, 06:29, iwotic <aunah...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
iwotic  
View profile  
 More options Nov 7, 8:07 am
From: iwotic <aunah...@gmail.com>
Date: Fri, 6 Nov 2009 13:07:13 -0800 (PST)
Local: Sat, Nov 7 2009 8:07 am
Subject: Re: Question about showing/hiding polylines
Got it to work! Thank you Martin! Your suggestion works perfectly.
I think the problem with me previously was that I used local variable
instead of using a global variable.

On Nov 6, 4:25 am, Martin <warwo...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google