Zoom changes when switching between custom and standart MapProviders (AS3)
Hi I modified the ModestMapsSample.as so that i have 4 buttons to switch between "google hybrid", "yahoo hybrid" and two custom Mapprovider. The custom Mapprovider are on a AS3 Port of the AbstractZoomifyMapProvider-Class.
It works quite well except when I switch betwenn the custom Mapproviders the map gets a lower zoom (-1).
Does anybody knows how to stop this?
Thx in advance,
Jan
It works quite well except when I switch betwenn the custom Mapproviders the map gets a lower zoom (-1).
Does anybody knows how to stop this?
Thx in advance,
Jan
2
people have this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?I've just used trunk r688 and executed the ModestMapsSample (flash) untouched. It has the same problem when switching between the AC Transit example (based on AbstractZoomifyMapProvider) and the other providers. I created my own custom provider and see the same thing. If you look at the status bar, you'll see the zoom level is all wrong. It seems to recalculate the custom zoom level starting at zero. I have 5 zoom levels and they should go from 9 to 13.
This issue seems to have been around a long time. Any updates? I'd love to get this working. It would be absolutely fantastic to overlay a standard map provider onto a custom map!
Hoping for any help - Steve
I’m unsure
-
Inappropriate?Hi Steve,
Zoom levels are set by the map providers. The zoomify providers use the zoom levels specified by the zoomify tile filenames, so they won't match up with Google/Yahoo/Microsoft's maps.
In theory it's possible to write a zoomify map provider which would translate latitude, longitude and zoom from Google (etc.) into zoomify coordinates, but it's probably easier to find a way to chop your image up into the same coordinate system as the Google (etc.) tiles to begin with.
To overlay the maps they'll need the same projection exactly - Modest Maps can't reproject two different maps right now.
That's quite an involved process unfortunately, but my colleague Mike's tutorial here might provide some pointers: http://mike.teczno.com/notes/flea-mar... -
Inappropriate?Thank you for pointing me to Michal's example of combining historical maps. It's very cool and exactly what I'd like to do; historically and technically! However, I'm not sure I'm ready to go through the long and tedious exercise of producing tiles. I so wish a tile maker tool existed to match the projections of the major map providers. It would be a very well used tool.
I wonder if it would be fairly easy to approximate the zoom level when switching between zoomify tiles and the major map providers' tiles? Interestingly, when you switch from the default "MS Road" map to my "Iowa County, Iowa" map (My Modest Maps Sample), the zoom level translates beautifully. However, when switching back, the zoom level degrades. If you change the zoom level, you still get a good zoom translation when starting with MS Road or one of the other providers!? Of course, when switching from the zoomify tiles, things go badly because the zoom level is changed to 0-5 or however many tile sets you have (the status bar on the bottom tells the zoom-level story). I don't know why it works the other way around!
I may be wrong, but I can see a permanent change to AbstractZoomifyMapProvider, so that the zoom-level is translated correctly when switching to other providers. The reason is this: the zoom calculation for a DIY zoomify map, as determined by map transformation calculator, is a perfect match for all the other providers.
Not knowing the code structure, I think it would take me a long time to write a new AbstractZoomifyMapProvider; that and I'm brand new to Action Script/Flash, though it's close to many language structures.
The tile boundaries don't match up between the major providers and zoomify tiles, but they are in the ballpark, so it's completely livable.
If you or anyone want to play with the sample map I put up, you may see some possibilities for AbstractZoomifyMapProvider.
Steve
I’m thankful
-
Inappropriate?Hi Steve,
Overlaying tiles whose projections don't match up is beyond the scope of Modest Maps... the reprojection is really better done at the scanning and tile-cutting stage, I'm afraid.
However, I have some thoughts on the provider switching issue you've highlighted...
I think that the zoom levels appear to match up because when you change providers Modest Maps tries to maintain the visible area. The visible area is given by map.getExtent, and it's a MapExtent object that doesn't specify zoom level, but rather the latitudes and longitudes of the corners of the map. So it somewhat 'correctly' converts the zoom levels.
Sadly, reapplying the extent after switching map providers is a lossy process. The visible area changes when you switch the first time, and switching back changes it yet again. Each time it will get bigger to ensure that the requested area stays visible.
If this is posing a problem for you it might be a good idea to keep a 'user extent' around that is only updated when the map moves as a result of a click or drag - you could listen for the extentChanged event but ignore it during a provider change.
So you'd have a MapExtent instance and a flag to check for ignoring the changes:
public var userExtent:MapExtent;
public var ignoreChanges:Boolean = false;
And when you initialize the map, you'd add a listener for changes to the extent, pan, and zoom:
map.addEventListener(MapEvent.EXTENT_CHANGED, onExtentChanged);
map.addEventListener(MapEvent.STOP_PANNING, onExtentChanged);
map.addEventListener(MapEvent.STOP_ZOOMING, onExtentChanged);
userExtent = map.getExtent();
The extent changed handler would look like this:
public function onExtentChanged(event:MapEvent):void
{
if (!ignoreChanges) {
userExtent = map.getExtent();
}
}
And the map provider button handler would have something like this in it:
ignoreChanges = true;
map.setMapProvider(/* whatever */);
ignoreChanges = false;
map.setExtent(userExtent);
I haven't tested this so I'm not certain it will work (typos, bugs, etc.), but it should make the map provider switches more stable with regard to zoom level.
-
Inappropriate?Thanks very much for the reply and example. What you say about MapExtent makes sense. I know my attempt (read hack) at getting zoomify tiles to somewhat line up with the other providers will never be perfect; rightly so, it should be beyond the scope of Modest Maps! It's out of laziness to go through the process of creating correctly projected tiles. I think I will give your example a try in order to quickly move on, however, at a later date I do believe I will have a go at reprojecting the tiles.
Thanks again.
Steve
I’m appreciative
Loading Profile...





EMPLOYEE