Your idea of using the setPaths method for updating the Polygon's coordinates was great, I don't need anything else!
I'll just check, when calling highlightCurrentMarker(), if highlightCircle exists, and if so, I'll just update its paths, instead of re-drawing it. Thanks! On Dec 20, 10:27 pm, Michał Biniek <[email protected]> wrote: > Hi, > > You can move polygon rather than erasing it and create new. For > example you can make function moveCurrentMarker (which is almost the > same as highlightCurrentMarker) and running it on "drag" event: > > google.maps.event.addListener(marker, "drag", function(){ > currentMarker = marker; > moveCurrectMarker(); > }); > > Code of moveCurrentMarker: > > function moveCurrectMarker() { > var markerPoint = currentMarker.getPosition(); > var mapNormalProj = overlayView.getProjection(); > var mapZoom = map.getZoom(); > var polyPoints = []; > var clickedPixel = mapNormalProj.fromLatLngToDivPixel > (markerPoint); > > var polySmallRadius = 20; > > var polyNumSides = 20; > var polySideLength = 18; > > for(var a=0; a<(polyNumSides+1); a++){ > var aRad = polySideLength * a * (Math.PI/180); > var polyRadius = polySmallRadius; > > var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad); > var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad); > > var polyPixel = new google.maps.Point(pixelX, pixelY); > var polyPoint = mapNormalProj.fromDivPixelToLatLng > (polyPixel); > polyPoints.push(polyPoint); > } > > highlightCircle.setPaths(polyPoints); > } > > There are still some problems with event 'mouseover' and 'click' - > when I dropped 'click' event the example still works. 'Mouseover' > event sometimes causes, that there are two polygons in the same place > in the same time - so opacity is higher (but only for the second :) > > Cheers, > Michal Biniek > > On 20 Gru, 03:12, kilkul <[email protected]> wrote: > > > Hi, > > > I've "translated" this great sample: > > >http://maps.examples.googlepages.com/highlightmarker.html > > > for API V3, here: > > >http://facut.ro/highlightmarker.html > > > The issue, as you might see, is that, unlike V2 of GMaps API, in V3, > > moving the polygon(s) in this manner leaves a "dirty" trace behind the > > one currently being dragged, while dragging. If the dragging occurs > > over an existing (bigger) polygon, the trace is even more visible (and > > lasting). > > > Is there any way of improving this, or will there be (soon) any API > > upgrade that might fix this issue? > > > Thanks! > > -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
