- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 JSON 对象中有大约 30 个纬度和经度,我每次填充 5 个一组并创建 HTML 标记并在浏览器中显示在左侧 DIV 元素上。在右侧的 DIV 元素上,我显示了具有所有可用纬度和经度(30 点)的 map 。
到目前为止,我正在设置一个特定的硬编码缩放级别来显示图钉。但我需要设置缩放级别,以便默认情况下只显示最少 5 个图钉(我从 HTML 标记中获取的那 5 个图钉 LAT Long)。在用户缩小时,他们应该能够看到所有可用的图钉。
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bing Maps - YUI</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/3.14.1/build/yui/yui-min.js"></script>
<link rel="stylesheet" type="text/css" href="StyleSheet.css"" />
<script type="text/javascript">
// Create a YUI sandbox on your page.
YUI().use('json-parse', 'json-stringify', "node", "selector-css3", "event-valuechange", "event", 'node-event-delegate', 'event-key', function (Y) {
Y.on('available', function () {
//alert("gh");
Y.one('#firststore').addClass('disableprev');
//e.preventDefault();
//Y.one('#firststore').addClass('successmsgdisplay12');
var data = JSON.stringify({ "stores": [
{ "storeId": "1", "Name": "Branch 1", "lat": "12.915397", "long": "77.624154", "address": "HSR Layout, Bengaluru 560102, India." },
{ "storeId": "2", "Name": "Branch 2", "lat": "12.936060", "long": "77.625506", "address": "Koramangala Ring Road, 4th Cross Road, Koramangala, Bengaluru 560034, India." },
{ "storeId": "3", "Name": "Branch 3", "lat": "12.936060", "long": "80.502330", "address": "Pilimathalawa Road, Menikdiwela, Sri Lanka." },
{ "storeId": "4", "Name": "Branch 4", "lat": "12.956805", "long": "77.700457", "address": "Varthur Main Road, Marattahalli, Bengaluru 560037, India." },
{ "storeId": "5", "Name": "Branch 5", "lat": "12.918325", "long": "77.573256", "address": "1 Kanakapura Main Road, Banashankari, Bengaluru 560050, India." },
{ "storeId": "6", "Name": "Branch 6", "lat": "12.920333", "long": "77.620291", "address": "321-2 Madwala Stage 1, BTM Layout, Bengaluru 560068, India." },
{ "storeId": "7", "Name": "Branch 7", "lat": "12.965170", "long": "77.619261", "address": "Old Airport Road, Neelasandra, Bengaluru 560071, India." },
{ "storeId": "8", "Name": "Branch 8", "lat": "13.095747", "long": "77.348184", "address": "Nelamangala Sub-District, Ka, India." },
{ "storeId": "9", "Name": "Branch 9", "lat": "12.918999", "long": "77.616942", "address": "273, BTM Layout, Bengaluru" },
{ "storeId": "10", "Name": "Branch 10", "lat": "12.932900", "long": "77.621835", "address": "Koramangala, Bengaluru" },
{ "storeId": "11", "Name": "Branch 11", "lat": "12.913922", "long": "77.622414", "address": "Bommanahalli, Bengaluru" },
{ "storeId": "12", "Name": "Branch 12", "lat": "12.915009", "long": "77.629581", "address": "L-55, HSR Layout, Bengaluru 560102, India." },
{ "storeId": "13", "Name": "Branch 13", "lat": "12.917373", "long": "77.622779", "address": "Silk Board Flyover, Koramangala, Bengaluru" },
{ "storeId": "14", "Name": "Branch 14", "lat": "12.916933", "long": "77.628487", "address": "100 Feet Ring Road, Koramangala, Bengaluru" },
{ "storeId": "15", "Name": "Branch 15", "lat": "12.918941", "long": "77.621642", "address": "Silk Board Flyover, Koramangala, Bengaluru 560034, India" },
{ "storeId": "16", "Name": "Branch 16", "lat": "12.916285", "long": "77.618015", "address": "100 Feet Ring Road, BTM Layout, Bengaluru 560029, India" },
{ "storeId": "17", "Name": "Branch 17", "lat": "12.919096", "long": "77.627409", "address": "Silk Board Flyover & Hosur Main Road, HSR Layout, Bengaluru 560102, India" },
{ "storeId": "18", "Name": "Branch 18", "lat": "12.915114", "long": "77.631169", "address": "L-115 3rd B Cross Road, HSR Layout, Bengaluru 560102, India" },
{ "storeId": "19", "Name": "Branch 19", "lat": "12.914549", "long": "77.615333", "address": "7/8 30th Main Road, BTM Layout, Bengaluru 560076, India" },
{ "storeId": "20", "Name": "Branch 20", "lat": "12.911391", "long": "77.633594", "address": "1089 19th Cross Road, HSR Layout, Bengaluru 560102, India" },
{ "storeId": "21", "Name": "Branch 21", "lat": "12.922601", "long": "77.622757", "address": "Madivala Market Road, Koramangala, Bengaluru 560034, India" },
{ "storeId": "22", "Name": "Branch 22", "lat": "12.924149", "long": "77.628808", "address": "Madivala Market Road & Sarjapur Road / Koramangala Road, Koramangala, Bengaluru 560034, India" }
]
});
Y.one("input[name='storeLatLong']").set("value", data);
try {
var val = Y.one("#storeLatLong").get("value");
var data = Y.JSON.parse(val);
}
catch (e) {
alert("Invalid product data");
}
var pins = data.stores;
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
{ credentials: "AkFmXSfNJbfsd3VIkd2R8AiIAYqO6fkrHpLC-4lTUvo3Lr920bQy9bLNCzbzXliz", mapTypeId: Microsoft.Maps.MapTypeId.road, showMapTypeSelector: false, customizeOverlays: true, showBreadcrumb: true, enableSearchLogo: false });
var infoboxLayer = new Microsoft.Maps.EntityCollection();
var pinLayer = new Microsoft.Maps.EntityCollection();
pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { width: 200, height: 100, visible: false });
infoboxLayer.push(pinInfobox);
Y.Array.each(pins, function (pin, index) {
var pinLocation = new Microsoft.Maps.Location(pin.lat, pin.long);
var NewPin = new Microsoft.Maps.Pushpin(pinLocation, { icon: 'images/Pushpin.png', width: 32, height: 32, text: pin.storeId, typeName: "pin" + index }); /*typeName: pin.Name*/
NewPin.Title = pin.address;
NewPin.ID = pin.Name;
NewPin.StoreID = pin.storeId;
Microsoft.Maps.Events.addHandler(NewPin, 'click', displayInfobox);
Microsoft.Maps.Events.addHandler(map, 'click', hideInfobox);
map.entities.push(NewPin);
/*Title*/
Y.one('.pin' + index).setAttribute('title', pin.Name);
/*Title*/
});
map.entities.push(infoboxLayer);
map.setView({ center: new Microsoft.Maps.Location(data.stores[0].lat, data.stores[0].long), zoom: 15 });
var selectedPin;
function displayInfobox(e) {
if (e.targetType == 'pushpin') {
selectedPin = e.target;
map.setView({ center: e.target.getLocation(), zoom: 15 });
pinInfobox.setLocation(e.target.getLocation());
pinInfobox.setOptions({ visible: true, title: e.target.ID, description: e.target.Title });
var selectedPinNum = selectedPin._text;
selectListFromMap(selectedPinNum);
resetPinImage();
selectedPin.setOptions({ icon: 'images/Pushpin_Selected.png' });
return false;
}
}
function resetPinImage() {
for (var i = 0; i < map.entities.getLength(); i++) {
var elt = map.entities.get(i);
if (elt.StoreID != null) {
elt.setOptions({ icon: 'images/Pushpin.png' });
}
}
}
function selectListFromMap(sel) {
var isPinExist = false;
Y.one(".test").get('children').setAttribute("class", "nameslist");
Y.all(".nameslist").each(function (node) {
if (node.getAttribute("id") == "pin_" + (sel - 1)) {
node.setAttribute("class", "actives");
isPinExist = true;
return;
}
});
if (!isPinExist) {
var pinNum = sel - 1;
var range = pinNum % 5;
if (range > 0) {
counter = pinNum - range;
} else {
counter = pinNum;
}
var endPoint = counter + 4;
if (endPoint > data.stores.length) endPoint = data.stores.length - 1;
createMarkup(counter, endPoint);
selectListFromMap(sel);
}
}
function hideInfobox(e) {
pinInfobox.setOptions({ visible: false });
}
createMarkup(0, 4);
function createMarkup(start, end) {
if (end > data.stores.length) {
end = data.stores.length;
}
var markup = "";
markup = "<ul class='test'>";
for (var i = start; i <= end; i++) {
var p = data.stores;
var classNme;
if (i == start) {
classNme = "actives";
setSelectedPinImage(i);
}
else {
classNme = "nameslist";
}
markup += "<li class=" + classNme + " id=pin_" + i + ">" + p[i].storeId + " " + p[i].Name + "</li>";
}
markup += "</ul>";
Y.one("#storeList").setHTML(markup);
Y.all(".nameslist").on("click", setSelectedCss);
Y.all(".actives").on("click", setSelectedCss);
Y.all(".nameslist").on("mouseover", setMouseoverCss);
Y.all(".nameslist").on("mouseout", setMouseoutCss);
Y.all(".actives").on("mouseover", setMouseoverCss);
Y.all(".actives").on("mouseout", setMouseoutCss);
//setMapZoom();
}
function setMouseoverCss(e) {
if (e._currentTarget.getAttribute("class") == "nameslist") {
e._currentTarget.setAttribute("class", "nameslisthover");
}
}
function setMouseoutCss(e) {
if (e._currentTarget.getAttribute("class") == "nameslisthover") {
e._currentTarget.setAttribute("class", "nameslist");
}
}
function setSelectedCss(e) {
Y.one(".test").get('children').setAttribute("class", "nameslist");
e._currentTarget.setAttribute("class", "actives");
var selectedPin = e._currentTarget.getAttribute("id").substring(4);
setSelectedPinImage(selectedPin);
hideInfobox();
map.setView({ center: new Microsoft.Maps.Location(data.stores[selectedPin].lat, data.stores[selectedPin].long), zoom: 15 });
}
function setSelectedPinImage(selectedPin) {
for (var i = 0; i < map.entities.getLength(); i++) {
var elt = map.entities.get(i);
if (elt.StoreID != null) {
if (Number(elt.StoreID) == Number(selectedPin) + 1) {
elt.setOptions({ icon: 'images/Pushpin_Selected.png' });
}
else {
elt.setOptions({ icon: 'images/Pushpin.png' });
}
}
}
}
var counter = 0;
Y.one("#prev").on("click", function (e) {
counter -= 5;
if (counter < 0) {
counter = 0;
Y.one('#firststore').addClass('disableprev');
Y.one('#firststore').removeClass('prevenabled');
e.preventDefault();
}
else {
Y.one('#firststore').removeClass('disableprev');
Y.one('#firststore').addClass('prevenabled');
}
createMarkup(counter, counter + 4);
var nextLoc = new Microsoft.Maps.Location(data.stores[counter].lat, data.stores[counter].long);
map.setView({ center: nextLoc, zoom: 15 });
hideInfobox();
e.preventDefault();
});
Y.one("#next").on("click", function (e) {
counter += 5;
var nextCounter = counter + 5;
var total = data.stores.length;
if (nextCounter > total) {
if (counter > total) counter -= 5;
nextCounter = total;
Y.one('#nextstore').removeClass('nextenabled');
Y.one('#nextstore').addClass('nextdisable');
e.preventDefault();
}
else {
Y.one('#nextstore').removeClass('nextdisable');
Y.one('#nextstore').addClass('nextenabled');
Y.one('#firststore').removeClass('disableprev');
Y.one('#firststore').addClass('prevenabled');
}
createMarkup(counter, nextCounter - 1);
var prevLoc = new Microsoft.Maps.Location(data.stores[counter].lat, data.stores[counter].long);
map.setView({ center: prevLoc, zoom: 15 });
hideInfobox();
e.preventDefault();
});
}, "#hiddenval");
});
</script>
</head>
<body>
<div>
<div id="storelists">
<div id="prev">
<input type="button" name="button" id="firststore" class="prevdisabled" />
</div>
<div id="storeList">
</div>
<div id="next">
<input type="button" name="button" id="nextstore" class="nextenabled" />
</div>
</div>
<div id="maplists">
<div id="mapDiv">
</div>
</div>
</div>
<div id="hiddenval">
<input type="hidden" name="storeLatLong" id="storeLatLong" value="" />
</div>
</body>
</html>
我的 CSS 是
body
{
background-color:#fff;
font-family:Arial;
font-size:12px;
}
#storelists
{
width:248px;
display:inline-block;
border:1px solid #999999;
height:306px;
}
#maplists
{
width:700px;
height:306px;
position:absolute;
display:inline-block;
border:1px solid #999999;
}
.test
{
list-style-type:none;
margin:0;
padding:0;
}
.nameslist
{
border-bottom:1px solid #f1f1f1;
background-color:#ffffff;
color:#3d6aae;
height:50px;
vertical-align:middle;
/*text-align: center;*/
}
.nameslisthover
{
background-color:#f0f0f0;
height:50px;
color:#3d6aae;
vertical-align:middle;
}
.actives
{
background-color:#de2a1e;
color:#ffffff;
height:50px;
vertical-align:middle;
}
.prevenabled
{
background: url("images/TopNavEnabled.PNG") no-repeat;
cursor:pointer;
border: none;
height:25px;
width:248px;
}
.prevdisabled
{
height:25px;
width:248px;
background:url("images/TopNavDisabled.PNG");
cursor:pointer;
border: none;
}
.nextenabled
{
height:25px;
width:248px;
background:url("images/BottomNavEnabled.PNG");
cursor:pointer;
border: none;
}
.nextdisable
{
height:25px;
width:248px;
background:url("images/BottomNavDisabled.PNG");
cursor:pointer;
border: none;
}
.successmsgdisplay
{
color: blue;
}
.successmsgdisplay12
{
color: Red;
}
.disableprev
{
color: #999999;
}
.enbableprev
{
color: green;
}
任何人都请帮助我。
最佳答案
创建一个数组,其中包含每个图钉的所有坐标。将此数组传递到 LocationRect 对象。这将为图钉生成一个边界框。将其作为 map View 的边界框传递。例如:
var locs = [];
for(var i=0;i<data.length;i++){
locs.push(new Microsoft.Maps.Location(data.stores[i].lat, data.stores[i].long));
}
var bounds = Microsoft.Maps.LocationRect.fromLocations(locs);
map.setView({bounds:bounds, padding: 100});
关于javascript - 如何根据要显示的图钉数量设置必应 map 中的缩放级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21428125/
Android 项目中最低(最低 sdk)和最高(目标 sdk)级别是否有任何影响。这些东西是否会影响项目的可靠性和效率。 最佳答案 没有影响,如果您以 SDK 级别 8 为目标,那么您的应用将以 9
我将现有的 android 项目升级到 API 级别 31。我使用 Java 作为语言。我改变了 build.gradle compileSdkVersion 31 defaultConfig {
我正在使用 ionic 3 创建一个 android 应用程序,当我尝试上传到 playstore 时,我收到一个错误,提示我的应用程序以 api 25 为目标,当我检查我的 project.prop
我刚刚尝试将应用程序的目标和编译 API 级别更新为 29 (Android 10),并注意到我无法再编译,因为 LocationManager.addNmeaListener 只接受 OnNmeaM
我的代码没有在 Kitkat 上显示工具栏。 这是我的两个 Android 版本的屏幕截图。 Kitkat 版本: Lollipop 版: 这背后的原因可能是什么。 list 文件
我正在构建面向 API 级别 8 的 AccessabilityService,但我想使用 API 级别 18 中引入的功能 (getViewIdResourceName())。这应该可以通过使用 A
当我想在我的电脑上创建一个 android 虚拟机时,有两个选项可以选择目标设备。它们都用于相同的 API 级别。那么我应该选择哪一个呢?它们之间有什么区别? 最佳答案 一个是基本的 Android,
当我选择 tagret 作为 Android 4.2.2(API 级别 17)时,模拟器需要很长时间来加载和启动。 所以我研究它并通过使用 找到了解决方案Intel Atom(x86) 而不是 ARM
我有一个使用 Android Studio 创建的 Android 项目。我在项目中添加了一些第三方依赖项,但是当我尝试在 Android Studio 中编译时,我遇到了以下错误: Error:Ex
如上所述,如何使用 API 8 获取移动设备网络接口(interface)地址? 最佳答案 NetworkInterface.getInetAddresses() 在 API8 中可用。 关于andr
我想显示 Snackbar并使用图像而不是文本进行操作。 我使用以下代码: val imageSpan = ImageSpan(this, R.drawable.star) val b
我有一个用 python 编写的简单命令行程序。程序使用按以下方式配置的日志记录模块将日志记录到屏幕: logging.basicConfig(level=logging.INFO, format='
使用下面的代码,实现游戏状态以控制关卡的最简单和最简单的方法是什么?如果我想从标题画面开始,然后加载一个关卡,并在完成后进入下一个关卡?如果有人能解释处理这个问题的最简单方法,那就太好了! impor
我想创建一个可以找到嵌套树结构深度的属性。下面的静态通过递归找出深度/级别。但是是否可以将此函数作为同一个类中的属性而不是静态方法? public static int GetDepth(MenuGr
var myArray = [{ title: "Title 1", children: [{ title: "Title 1.1", children: [{
通过下面的代码,实现游戏状态来控制关卡的最简单、最容易的方法是什么?如果我想从标题屏幕开始,然后加载一个关卡,并在完成后进入下一个关卡?如果有人可以解释处理这个问题的最简单方法,那就太好了! impo
我有一个树结构,其中每个节点基本上可以有无限个子节点,它正在为博客的评论建模。 根据特定评论的 ID,我试图找出该评论在树中的深度/级别。 我正在关注 this guide that explains
考虑任何给定的唯一整数的数组,例如[1,3,2,4,6,5] 如何确定“排序度”的级别,范围从 0.0 到 1.0 ? 最佳答案 一种方法是评估必须移动以使其排序的项目数量,然后将其除以项目总数。 作
我如何定义一个模板类,它提供一个整数常量,表示作为输入模板参数提供的(指针)类型的“深度”?例如,如果类名为 Depth,则以下内容为真: Depth::value == 3 Depth::value
我的场景是:文件接收器应该包含所有内容。另一个接收器应包含信息消息,但需要注意的是 Microsoft.* 消息很烦人,因此这些消息应仅限于警告。两个sink怎么单独配置?我尝试的第一件事是: str
我是一名优秀的程序员,十分优秀!