admin管理员组文章数量:1279113
I need to make a custom shape div holding a "google maps" map. The custom border it's fine, I can handle it using a .png, but the shape itself, I have only some theories of how to do it, but nothing in practice. But I think there is a way to do it using HTML canvas to make the custom shape on the div and use in CSS overflow:hidden
to hide what goes out of the div.
right now I have the following structure:
<html>
<body>
<div class="Orange_Background"></div>
<div class="FX_Lines_over_background"></div>
<div class="GoogleMaps_Container"></div>
</body>
</html>
So as you can se I can't use the background as a .png to only show the map, and because I need the map to be clickable.
Here is a image of what I was saying.
PS: It can be with jQuery too.
I need to make a custom shape div holding a "google maps" map. The custom border it's fine, I can handle it using a .png, but the shape itself, I have only some theories of how to do it, but nothing in practice. But I think there is a way to do it using HTML canvas to make the custom shape on the div and use in CSS overflow:hidden
to hide what goes out of the div.
right now I have the following structure:
<html>
<body>
<div class="Orange_Background"></div>
<div class="FX_Lines_over_background"></div>
<div class="GoogleMaps_Container"></div>
</body>
</html>
So as you can se I can't use the background as a .png to only show the map, and because I need the map to be clickable.
Here is a image of what I was saying.
PS: It can be with jQuery too.
Share Improve this question edited May 14, 2024 at 14:53 TylerH 21.1k77 gold badges79 silver badges112 bronze badges asked Jul 4, 2012 at 20:14 Ricardo FioraniRicardo Fiorani 7821 gold badge7 silver badges19 bronze badges 3- I'm not sure it can be done without some very ugly hacks. But I'd love to see what people e up with. – Madara's Ghost Commented Jul 4, 2012 at 20:36
- 2 There's a way with KMLs but then you have to line everything up with the actual background. And it only loads after the map so for a moment the map will look rectangular. Maybe if all else fails use this approach. See Google's Screen Overlay Example – Heitor Chang Commented Jul 4, 2012 at 20:40
- Check this SO Answer if you want to use a static Google Map or other content in a customized div container. Cheers! – arttronics Commented Jul 5, 2012 at 1:30
2 Answers
Reset to default 5RE: Zee Tee's answer: If you do go this route, you can set pointer-events: none (in your css) for the div containing the images. this will send all mouse events to the layer below it. Sorry, I don't have the privilege to ment on answers yet :D
If you don't care about IE(6-8) support, then you can use CSS 3D transforms to do this directly on the map layer. But the map will look skewed, if that's the effect you are after, if not previous answer is still the best approach
Another solution is to use the mask image. sorry browser support sucks for this, but if you have a nice fallback until they catch up, you should be alright
https://developer.mozilla/en/CSS/-webkit-mask-image
You would need to create a frame with 4 different layers, top/right/left/bottom, and apply a higher z-index, background-image using a transparent PNG image than the map itself. Position would need to be absolute or fixed on those layers.
As you can see below, the 4 images are the black highlighted areas, and they would need to be individually sliced, then you can position them over the map layer. This keeps the middle area open without any overlapping layers so the map is still functional:
You can keep the entire orange background behind the maps layer, it won't matter because you'll be overlapping it first with the map, then with the 4 frame layers which if sliced properly and positioned properly would just overlap the background image. The entire background image would obviously be the full image, without any maps on it, but all orange with your stripes and gradient. Quite a task if you asked me, time consuming, but is possible.
NOTE: The transparent areas are only the white spaces you see in the black highlights, the rest would obviously be your image.
本文标签: javascriptCustom Shape Div with google maps insideStack Overflow
版权声明:本文标题:javascript - Custom Shape Div with google maps inside - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741249823a2365587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论