Hi,
I'm working with the trunk version and I'm trying to use the new features that allows to use openstreetmap data directly in mapwingis. Does any one know if it's working in the trunk ? because I didn't manage to get it working sadly. The problem I have, is in the display of the tiles.
As I understand i have to do something like that:
At first i got a messagebox saying one of my parameters was of the wrong type. It seems there is a inconsistency between the code definition and the odl file on the trunk. So I change it and made the "key" parameter of BSTR type.
Then when i called the code nothing was happening, so i goolged some and found an old post somewhere from 2008 saying I had to specify the geoprojection in my map object. So I did like that:
The crash occure because of an unhandled exception in TilesDrawer.cpp
I don't want to make big modification to the code, I'm thinking i'm missing something but after some time looking at the problem i can't see what. I'll keep working on this but comments or ideas are welcome :)
I'm working with the trunk version and I'm trying to use the new features that allows to use openstreetmap data directly in mapwingis. Does any one know if it's working in the trunk ? because I didn't manage to get it working sadly. The problem I have, is in the display of the tiles.
As I understand i have to do something like that:
my_map.LoadTiles(my_map.GetExtents(), 256, key, tkTileProvider::OpenStreetMap);
where my_map is an object of type CMap1 in my application and key is a BSTR variable initilized to "OSM".At first i got a messagebox saying one of my parameters was of the wrong type. It seems there is a inconsistency between the code definition and the odl file on the trunk. So I change it and made the "key" parameter of BSTR type.
Then when i called the code nothing was happening, so i goolged some and found an old post somewhere from 2008 saying I had to specify the geoprojection in my map object. So I did like that:
IGeoProjectionPtr pProj = NULL;
pProj.CreateInstance( __uuidof(GeoProjection));
VARIANT_BOOL res= VARIANT_FALSE;
CString sProj = _T("+proj=longlat +datum=WGS84 +no_defs");
BSTR sProjBstr = sProj.AllocSysString();
pProj->ImportFromProj4(sProjBstr, &res);
SysFreeString(sProjBstr);
my_map.SetGeoProjection(pProj);
Now the system began to work. I could see MakeTileImageUrl being called in OpenStreetMapProvider which generated a valid URL, I could see that a bitmap was allocated in memory etc. But after that MapWingis crashed.The crash occure because of an unhandled exception in TilesDrawer.cpp
void CTilesDrawer::DrawTiles(ITiles* cotiles, double pixelsPerMapUnit,
IGeoProjection* mapProjection, BaseProjection* tileProjection, bool printing)
on line 54customProj = dynamic_cast<CustomProjection*>(tileProjection);
tileProjection as its name says comme from the tile provider and for OSM it's of type MercatorProjection so it's normal for the cast to fail. I tried several changes but none displayed the tiles correctly :(I don't want to make big modification to the code, I'm thinking i'm missing something but after some time looking at the problem i can't see what. I'll keep working on this but comments or ideas are welcome :)