gpt4 book ai didi

windows-phone - 如何在 Windows Phone 8 中显示多个图钉

转载 作者:行者123 更新时间:2023-12-04 04:58:48 24 4
gpt4 key购买 nike

有人请为我修复此代码。我不能显示多个图钉:(
或者给我一些关于显示图钉的链接。泰:)

// Creat point
GeoCoordinate p1 = new GeoCoordinate(21.0178, 105.8303);
GeoCoordinate p2 = new GeoCoordinate(21.0076, 105.8414);
// Show center map
this.myPushpins.Center = p1;
this.myPushpins.ZoomLevel = 13;
// Creat Pushpins
Pushpin pp = new Pushpin();
// Creat MapOverLap
MapOverlay overlay1 = new MapOverlay();
overlay1.Content = pp;
overlay1.GeoCoordinate = new GeoCoordinate(21.0178, 105.8303);
MapOverlay overlay2 = new MapOverlay();
overlay2.Content = pp;
overlay2.GeoCoordinate = new GeoCoordinate(21.0076, 105.8414);
// Creat Maplayer
MapLayer layer = new MapLayer();
layer.Add(overlay1);
layer.Add(overlay2);
myPushpins.Layers.Add(layer);

最佳答案

您正在设置 overylay1 的内容和 overylay2到同一个 Pushpin对象实例。您需要有两个不同的 Pushpin 实例。 .试试这个代码:

    // Creat point
GeoCoordinate p1 = new GeoCoordinate(21.0178, 105.8303);
GeoCoordinate p2 = new GeoCoordinate(21.0076, 105.8414);
// Show center map
this.myPushpins.Center = p1;
this.myPushpins.ZoomLevel = 13;
// Creat Pushpins
//Pushpin pp = new Pushpin();
// Creat MapOverLap
MapOverlay overlay1 = new MapOverlay();
overlay1.Content = new Pushpin();
overlay1.GeoCoordinate = new GeoCoordinate(21.0178, 105.8303);
MapOverlay overlay2 = new MapOverlay();
overlay2.Content = new Pushpin();
overlay2.GeoCoordinate = new GeoCoordinate(21.0076, 105.8414);
// Creat Maplayer
MapLayer layer = new MapLayer();
layer.Add(overlay1);
layer.Add(overlay2);
myPushpins.Layers.Add(layer);

或者甚至更好地具有一些功能来显示您的引脚

public void PinMap(Map map, GeoCoordinate geoPosition) {
map.Center = geoPosition;
map.ZoomLevel = 13;

var mapOverlay = new MapOverlay();
mapOverlay.Content = new Pushpin();
mapOverlay.GeoCoordinate = geoPosition;

var mapLayer = new MapLayer();
mapLayer.Add(mapOverlay);

map.Layers.Add(mapLayer);
}

PinMap(myMap, new GeoCoordinate(21.0178, 105.8303));
PinMap(myMap, new GeoCoordinate(21.0076, 105.8414));

关于windows-phone - 如何在 Windows Phone 8 中显示多个图钉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16402797/

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