如何在 google 地图 api V3 中将图像锚点居中?
我试图将 google 地图 api 此处 中的图标锚点居中,但是当我尝试时直到爆炸图像消失。
此代码工作正常,但锚点位于图像的底部中心:
var image_explode = 'images/map/explode.png';
var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
var explode = new google.maps.Marker({
position: explode_longlat,
map: map,
icon: image_explode
});
我尝试使用此代码使锚点居中,但它消失了:
var image_explode = new google.maps.MarkerImage("projectstratos.com/images/map/explode.png",new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(10,10));
var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
var explode = new google.maps.Marker({
position: explode_longlat,
map: map,
icon: image_explode
});
I'm trying to center the anchor of an icon in the google maps api here but when I try to the explosion image disapears.
This code works fine but the anchor is at the bottom center of the image:
var image_explode = 'images/map/explode.png';
var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
var explode = new google.maps.Marker({
position: explode_longlat,
map: map,
icon: image_explode
});
I tried making the anchor centered using this code but it dissapears:
var image_explode = new google.maps.MarkerImage("projectstratos.com/images/map/explode.png",new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(10,10));
var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
var explode = new google.maps.Marker({
position: explode_longlat,
map: map,
icon: image_explode
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要包含主机名,则需要在 URL 中使用方案 (http://):
或者,将主机名 (projectstratos.com) 保留为关闭。
You need the scheme (http://) in your URL if you are going to include the hostname:
Alternatively, leave the hostname (projectstratos.com) off.