Board index » cppbuilder » capture maps

capture maps


2008-03-14 07:35:08 PM
cppbuilder53
Hello,
Using TCppWebBrowser I made an application to show Google Maps or Microsoft
Virtual Earth.
Now I'm looking for a way to capture those maps in a jpeg.
I wonder if someone has an idea to do this.
Thanks,
regards
Anton
 
 

Re:capture maps

Quote
Using TCppWebBrowser I made an application to show Google Maps or
Microsoft Virtual Earth.

Now I'm looking for a way to capture those maps in a jpeg.

I did this a while ago (if I remember correctly, I owe Remy a credit or two):
TComInterface<IHTMLDocument2>Doc;
TComInterface<IHTMLStyle>Style;
TComInterface<IHTMLElement>Body;
TComInterface<IHTMLBodyElement>BodyElement;
TComInterface<IViewObject>ViewObject;
{ if(SUCCEEDED(web->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc)))
{ if(SUCCEEDED(Doc->get_body(&Body)))
{ if(SUCCEEDED(Body->QueryInterface(IID_IHTMLBodyElement,(LPVOID*)&BodyElement)))
{ BodyElement->put_noWrap(VARIANT_TRUE);
// hide scrollbars
if( SUCCEEDED(Body->get_style(&Style)))
Style->put_borderStyle(WideString("none"));
BodyElement->put_scroll(WideString("no"));
web->Document->QueryInterface(IID_IViewObject,(LPVOID*)&ViewObject);
if(ViewObject)
{ RECT SourceRect=Rect(0,0,web->Width,web->Height);
Graphics::TBitmap *bitmap=new Graphics::TBitmap;
bitmap->PixelFormat=pf32bit;
bitmap->Height=web->Height;
bitmap->Width=web->Width;
if(SUCCEEDED(ViewObject->Draw(
DVASPECT_CONTENT,1,NULL,NULL,
this->Handle,bitmap->Canvas->Handle,
(_RECTL *) &SourceRect, NULL, NULL,0)))
{ ...
delete bitmap;
}
}
}
}
}
}
 

Re:capture maps

Thank you very much for your answer.
Maybe I will try it, but by accident I found an easier way to download the
images.
Nevertheless thanks again.
regards,
Anton
"Brian" < XXXX@XXXXX.COM >schreef in bericht
Quote
>Using TCppWebBrowser I made an application to show Google Maps or
>Microsoft Virtual Earth.
>
>Now I'm looking for a way to capture those maps in a jpeg.
>
I did this a while ago (if I remember correctly, I owe Remy a credit or
two):

TComInterface<IHTMLDocument2>Doc;
TComInterface<IHTMLStyle>Style;
TComInterface<IHTMLElement>Body;
TComInterface<IHTMLBodyElement>BodyElement;
TComInterface<IViewObject>ViewObject;

{
if(SUCCEEDED(web->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc)))
{ if(SUCCEEDED(Doc->get_body(&Body)))
{
if(SUCCEEDED(Body->QueryInterface(IID_IHTMLBodyElement,(LPVOID*)&BodyElement)))
{ BodyElement->put_noWrap(VARIANT_TRUE);
// hide scrollbars
if( SUCCEEDED(Body->get_style(&Style)))
Style->put_borderStyle(WideString("none"));
BodyElement->put_scroll(WideString("no"));

web->Document->QueryInterface(IID_IViewObject,(LPVOID*)&ViewObject);
if(ViewObject)
{ RECT SourceRect=Rect(0,0,web->Width,web->Height);
Graphics::TBitmap *bitmap=new Graphics::TBitmap;
bitmap->PixelFormat=pf32bit;
bitmap->Height=web->Height;
bitmap->Width=web->Width;
if(SUCCEEDED(ViewObject->Draw(
DVASPECT_CONTENT,1,NULL,NULL,
this->Handle,bitmap->Canvas->Handle,
(_RECTL *) &SourceRect, NULL, NULL,0)))
{ ...
delete bitmap;
}
}
}
}
}
}


 

{smallsort}

Re:capture maps

Quote
Maybe I will try it, but by accident I found an easier way to download the
images.
Anton
I would be interested in how you did this - could you please explain and
perhaps share the code used to do this?
thanks
daryl
 

Re:capture maps

Hi Daryl,
At first I have to say I feel very sorry that I did not see your question
earlier.
Nevertheless here is the answer, maybe you don't need it anymore, but in
that case just forget it.
In fact this solution has not much to do with C++.
In the first place you need the VirtualEarth Tile Name
generator:www.gnewt.org/timoney/vetileinfo.php
This php-application generates the name of the picture by inputting the lat
& lon coordinates.
if you put 0,50,4,51,10 for min lon, min lat, max lon, max lat and zoomlevel
10
you will receive several names.
Then you can put the name in the next sentence and you get the picture
t0.tiles.virtualearth.net/tiles/h0313131331.pg
the h stands for hybrid I think.
I suppose there are more combinations available, but this is what I found
out.
Regards
Anton
"Daryl" < XXXX@XXXXX.COM >schreef in bericht
Quote
>Maybe I will try it, but by accident I found an easier way to download
>the images.

Anton
I would be interested in how you did this - could you please explain and
perhaps share the code used to do this?

thanks
daryl