Circle - setting radius after it is drawn not working for me

3,016 views
Skip to first unread message

RdotLee

unread,
Dec 29, 2011, 10:31:18 PM12/29/11
to google-map...@googlegroups.com
Hi -

  I can draw a circle on the map no problems.     What I want to do is set the radius to the value entered into an input field.   

  This all sounds pretty simple.

   function distanceChanged() {

        var val = $("#someinputfield").val();
        console.log(val);
        circle.set('radius', val);
        console.log(circle.get('radius'));
    }

 That does not change the circles radius.  The circle just disappears.   But in the console I get the value that was entered into the input field for the circles new radius.    The value entered is always in meters.

  Now if I hard code the new radius value it works!    What am I missing? 

 function distanceChanged() {
        circle.set('radius', 90000);
    }

 Why does coding an integer value work, but the value entered into the input field does not?

 I'm a totally newb to google maps.   Sorry if this is easy  :)

 thanks 


 

Barry Hunter

unread,
Dec 30, 2011, 7:12:03 AM12/30/11
to google-map...@googlegroups.com

Have you tried:

circle.set('radius', parseInt(val, 10) );

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/bB3b_FklARkJ.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

RdotLee

unread,
Dec 30, 2011, 10:18:24 AM12/30/11
to google-map...@googlegroups.com
Thanks barryhunter I will give that a try.   I'm guessing that will work.   I assumed wrongly that such a conversion would be handled by the api.

Thanks


RdotLee

unread,
Dec 30, 2011, 8:32:55 PM12/30/11
to google-map...@googlegroups.com
That did the trick.   Thx again for your help.
Reply all
Reply to author
Forward
0 new messages