AckerApple / agm-overlays

Custom marker overlay for the @agm/core package
MIT License
25 stars 24 forks source link

Cannot update position of overlay #4

Closed quadband closed 6 years ago

quadband commented 6 years ago

The initial rendering of the overlay works fine, but when I update the lat/lng of the marker it does not update.

I went digging in the source and found a few issues. Imports not being used : Subscription, EventEmitter, TemplateRef, QueryList, AgmInfoWindow, LatLngBounds, LatLng, AgmMarker, GoogleMap

Are these still necessary?

Additionally, you are not importing AfterViewInit, OnChanges, or OnDestroy from @angular/core

I'm not seeing a call to MarkerManager.updateMarkerPosition

Within overlayView.draw your point will never change as it can never obtain a new lat/lng from the variable latlng as it is defined up above.

I'm wondering if there were some breaking changes made upstream.

I am using Angular 6 and the latest release of AGM.

quadband commented 6 years ago

I modified the following and resolved my issue:

  onChangesOverride( changes ){
    if( (changes.latitude || changes.longitude) ){
      this.overlayView.latitude = this.latitude;
      this.overlayView.longitude = this.longitude;
      this.overlayView.draw()
    }
  }
    this.overlayView.draw = function(){
      if ( !this.div ) {
        this.div = elm
        this.getPanes().overlayImage.appendChild( elm )
      }

      let latlngnew = new google.maps.LatLng(this.latitude,this.longitude)

      const point = this.getProjection().fromLatLngToDivPixel( latlngnew )

      if (point) {
        elm.style.left = (point.x - 10) + 'px'
        elm.style.top = (point.y - 20) + 'px'
      }
    }
AckerApple commented 6 years ago

I’ll check it out tomorrow

tsgreenberg1217 commented 6 years ago

@quadband you can now download 1.1.2. The issue should be fixed now Also, the demo page has parameters where you can update the overlays.

AckerApple commented 6 years ago

I will be closing this issue in the near future if no further comments

quadband commented 6 years ago

Thanks much!

jvv commented 5 years ago

This issue re-appeared, at least on the 1.3.0 release. When switching to 1.1.2 (as suggested above) the repositioning works.

AckerApple commented 5 years ago

Confirmed. Demo seems to still update marker position however an error is thrown in console.