Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a resizable circle in google maps v3?

I have the following code, the circle is already moveable, now I want it to be resizeable:

  function init() {
    var mapCenter = new google.maps.LatLng(0, 0);
    var map = new google.maps.Map(document.getElementById('map'), {
      'zoom': 1,
      'center': mapCenter,
      'mapTypeId': google.maps.MapTypeId.ROADMAP
    });

    var marker = new google.maps.Marker({
      map: map,
      position: new google.maps.LatLng(55, 0),
      draggable: true,
      title: 'Drag me!'
    });

    var circle = new google.maps.Circle({
      map: map,
      radius: 3000000 // 3000 km
    });

    circle.bindTo('center', marker, 'position');
  }

  // Register an event listener to fire when the page finishes loading.
  google.maps.event.addDomListener(window, 'load', init);

Now, how can I do the resizer? I already read: http://code.google.com/intl/pt-BR/apis/maps/articles/mvcfun.html But there isn't another way to do that?

like image 826
Lucas Avatar asked May 12 '11 01:05

Lucas


Video Answer


1 Answers

The google.maps.Circle object has method .setEditable(true). The description from the docs says:

If set to true, the user can edit this circle by dragging the control points shown at the center and around the circumference of the circle.

like image 128
Tomas Avatar answered Oct 25 '22 23:10

Tomas