Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

javascript - scaleControl not displaying correctly in .net

I am trying to include a scaleControl on a Google Map running in a WebBrowser control in WPF.

Everything works fine, except when I try to enable the scaleControl. It displays as a white box. (see below)

I am initializing the map as follows:

var myOptions =
        {
            zoom: 2,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scaleControl: true
        };
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

If you click the white rectangle, it changes size (as expected when changing units). A screenshot of the rectangle is below.

enter image description here

I believe this issue might be related to the fact I am using the map in a WPF WebBrowser element. As I have seen this issue somewhere else and that was also using WPF.

Any ideas on how to correctly display this scaleControl?

UPDATE:

From DormantOden's answer, I have managed to fix my issue and get the ScaleControl to work.

I went into the registry and added the following values:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION"MY APP NAME".exe

&

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION"MY APP NAME".exe

I set the value to 0x2AF7, which according to DormantOden's link, causes the WebBrowser control to run as IE10 instead of IE7.

The scaleControl now renders correctly

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I suspect this is due to the WPF WebBrowser element defaulting to rendering with old versions of IE.

See here on how to specify the IE version used. It will likely fix your issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...