[英]specify size of custom marker in google map
I am trying to put custom markers on a google map. 我想在谷歌地图上放置自定义标记。 The icons that I want to use are png files and vary based on the type of point being placed on the map.
我想要使用的图标是png文件,并根据放置在地图上的点的类型而有所不同。 Both the location of the point and the url of the png file for its marker are being pulled from an SQLdatabase.
从SQL数据库中提取点的位置和其标记的png文件的URL。
The code I am using is as follows 我使用的代码如下
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lon),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
// marker:true
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lon);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.venue,
icon: data.image
});
When this is run, I get very large markers on my map, each marker is the correct one, but they are so large that it looks like a jumble. 当这个运行时,我在地图上得到非常大的标记,每个标记都是正确的标记,但是它们非常大,看起来像混乱。
Any suggestions on how to control the size of the icon? 有关如何控制图标大小的任何建议?
You could specify a google.maps.Icon as the MarkerOptions, eg 您可以将google.maps.Icon指定为MarkerOptions,例如
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.venue,
icon: {
url: data.image,
scaledSize: new google.maps.Size(32, 32)
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.