我设法向用户询问Lat和lNG,但我似乎无法向用户询问标记的图标类型。
图标当前设置为
var icons = prompt("lH, lN, or lC", "lC");
icon: icons
选项是:lN,lH和lC,你可以看得更远,我尝试使用提示var并将其设置为图标但是没有工作
function newqMarker( width, height ) {
lN = new google.maps.MarkerImage( 'http://www.schweizer-brandschutz.ch/media/image/google-marker.png',
new google.maps.Size( 32, 37 ),
new google.maps.Point( 0, 0 ),
new google.maps.Point( 16, 35 ) );
lH = new google.maps.MarkerImage( 'http://www.andersiahotel.pl/img/marker-small.png',
new google.maps.Size( 32, 37 ),
new google.maps.Point( 0, 0 ),
new google.maps.Point( 16, 35 ) );
lC = new google.maps.MarkerImage( 'https://oge.com/images/blueMarker.png',
new google.maps.Size( 20, 32 ),
new google.maps.Point( 0, 0 ),
new google.maps.Point( 16, 35 ) );
var person = prompt("lH, lN, or lC", "lC");
markere = new google.maps.Marker( {
position: new google.maps.LatLng( prompt( "Latitude: " ), prompt( "Longtitude: " ) ),
map: map,
animation: google.maps.Animation.DROP,
icon: lH,
title: 'I am here'
} );
google.maps.event.addListener( markere, 'click', toggleBounce );
google.maps.event.addListener( markere, 'click', function() {
InfoWindowe.open( map, markere )
} );
google.maps.event.addListener(markere, 'mouseover', function(){this.setIcon(lH)});
google.maps.event.addListener(markere, 'mouseout', function(){this.setIcon(lN)});
google.maps.event.addListener(markere, 'mousedown', function(){this.setIcon(lC)});
google.maps.event.addListener(markere, 'mouseup', function(){this.setIcon(lH)});
}
任何人都可以帮忙吗?
=QUERY(Valuations!B1:B,"select B where LEN(B)>3 ")
答案 0 :(得分:1)
图标是一个复杂的对象,它不能由prompt
返回,但您可以添加switch
语句,以便从{{1}返回的字符串中设置该属性}}:
prompt
注意: {vl.10之后的var person = prompt("lH, lN, or lC", "lC");
var icon = lH;
switch (person) {
case "lH":
icon = lH;
break;
case "lN":
icon = lN;
break;
case "lC":
default:
icon = lC;
break;
}
var markere = new google.maps.Marker({
position: new google.maps.LatLng(prompt("Latitude: "), prompt("Longtitude: ")),
map: map,
animation: google.maps.Animation.DROP,
icon: icon,
title: 'I am here'
});
google.maps.event.addListener(markere, 'click', toggleBounce);
google.maps.event.addListener(markere, 'click', function() {
InfoWindowe.open(map, markere)
});
类已被弃用(很久以前~2012 / 2013):
将MarkerImage对象转换为类型图标
在Google Maps JavaScript API版本3.10之前,复杂图标被定义为MarkerImage对象。 Icon对象文字已在3.10版本中添加,并从3.11版本开始替换MarkerImage。
代码段
MarkerImage

var map;
function initialize() {
map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
newqMarker(0, 0);
}
google.maps.event.addDomListener(window, "load", initialize);
function newqMarker(width, height) {
lN = new google.maps.MarkerImage('http://www.schweizer-brandschutz.ch/media/image/google-marker.png',
new google.maps.Size(32, 37),
new google.maps.Point(0, 0),
new google.maps.Point(16, 35));
lH = new google.maps.MarkerImage('http://www.andersiahotel.pl/img/marker-small.png',
new google.maps.Size(32, 37),
new google.maps.Point(0, 0),
new google.maps.Point(16, 35));
lC = new google.maps.MarkerImage('https://oge.com/images/blueMarker.png',
new google.maps.Size(20, 32),
new google.maps.Point(0, 0),
new google.maps.Point(16, 35));
var person = prompt("lH, lN, or lC", "lC");
var icon = lH;
switch (person) {
case "lH":
icon = lH;
break;
case "lN":
icon = lN;
break;
case "lC":
default:
icon = lC;
break;
}
markere = new google.maps.Marker({
position: new google.maps.LatLng(prompt("Latitude: ", "37.4419"), prompt("Longtitude: ", "-122.1419")),
map: map,
animation: google.maps.Animation.DROP,
icon: icon,
title: 'I am here'
});
google.maps.event.addListener(markere, 'mouseover', function() {
this.setIcon(lH)
});
google.maps.event.addListener(markere, 'mouseout', function() {
this.setIcon(lN)
});
google.maps.event.addListener(markere, 'mousedown', function() {
this.setIcon(lC)
});
google.maps.event.addListener(markere, 'mouseup', function() {
this.setIcon(lH)
});
}

html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}