none
Bing Map in VS2010 RRS feed

  • Question

  • I'm using Qt in Visual Studio 2010 and in a QWebView i load the following HTML-Code

    //------------------------------------------HTML FILE-------------------------------------------------
    #define MAP_HTML "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><title></title>"\
    	"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"\
    	"<script type=\"text/javascript\" src=\"http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0\"></script><script type=\"text/javascript\">"\
    	"var map = null;"\
    	"function viewChanged(){MobileDataVisualAnalyticsMap.loaded()}"\
    	"function viewChangeStarted(){MobileDataVisualAnalyticsMap.viewChangeStart()}"\
    	"function mouseMoved(e){if (e.targetType == \"map\") {var point = new Microsoft.Maps.Point(e.getX(), e.getY());var loc = e.target.tryPixelToLocation(point);MobileDataVisualAnalyticsMap.mouseMoved(loc.latitude, loc.longitude);e.handled = false;}}"\
    	"function clicked(e){MobileDataVisualAnalyticsMap.mapClick(); e.handled = false;}"\
    	"function GetMapByBounds(northWestLatitude, northWestLongitude, southEastLatitude, southEastLongitude, mapType){"\
    	"var boundingBox = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(northWestLatitude,northWestLongitude), new Microsoft.Maps.Location(southEastLatitude,southEastLongitude));"\
    	"map = new Microsoft.Maps.Map(document.getElementById(\"mapDiv\"),{credentials: \"KeyDeleted\","\
    	"bounds: boundingBox, mapTypeId: mapType, enableSearchLogo: false, enableClickableLogo: false, showScalebar: false, showCopyright: false, showDashboard:false});"\
    	"Microsoft.Maps.Events.addHandler(map, 'viewchangeend', viewChanged); "\
    	"Microsoft.Maps.Events.addHandler(map, 'viewchangestart', viewChangeStarted); "\
    	"Microsoft.Maps.Events.addHandler(map, 'mousemove', mouseMoved); "\
    	"Microsoft.Maps.Events.addHandler(map, 'click',clicked);"\
    	"}"\
    	"function GetMap(latitude, longitude, zoomfactor, mapType, mapHeading){"\
    	"map = new Microsoft.Maps.Map(document.getElementById(\"mapDiv\"),{credentials: \"KeyDeleted\","\
    	"center: new Microsoft.Maps.Location(latitude,longitude),mapTypeId: mapType,zoom: zoomfactor, enableSearchLogo: false, enableClickableLogo: false, showScalebar: false, showCopyright: false, showDashboard:false, heading: mapHeading});"\
    	"Microsoft.Maps.Events.addHandler(map, 'viewchangeend', viewChanged); "\
    	"Microsoft.Maps.Events.addHandler(map, 'viewchangestart', viewChangeStarted); "\
    	"Microsoft.Maps.Events.addHandler(map, 'mousemove', mouseMoved); "\
    	"Microsoft.Maps.Events.addHandler(map, 'click',clicked);"\
    	"}"\
    	"</script></head>"\
    	"<body onload=\"GetMap(46.5269,6.56573, 15, Microsoft.Maps.MapTypeId.road, 0);\">"\
    	"<div id=\"mapDiv\" style=\"width:100%; height:100%\"></div>"\
    	"</body></html>"
    
    //----------------------------------------END OF HTML FILE-------------------------------------------


    Under 32 bit zoom and pan works fine with every zoom factor. Now i changed to the 64 bit version of Qt and the map is loading perfectly above zoom factor 15, which is the default-value by loading the html. I can zoom in and pan around, all works fine. If i zoom out (zoom factor < 15) the map does not render more than i see with zoom factor 15. So i have a grey border around the map, which is expanding if i zoom more out. If i pan around the map acts like a static map and shows always the same pane.
    Changing the default value of the zoom factor didn't change anything. If i take for example zoom factor 10 the map doesn't show anything till i zoom in and reach zoom factor 15.
    Under the 32 bit version of Qt all works fine, its just the 64 bit version that shows this behaviour.
    Does anyone have an idea about this?

    Best regards from Germany

    Theo Rehm


    • Edited by Theorembeweiser Monday, February 13, 2012 3:37 PM
    • Moved by Ricky_Brundritt Friday, March 16, 2012 6:51 PM (From:Bing Maps: Map Control and Web services Development)
    Monday, February 13, 2012 1:20 PM

Answers

  • Solved it! :-D
    The problem was, that QWebView didn't show GIF and/or JPEG images.
    Solution:
    1. In the directory where your Qt application is located, create a subdirectory with imageformats name.
    2. Copy the image plug-ins from the following directory: $(QTDIR)\plugins\imageformats

    Thursday, March 8, 2012 3:51 PM

All replies

  • Seems to be a problem with VS2010 x64 build.
    With x86 build of VS2010 both versions (64 bit - 32 bit) of Qt work fine with the bing map. With the x64 build both versions show the issue descriped above.
    Any ideas?
    Wednesday, February 22, 2012 5:44 PM
  • Small addition: Neither the aerial, nor the birdseye view shows anything. Only the road map works above zoom factor 15. :-/
    Friday, March 2, 2012 12:17 PM
  • You haven't specified a position property for your map div. This is required. Try adding "position:relative;" to the style property of your map div.

    http://rbrundritt.wordpress.com

    Friday, March 2, 2012 3:22 PM
  • Thx for your reply. ;-)

    With the position property the map doesn't show anything at all. :-/

    <div id=\"mapDiv\" style=\"position:relative; width:100%; height:100%\"></div>



    Tuesday, March 6, 2012 4:47 PM
  • Can you try with a fixed value for the width and height.
    Also you should consider to start by removing your own event code so you'll be only loading the map.

    You might consider using the MarketPlace option in the URL to use German tiles (add mkt=DE-de  at the end of the control script reference)


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/

    Wednesday, March 7, 2012 10:27 AM
    Moderator
  • The fixed value doesn't change the problem.
    Removing my own event code was the first thing i made. I just tested it again with this code:

    #define TEST_HTML "<html>"\
    "<head><title></title>"\
    "<script type=\"text/javascript\" src=\"http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=DE-de\"></script>"\
    "<script type=\"text/javascript\">"\
    "function GetMap(){"\
    "var map = new Microsoft.Maps.Map(document.getElementById(\"mapDiv\"),{credentials: \"Key\","\
    "center: new Microsoft.Maps.Location(46.5269,6.56573),mapTypeId: Microsoft.Maps.MapTypeId.road,zoom: 15});"\
    "}"\
    "</script>"\
    "</head>"\
    "<body onload=\"GetMap();\">"\
    "<div id=\"mapDiv\" style=\"width:300; height:300\"></div>"\
    "</body></html>"

    I also removed the QGraphicsview and other things, so that i purely have a QWebView with the map in it. But the map shows the same issue as with the code i posted above.

    Wednesday, March 7, 2012 2:39 PM
  • Well, you should put unit on the CSS values and add the position:relative property and value. Also make sure that Content type are set and DocType too like in your first code.
    Make sure that external JavaScript can be executed but I must say that I can't help you with the Qt dev. Try to add some tracking code (alert could be simple) so you can follow where the javascript is executed and where it stops if so.

    If a simple web page cannot show, there must be a problem outside this one. And I'm pretty sure you fall with the same result in your analysis.


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/

    Wednesday, March 7, 2012 2:44 PM
    Moderator
  • Solved it! :-D
    The problem was, that QWebView didn't show GIF and/or JPEG images.
    Solution:
    1. In the directory where your Qt application is located, create a subdirectory with imageformats name.
    2. Copy the image plug-ins from the following directory: $(QTDIR)\plugins\imageformats

    Thursday, March 8, 2012 3:51 PM