Is it possible to limit the dimensions/area of an editable shape in Google maps API v3 so that one cannot be drawn to large or small? -
i want able draw shapes (circles, polygons , rectangles) on google map place limits on size (area) of shape can drawn. taking circle example, desired behaviour user starts dragging mouse point on map form circle , circle hit invisible boundary , stop expanding.
i'll define size/area of shape geographical area covers. ideally able stipulate limits on geographical area shape covers. in circle example, specify circle stop expanding when geographical area covers reaches, 10 square kilometres, regardless of viewport zoom level.
i haven't though how work drawing polygon i'm sure it's bit more complicated because of fact polygon drawn in stages (multiple clicks)... 1 step @ time.
this best solution come circle scenario. note, doesn't explicitly stop circle's resize it's being edited, user releases resize, circle snaps maximum allowed size.
may not ideal per chrismarx & zeusakm notes above, there doesn't appear native way google's api set strict boundary on size user resizes.
var shapeoptions = { fillcolor: '#ff0000', fillopacity: 0.50, map: map, // map center: curlocation, // geo starting point draggable: true, editable: true, radius: 30 // initial circle radius in meters }; // add circle map. newcircle = new google.maps.circle(shapeoptions); var maxradius = 100; // whatever max size want dictate google.maps.event.addlistener(newcircle,'radius_changed',function(){ if (this.getradius() > maxradius) { this.setradius(maxradius); } }); if want create totally custom, solution may of use: how know radius while drawing circle on google maps
Comments
Post a Comment