seikur0 / PGO-mapscan-opt

GNU General Public License v3.0
111 stars 50 forks source link

iOS 10 MobileSafari zoom problems #266

Open c00ni opened 8 years ago

c00ni commented 8 years ago

Sometimes (frequently) the map glitches out and the Pokémon icon size doesn't maintain their size and refuse to get smaller again. Map tiles at different zoom levels also stop loading. Markers remain functional but are also massive.

I believe this happens when you try to zoom in whilst new data is being fetched, or something related to that. EDIT: See near the bottom of comments to see the real cause

Page must be reloaded (not refreshed) to fix.

http://m.imgur.com/atIAc4G Ignore that %, I'm just mucking around with stuff.

seikur0 commented 8 years ago

I'm not sure, this might be fixed with the new server now.

c00ni commented 8 years ago

It is not =/

seikur0 commented 8 years ago

It's more a problem with the zooming putting too much graphical strain on your mobile, I'm not sure, how to help you with this.

c00ni commented 8 years ago

Hmmm I would have imagined it may lag but eventually load properly... but it just doesn't. I guess we can leave this open until someone figures it out?

seikur0 commented 8 years ago

I remember that from earlier, when the icons weren't optimized yet and I still used the simpleHTTPServer, that this happened, but it hasn't happened to me in a long time. I'll keep an eye on it

seikur0 commented 8 years ago

And he accidentally closed it :D

c00ni commented 8 years ago

It happens even when there's almost no pokemon on the map, and happens on an iPhone 7 as well so I don't think it's gfx strain.

Actually, I think it may have started after the icons were merged into the one file to reduce load?

is there a quick way of temp. reverting it?

seikur0 commented 8 years ago

A quick way? Split the sprite into single icons and change the code in mapscan.js.

c00ni commented 8 years ago

I've half figured it out,

If you pinch to zoom with both fingers on a pokemon icon each, it zooms in/out the whole page's visible layer instead of adjusting the zoom level of the map tiles.

Once the icons are massive, you can "fix" it by zooming out with both fingers on a pokemon icon.

Zooming with one finger on a pokemon and the other on empty map space works properly.

Still unsure how to fix but at least the cause has been found.

seikur0 commented 8 years ago

Mkay, interesting cause.

I guess there are two things, you can try.

First, in the constructor for the markers, line 172 of mapscan.js, try setting it to optimized=true, that should probably be changed anyway and may change that behavior.

Second, you could add code like this to mapscan.js:

google.maps.event.addListener(map, 'zoom_changed', function() {
  for (var i = 0; i < markers.length; i++) {
    markers[i].setIcon(markers[i].getIcon());
  }
});

Or instead of resetting the icon, set it to invisible and then visible or anything else, that comes to mind. See this.

c00ni commented 8 years ago

Nothing worked I wouldn't imagine it's to do with the map's zoom level - the map thinks the zoom level hasn't changed, the layer/canvas/whatever you call it that the map is drawn on is changing zoom level. Hmmm, will look around for other solutions...

seikur0 commented 8 years ago

Okay then rather than changing the icon of the markers unbind them from the map with .setMap(null) and rebind them with .setMap(map), maybe like that?

seikur0 commented 8 years ago

Or you listen to the dragstart event of the map, I think that should be fire, when you start the zoom. In that use map.setClickableIcons(false) and then in the dragend event map.setClickableIcons(true). If these events don't fire, try the bounds_changed and idle events instead.

c00ni commented 8 years ago

Am trying to implement possible solutions you suggest. Am inexperienced cry

but I don't think dragstart will fire because the issue is that you're not actually dragging / tapping the map at all, just the markers? (because normally the zoom/drag events are properly handled to change the map tiles instead of dragging/zooming the whole page)

seikur0 commented 8 years ago

That's why I said I wasn't sure, about that being the correct event, add a listener and put console.log('hey') in it. I can't be the only one, who uses 'hey' as the check word, right? :D

dikkedeur commented 8 years ago

i can confirm this, this was not happening on ios 9.x, it came with ios10, so the new safari has some problems with zooming in and then out and then icons of the pokemons stay big, so cluthering the screen.

seikur0 commented 8 years ago

That's funny, because yesterday I saw an old post about the same thing happening in ios 6.0, when it didn't happen in ios 5.0 before. I think it was 6 and 5 anyways. Did they reintroduce an ancient bug?

dikkedeur commented 8 years ago

no idea if it is a bug re-introduced.. all i know that on safari on ios 9.x it didnt happen.