如何使用 Meteor 更改带有此图标的标记以在 Google 地图中使用字母?
How to change Markers with this icon to use Letters in Google Maps using Meteor?
我有带有此图标的标记,但我想使用像 a、b、c 这样的字母 etc.The 图标和标记代码,如下所示:
JS代码:
var icon = {
path: "M-20,0a20,20 0 1,0 40,0a20,20 0 1,0 -40,0",
fillColor: '#FF0000',
strokeWeight: 1,
fillOpacity: 1,
anchor: new google.maps.Point(0,0),
scale: .35
}
for(var i = 0 ; i <latLong.length ; i++) {
late = latLong[i].lat;
longe = latLong[i].long;
console.log("i:"+i+" " +late,longe);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(late, longe),
map: map,
title:'hi mi lat are ' + late + ' and mi long are ' + longe,
draggable: false,
animation: google.maps.Animation.DROP,
icon: icon
});
}
所以请建议我为此做什么?
先下载这个markers set
其次创建此变量以保存 for 或 forEach 中的图像,您必须创建 dynamyc 标记。
for (var i = 0; i < markersArray.length; i++) { //where marker array its an array of markers
var lettersMarker = new google.maps.MarkerImage('marker' + i + '.png');
var marker = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: image,
});
注意:这仅在您有动态标记时才有效。
如果您没有 for each 等,只需像这样创建标记。
var imageMarkerA = new google.maps.MarkerImage('public/markerA.png');
var markerA = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: imageMarkerA,
});
var imageMarkerB = new google.maps.MarkerImage('public/markerB.png');
var markerB = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: imageMarkerB,
});
等等...
我有带有此图标的标记,但我想使用像 a、b、c 这样的字母 etc.The 图标和标记代码,如下所示:
JS代码:
var icon = {
path: "M-20,0a20,20 0 1,0 40,0a20,20 0 1,0 -40,0",
fillColor: '#FF0000',
strokeWeight: 1,
fillOpacity: 1,
anchor: new google.maps.Point(0,0),
scale: .35
}
for(var i = 0 ; i <latLong.length ; i++) {
late = latLong[i].lat;
longe = latLong[i].long;
console.log("i:"+i+" " +late,longe);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(late, longe),
map: map,
title:'hi mi lat are ' + late + ' and mi long are ' + longe,
draggable: false,
animation: google.maps.Animation.DROP,
icon: icon
});
}
所以请建议我为此做什么?
先下载这个markers set
其次创建此变量以保存 for 或 forEach 中的图像,您必须创建 dynamyc 标记。
for (var i = 0; i < markersArray.length; i++) { //where marker array its an array of markers
var lettersMarker = new google.maps.MarkerImage('marker' + i + '.png');
var marker = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: image,
});
注意:这仅在您有动态标记时才有效。
如果您没有 for each 等,只需像这样创建标记。
var imageMarkerA = new google.maps.MarkerImage('public/markerA.png');
var markerA = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: imageMarkerA,
});
var imageMarkerB = new google.maps.MarkerImage('public/markerB.png');
var markerB = new google.maps.Marker({
position: lat[i],lng[i], //or whatever you have.
map: map,
icon: imageMarkerB,
});
等等...