Google maps api 3 谷歌地图上的不同颜色标记
我正在尝试将一张图片与谷歌地图上的15个不同的团队标记关联起来,我已经尝试过了,但它在我的地图上无法正常工作,任何建议都将不胜感激。我的想法是associate:if(location.nombreequipo==AST1){icon:imagen},但我对这个想法有很多疑问Google maps api 3 谷歌地图上的不同颜色标记,google-maps-api-3,google-maps-markers,Google Maps Api 3,Google Maps Markers,我正在尝试将一张图片与谷歌地图上的15个不同的团队标记关联起来,我已经尝试过了,但它在我的地图上无法正常工作,任何建议都将不胜感激。我的想法是associate:if(location.nombreequipo==AST1){icon:imagen},但我对这个想法有很多疑问 function displayLocation(location){ var content = '<strong><p>Equipo: ' +location.nombreequipo
function displayLocation(location){
var content = '<strong><p>Equipo: ' +location.nombreequipo + '</strong>'
+'</strong></p><strong><p>Hora móvil: ' + location.fecha_movil
+ '</strong></p><strong><p>Longitud: ' +location.longitud +'</strong></p>'
+ '</strong></p><strong><p>Latitud: ' +location.latitud +'</strong></p>';
var latLng = new google.maps.LatLng(parseFloat(location.latitud), parseFloat(location.longitud));
var imagen ='img/blue_MarkerA.png';
var marker = new google.maps.Marker({
position: latLng,
draggable: false,
map: map,
draggable: true,
visible: true,
title: location.nombreequipo
});
arrayMarcadores.push(marker);
google.maps.event.addListener(marker, 'click', function(){
infowindow.setContent(content);
infowindow.open(map, marker);
});
return marker;
}
功能显示位置(位置){
var content='Equipo:'+location.nombreequipo+''
+“霍拉·莫维尔:”+location.fecha_movil
+“Longitud:”+location.Longitud+“”
+“纬度:”+location.Latitud+“”;
var latLng=new google.maps.latLng(parseFloat(location.latitud)、parseFloat(location.longitud));
var imagen='img/blue_MarkerA.png';
var marker=new google.maps.marker({
位置:latLng,
可拖动:错误,
地图:地图,
真的,
可见:对,
标题:location.nombreequipo
});
阵列天线。推(标记器);
google.maps.event.addListener(标记'click',函数(){
infowindow.setContent(content);
信息窗口。打开(地图、标记);
});
返回标记;
}
提前感谢。能否尝试将
.imagen
属性添加到您的位置
例如,分配location.imagen=img/blue.png
,然后
var marker = new google.maps.Marker({
position: latLng,
draggable: false,
...
icon: location.imagen
});
顺便说一下,您有两个可拖动的,第一个是false,然后是true 能否尝试将
.imagen
属性添加到位置
例如,分配location.imagen=img/blue.png
,然后
var marker = new google.maps.Marker({
position: latLng,
draggable: false,
...
icon: location.imagen
});
顺便说一下,您有两个可拖动的,第一个是false,然后是true 我最终采用的解决方案是:
if(location.nombreequipo=="TEAMNAME"){
var image='img/blueMarker.png';
}
if(location.nombreequipo=="TEAMNAME2"){
var image='img/redMarker.png';
}
function displayLocation(location){
var content = '<strong><p>Equipo: ' +location.nombreequipo + '</strong>'
+'</strong></p><strong><p>Hora móvil: ' + location.fecha_movil
+ '</strong></p><strong><p>Longitud: ' +location.longitud +'</strong></p>'
+ '</strong></p><strong><p>Latitud: ' +location.latitud +'</strong></p>';
var latLng = new google.maps.LatLng(parseFloat(location.latitud), parseFloat(location.longitud));
var marker = new google.maps.Marker({
position: latLng,
map: map,
draggable: true,
visible: true,
title: location.nombreequipo,
icon: image
});
arrayMarcadores.push(marker);
/*Content window asociated to created markers*/
google.maps.event.addListener(marker, 'click', function(){
infowindow.setContent(content);
infowindow.open(map, marker);
});
return marker;
}
if(location.nombreequipo==“TEAMNAME”){
var image='img/blueMarker.png';
}
如果(location.nombreequipo==“TEAMNAME2”){
var image='img/redMarker.png';
}
功能显示位置(位置){
var content='Equipo:'+location.nombreequipo+''
+“霍拉·莫维尔:”+location.fecha_movil
+“Longitud:”+location.Longitud+“”
+“纬度:”+location.Latitud+“”;
var latLng=new google.maps.latLng(parseFloat(location.latitud)、parseFloat(location.longitud));
var marker=new google.maps.marker({
位置:latLng,
地图:地图,
真的,
可见:对,
标题:location.nombreequipo,
图标:图像
});
阵列天线。推(标记器);
/*与已创建标记关联的内容窗口*/
google.maps.event.addListener(标记'click',函数(){
infowindow.setContent(content);
信息窗口。打开(地图、标记);
});
返回标记;
}
谢谢。我最终采用的解决方案是:
if(location.nombreequipo=="TEAMNAME"){
var image='img/blueMarker.png';
}
if(location.nombreequipo=="TEAMNAME2"){
var image='img/redMarker.png';
}
function displayLocation(location){
var content = '<strong><p>Equipo: ' +location.nombreequipo + '</strong>'
+'</strong></p><strong><p>Hora móvil: ' + location.fecha_movil
+ '</strong></p><strong><p>Longitud: ' +location.longitud +'</strong></p>'
+ '</strong></p><strong><p>Latitud: ' +location.latitud +'</strong></p>';
var latLng = new google.maps.LatLng(parseFloat(location.latitud), parseFloat(location.longitud));
var marker = new google.maps.Marker({
position: latLng,
map: map,
draggable: true,
visible: true,
title: location.nombreequipo,
icon: image
});
arrayMarcadores.push(marker);
/*Content window asociated to created markers*/
google.maps.event.addListener(marker, 'click', function(){
infowindow.setContent(content);
infowindow.open(map, marker);
});
return marker;
}
if(location.nombreequipo==“TEAMNAME”){
var image='img/blueMarker.png';
}
如果(location.nombreequipo==“TEAMNAME2”){
var image='img/redMarker.png';
}
功能显示位置(位置){
var content='Equipo:'+location.nombreequipo+''
+“霍拉·莫维尔:”+location.fecha_movil
+“Longitud:”+location.Longitud+“”
+“纬度:”+location.Latitud+“”;
var latLng=new google.maps.latLng(parseFloat(location.latitud)、parseFloat(location.longitud));
var marker=new google.maps.marker({
位置:latLng,
地图:地图,
真的,
可见:对,
标题:location.nombreequipo,
图标:图像
});
阵列天线。推(标记器);
/*与已创建标记关联的内容窗口*/
google.maps.event.addListener(标记'click',函数(){
infowindow.setContent(content);
信息窗口。打开(地图、标记);
});
返回标记;
}
谢谢。哦,对那个错误很抱歉,最后我用另一种方法解决了。但是你的想法也很好。哦,对不起,那个错误,最后我用另一种方式解决了。但是你的想法也很好。