Google 地图 v3 customMarker 锚点出现问题
我开发了带有自定义标记图标的地图。 lat lng 坐标是从 json 文件中引入的。但我的问题是,我们不是定义每个标记,而是将它们全部分组在横幅标记的 if 语句中。我的问题是我想在另一个横幅中使用 if 语句来使一个横幅显示不同。
代码如下:
if (is_featured == true){
if (ad_id == 93){
var marker_icon = new google.maps.MarkerImage(
"_files/ads/70/" + mark[93] + "m.png",
new google.maps.Size(91, 64),
new google.maps.Point(0, 0),
new google.maps.Point(45.5, 64));
info = get_sponsor_info(mark);
var shadow = new google.maps.MarkerImage(
"_files/ads/70/" + mark[93] + "ms.png",
new google.maps.Size(126, 64),
new google.maps.Point(0,0),
new google.maps.Point(45.5, 64));
}
else {
var marker_icon = new google.maps.MarkerImage(
"_files/ads/70/" + mark['ad_id'] + "m.png",
new google.maps.Size(140, 63),
new google.maps.Point(0, 0),
new google.maps.Point(70, 63));
info = get_sponsor_info(mark);
var shadow = new google.maps.MarkerImage(
"_files/ads/70/" + mark['ad_id'] + "ms.png",
new google.maps.Size(176, 63),
new google.maps.Point(0,0),
new google.maps.Point(70, 63));
var banner_marker = new google.maps.Marker({
position: pt,
icon: marker_icon,
map: map,
zIndex: 100000000,
shadow: shadow
})};
if (ad_id ==93) 中的锚点值不会影响横幅的实际锚点。
地图在这里:
http://www.noblood.org/transfusion -alternatives-blood-management-resources-map
您可以看到俄亥俄州的横幅应该位于哥伦布市的红色 x 处,但事实并非如此。
I have developed a map with custom marker Icons. The lat lng coordinates are brought in from a json file. My problem though is that instead defining each and every marker we grouped them all together in an if statement for banner markers. My problem is that I want to use an if statement inside another one to make one banner appear differently.
Here is the code:
if (is_featured == true){
if (ad_id == 93){
var marker_icon = new google.maps.MarkerImage(
"_files/ads/70/" + mark[93] + "m.png",
new google.maps.Size(91, 64),
new google.maps.Point(0, 0),
new google.maps.Point(45.5, 64));
info = get_sponsor_info(mark);
var shadow = new google.maps.MarkerImage(
"_files/ads/70/" + mark[93] + "ms.png",
new google.maps.Size(126, 64),
new google.maps.Point(0,0),
new google.maps.Point(45.5, 64));
}
else {
var marker_icon = new google.maps.MarkerImage(
"_files/ads/70/" + mark['ad_id'] + "m.png",
new google.maps.Size(140, 63),
new google.maps.Point(0, 0),
new google.maps.Point(70, 63));
info = get_sponsor_info(mark);
var shadow = new google.maps.MarkerImage(
"_files/ads/70/" + mark['ad_id'] + "ms.png",
new google.maps.Size(176, 63),
new google.maps.Point(0,0),
new google.maps.Point(70, 63));
var banner_marker = new google.maps.Marker({
position: pt,
icon: marker_icon,
map: map,
zIndex: 100000000,
shadow: shadow
})};
The anchor value in the if (ad_id ==93) does not affect the actual anchor point of the banner.
The map is here:
http://www.noblood.org/transfusion-alternatives-blood-management-resources-map
And you can see that the banner in Ohio should be right at the red x in Columbus but it's not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论