0
我在嘗試更正此問題時遇到問題。我創建了2個自定義Bing地圖類型。用戶可以通過自定義放置框更改地圖類型。當用戶從Default更改爲Road時。大部分時間,如果用戶變回默認值,道路將保持不變。我錯過了那麼明顯的東西嗎?我已經包含了我的代碼。自定義必應地圖類型問題
地圖類型
var defaultMapColors =
{
"version": "1.0",
"settings":
{
"landColor": "#686868"
},
"elements":
{
"mapElement": { "labelVisible": false },
"area": { "visible": false },
"transportation": { "visible": false },
"countryRegion": { //country
"borderStrokeColor": "#444444",
"borderOutlineColor": "#00000000",
"borderWidthScale": 3,
"fillColor": "#888888",
"visible": true
},
"adminDistrict": { //states
"borderVisible": true,
"borderStrokeColor": "#444444",
"borderOutlineColor": "#00000000",
"borderWidthScale": 3,
"fillColor": "#888888",
},
"water": { "fillColor": "#4E5E6D" },
"point": { "visible": false }
}
};
var defaultMapColorsWithRoads =
{
"version": "1.0",
"settings":
{
"landColor": "#686868"
},
"elements":
{
"mapElement": { "labelVisible": false },
"area": { "visible": false },
"transportation": {
"visible": true,
"strokeColor": "#ffffff",
},
"countryRegion": { //country
"borderStrokeColor": "#444444",
"borderOutlineColor": "#00000000",
"borderWidthScale": 3,
"fillColor": "#888888",
"visible": true
},
"adminDistrict": { //states
"borderVisible": true,
"borderStrokeColor": "#444444",
"borderOutlineColor": "#00000000",
"borderWidthScale": 3,
"fillColor": "#888888",
},
"water": { "fillColor": "#4E5E6D" },
"point": { "visible": false }
}
};
下拉
<div class="form-group">
<select id="customNavSelector" class="form-control selectpicker show-tick">
<option value="Default" onclick="map.setView({ mapTypeId: Microsoft.Maps.MapTypeId.road, customMapStyle: defaultMapColors });">Default</option>
<option value="Road" onclick="map.setView({ mapTypeId: Microsoft.Maps.MapTypeId.road, customMapStyle: defaultMapColorsWithRoads });">Road</option>
<option value="Aerial" onclick="map.setView({ mapTypeId: Microsoft.Maps.MapTypeId.aerial, customMapStyle: '' });">Aerial</option>
</select>
</div>
地圖對象
map = new Microsoft.Maps.Map(mapDiv,
{
credentials: "@ViewBag.BingMapKey",
center: new Microsoft.Maps.Location(@ConfigurationManager.AppSettings["CenterLatitude"], @ConfigurationManager.AppSettings["CenterLongitude"]),
customMapStyle: defaultMapColors,
mapTypeId: Microsoft.Maps.MapTypeId.road, //grayscale, aerial, road, canvasLight, canvasDark
//liteMode: true,
showMapTypeSelector: false, //set to true to show default bing map selector
disableStreetside: false,
disableStreetsideAutoCoverage: true,
zoom: zoom,
backgroundColor: 'black',
//showBreadcrumb: true,
//showLocateMeButton: locator,
enableInertia: false,
enableClickableLogo: false,
navigationBarMode: Microsoft.Maps.NavigationBarMode.compact //compact, default, minified
});
我不認爲我能夠做到這一點。這是爲了將多個圖層添加到地圖的內部地圖應用程序。處置地圖會導致用戶失去他們當前的數據,如果他們根據您的建議從一種地圖類型切換到另一種 - 正確的? – bradoxbl
正確,但是您可以跟蹤哪些圖層已打開,只需將它們添加到新地圖實例即可。 – rbrundritt
我確實試過這個,看看它是否會起作用。它確實如此。但是,對於我們所需要的,這不是100%真實的。現在,我們將暫時放棄這種選擇,直到有可用的解決方案 – bradoxbl