angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Markers not reloading on subsequent view load (ng-router issue)

Open ndicenso opened this issue 12 years ago • 18 comments

When loading markers on a fresh view/controller load, markers load fine. However, when navigating away (route to new view), and then back, the markers do not reload.

Details:

  • Using version 2.0.1
  • Loading approx 1000 markers
  • Using GoogleMapApi.then(function(maps) {}); to know when to load marker data
  • Using ui-router

Observations:

  • Using tilesloaded event instead from $scope.map.events works but needs a boolean condition to prevent from loading data every time tilesloaded gets called. Consider wrapping this with a promise for the "GoogleMapApi.then"
  • Using $timeout inside the GoogleMapApi.then callback seems to work consistently but feels dirty

ndicenso avatar Oct 11 '14 00:10 ndicenso

I have the same problem with 2.0.1 and ui-router. I don't use the async loading (GoogleMapApi.then (function(maps) {}). On fresh load it works fine, but when navigating through the app's stages - it's broken.

oktay89 avatar Oct 13 '14 11:10 oktay89

Yes, I'll look into it.

nmccready avatar Oct 13 '14 12:10 nmccready

I have the same issue. Just for information, could it be possible to save the current map state before switching view and reload saved content when going back to map view?

This kind on flow:

  1. Home page ("/")
  2. Go to map page ("/map") > first load
  3. Go back to home page > save map state
  4. Go again to map page > not re-execute the directive but load cached content instead

Shingaz avatar Oct 13 '14 18:10 Shingaz

@Shingaz That's something you will have to do yourself. No way we can/will implement this on our side

gitnik avatar Oct 14 '14 19:10 gitnik

@gitnik Understood =)

Shingaz avatar Oct 14 '14 19:10 Shingaz

have the same issue as @oktay89

dinodsaurus avatar Oct 15 '14 17:10 dinodsaurus

Same issue showing markers with directives

TFaga avatar Oct 16 '14 07:10 TFaga

Hi,

I have this exact same issue on Chrome.

On firefox, markers don't load at all and I have this error:

Error: Promise.defer is not a function
MarkerChildModel

at this line: this.deferred = Promise.defer();

Required bluebird lib seems loaded...

mathpere avatar Oct 16 '14 13:10 mathpere

@mathpere us sure it is loaded prior?

nmccready avatar Oct 16 '14 14:10 nmccready

I'm using browserify with this config and angular-google-maps is the only lib which is based on bluebird.

  "browserify-shim": {
    "angular-google-maps": {
      "depends": [
        "angular",
        "jquery",
        "lodash",
        "bluebird"
      ]
    }
/* ... */
}

mathpere avatar Oct 16 '14 14:10 mathpere

Ok make sure it is using the browser version of bluebird https://github.com/petkaantonov/bluebird/tree/master/js/browser

nmccready avatar Oct 16 '14 14:10 nmccready

Has anyone solved this. My markers are not visible on state change. I can confirm that they are being created, and appear on page reload, but I can't find a way around this. Thanks

Chise-Derrick avatar Oct 16 '14 20:10 Chise-Derrick

@rexthepenguin As I mentioned in the original post of this issue, there are a couple of work-arounds I found that allowed me to get past the issue temporarily. I know the team is already aware of the issue and is likely working on a fix, but you may consider the options mentioned above if you need something immediately.

ndicenso avatar Oct 16 '14 23:10 ndicenso

Same here, markers disappear :(

bogomips avatar Oct 20 '14 14:10 bogomips

@ndicenso I think the fix is the Promise needs to be reset. It is resolved from the previous load. This is why timeout causes the fix as it makes it behave like the legacy code.

nmccready avatar Oct 20 '14 22:10 nmccready

That makes sense. I look forward to integrating the update once it's ready. In the meantime, my half-baked work-around has not let me down. Thanks for following up.

ndicenso avatar Oct 21 '14 00:10 ndicenso

@ndicenso how did you manage to get around it? I have the same problem. Works perfectly with around 800 markers on page reload, but when I switch states (I'm using ui-router) markers disappear.

ghost avatar Oct 21 '14 08:10 ghost

@ionut-tanasa look at the changes on #782 to see what was changed.

nmccready avatar Oct 22 '14 02:10 nmccready