gpt4 book ai didi

google-maps-api-3 - Windows 应用商店应用程序上的 Google map (C#/XAML) - 无缩放缩放

转载 作者:行者123 更新时间:2023-12-01 05:14:48 25 4
gpt4 key购买 nike

有没有人能够在 Windows 应用商店应用程序 (C#/XAML) 上成功包含某种 Google map View ,用于 window 8.1 ?由于 Bing Maps 许可证的成本,我们选择了 Google Maps(这会更容易,因为 Bing Maps 有一个本地 Metro 控件)。

我能够关注 this article并在 WebView 控件中包含一个 html 页面。我还可以通过我的 C# 类与它进行通信(使用 ScriptNotify window.external.notify )。

但是,无法识别捏缩放手势,因为它不会在 map 上执行缩放。

这是我的 WebView

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="GridOut">
<WebView x:Name="MapWebView" ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Disabled" ManipulationMode="All" />
</Grid>
</Grid>

以及带有 map 的 html 页面:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10" /> <!-- To get double tap for zoom to work-->
<!– Google Maps API reference –>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=visualization"></script>
<script type="text/javascript" src="libs/richmarker.js"></script>
<script type="text/javascript" src="CountryInfo.js"></script>
<script type="text/javascript" src="libs/infobox.js"></script>
<!– map references –>
<link href="map.css" rel="stylesheet" />
<script src="map.js"></script>
</head>
<body>
<div id="mapdisplay" />
</body>
</html>

但是,如果我在 IE 中打开我的 HTML 页面(甚至在 Visual Studio Simulator 中使用 IE),捏到缩放手势就在那里并且工作顺利,所以我认为问题出在 WebView 上。另一方面,如果我将 WebView 导航到此 URL ,捏缩放会起作用,所以这真的让我感到困惑。

我也试过:

1) 在额外的 HTML 页面中使用 IFrame 但它没有改变任何东西。

2) 实现我自己的缩放 JavaScript 手势识别器(使用 MSGestureChange),但结果远非理想,我觉得我“重新发明了一个非常糟糕的轮子”......

有没有人遇到过这个问题?

提前致谢。

最佳答案

所以这就是我的工作,但它与实际的谷歌地图缩放相去甚远,因为:

1) 谷歌地图的捏合缩放不只是跳转到缩放级别,它还会缩放图 block 以实现平滑的动画/过渡。

2) 根据用户在屏幕上应用缩放的位置,它也倾向于平移到该区域(假设您以 LatLong 0、0 为中心,缩放级别为 2。如果用户捏住北极,则当您继续放大时,缩放级别应增加并逐渐向北极平移)。

var mGesture = new MSGesture();

function InitGestureHandler()
{

var mapDiv = document.getElementById('mapdisplay');
mGesture.target = mapDiv;

// You need to first register to MSPointerDown to be able to
// have access to more complex Gesture events
mapDiv.addEventListener("pointerdown", pointerdown, false);
mapDiv.addEventListener("MSGestureChange", manipulateElement, false);

}

function manipulateElement(e) {

//Can also add timestamps here to allow the code to run only every so milliseconds
if (e.scale > 1.05) {
map.setZoom(currentZoomLevel + 1);
}
else if (e.scale < 0.95) {
map.setZoom(currentZoomLevel - 1);
}
}

关于google-maps-api-3 - Windows 应用商店应用程序上的 Google map (C#/XAML) - 无缩放缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21703049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com