简体   繁体   English

在一个Google Maps Marker中包含3张图像

[英]Including 3 images inside one Google Maps Marker

I'm trying to have this done using Google Maps API. 我正在尝试使用Google Maps API完成此操作。 I tried several javascript plugins such as components from google-maps-utility-library-v3 but nothing seems really done for this purpose. 我尝试了几个javascript插件,例如google-maps-utility-library-v3但似乎并没有为此目的做任何事情。

Basically what I'm trying to do is to have one shadow layer, one user's picture layer and over it one layer for the marker image. 基本上,我要尝试的是具有一个阴影层,一个用户的图片层,并在其上具有一层标记图像。 My marker image has a transparent hole in it, so I'd like the user's face to be shown in that hole which is why I'm trying to do this. 我的标记图像上有一个透明的孔,因此我希望在该孔中显示用户的脸,这就是为什么我要这样做。

What I have right now is pretty simple: 我现在所拥有的非常简单:

var shadow = {
    url: '/data/images/map/pin_shadow.png',
    size: new google.maps.Size(108, 95),
    anchor: new google.maps.Point(30, 47)
};

var image = {
    url: '/data/images/map/pin.png',
    size: new google.maps.Size(60, 95),
    anchor: new google.maps.Point(30, 47)
};

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(venue.lat, venue.lng),
    map: map,
    icon: image,
    shadow: shadow
});

I was wondering if anyone has ever did this? 我想知道是否有人这样做过?

EDIT: I'd better like a client-side solution though. 编辑:我最好还是一个客户端解决方案。 Thanks 谢谢

I wish I could add another image between the shadow and the image. 我希望可以在阴影和图像之间添加另一个图像。 Any idea? 任何想法?

Thanks and have a nice day! 感谢,并有一个愉快的一天!

You could try something like this : 您可以尝试这样的事情:

create pin images on the fly from PHP/.NET/JSP/... 从PHP / .NET / JSP /即时创建销钉图像

var image = {
    url: 'my_script.php?user=12345',
    size: new google.maps.Size(60, 95),
    anchor: new google.maps.Point(30, 47)
};

I don't know which language you use so here's a script pseudo-code : 我不知道您使用哪种语言,所以这是一个脚本伪代码:

Set headers to print script as image
if image exists for specified user : 
    return this image;
else
    create image for user with the 3 layers
    return image
end if

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM