
LAST CODE - http://jsfiddle.net/YsQdh/88/ -
THIS VERSION USES gDouglasPeuker to create a rough polygon shape from an elongated version - http://jsfiddle.net/YsQdh/94/
^ This disables the map for drawing and turns it back on after creating a shape.
I am working on a Google Maps application. Unlike polygon point and click. I want to be able to draw a shape, which is then converted to a polygon.
Here is my last application - http://jsfiddle.net/Cbk9J/168/
I found the following code, but I'm not sure how to include it in the example. I have not found any documentation for free drawing, and I'm not sure if these features exist in the Google Map Drawing Manager.
var completeFreehand = function (changed) { if (changed) { isUserPolygon = true; updateLocation(); } unhighlightControls(); showMessages(); updateListingResults(); }; var completeDelete = function() { map.endDeleteSearchArea(); unhighlightControls(); showMessages(); }; var cancelDelete = function() { if (map.isDeletingSearchArea()) { completeDelete(); updateListingResults(); enableControls(); } return false; }; var cancelFreehand = function () { if (map.isDrawingFreehand()) { map.cancelFreehand(); completeFreehand(); enableControls(); } }; var clearMap = function (silent) { map.clearSearchArea(silent); mostRecentPinCount = 0; enableControls(); map.clearMarkers(true); return false; }; var drawFreehand = function (element) { if (map.isDrawingFreehand()) { cancelFreehand(); return; } else if (map.isDeletingSearchArea()) { completeDelete(); } disableControls(true); highlightControl(element); hideMessages(); if ( $(element).hasClass('js-maps-btn-add') ) { $('.js-maps-status-message-draw').removeClass('is-hidden'); } else { $('.js-maps-status-message-new').removeClass('is-hidden'); } map.clearMarkers(); map.drawFreehand(completeFreehand); updateBasePolygon(); return false; }; function updateBasePolygon () { if (typeof(basePolygon) == 'undefined') { var polys = map.getPolygons(); if (polys.length) { basePolygon = $.map(polys, function (val, i) { var a = val.getPath().getArray(); return [ $.map(a, function (val, i) { return [[ val.lat(), val.lng() ]]; }) ]; }); } } }
javascript google-maps
The old county
source share