Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SVG-如何剪辑谷歌地图?_Javascript_Google Maps_Svg - Fatal编程技术网

Javascript SVG-如何剪辑谷歌地图?

Javascript SVG-如何剪辑谷歌地图?,javascript,google-maps,svg,Javascript,Google Maps,Svg,这是我的密码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <title>Map&

这是我的密码:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <title>Map</title>

        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
        <script>
            var map;
            function initialize() {
                var mapOptions = {
                    zoom: 8,
                    center: new google.maps.LatLng(-34.397, 150.644),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                map = new google.maps.Map(document.getElementById('map-canvas'),
                    mapOptions);

            }

            google.maps.event.addDomListener(window, 'load', initialize);

        </script>
    </head>
    <body style="background-color: #eee">
        <svg id="svg-container" width="700" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">

            <clipPath id="cut-off">
                <polygon points="100,50 300,75 400,25 500,150 690,180 690,240 480,380 510,410 560,410 460,490 410,420 450,380 350,360 280,430 240,430 290,340 220,250 110,260 10,230 110,110" />
            </clipPath>

            <polygon points="100,50 300,75 400,25 500,150 690,180 690,240 480,380 510,410 560,410 460,490 410,420 450,380 350,360 280,430 240,430 290,340 220,250 110,260 10,230 110,110" stroke="black" stroke-width="3" fill="white" />

            <foreignobject x="0" y="0" width="700" height="500" clip-path="url(#cut-off)" >
                <body xmlns="http://www.w3.org/1999/xhtml">
                    <div id="map-canvas" style="width: 500px; height: 500px;"></div>
                </body>
            </foreignObject>
        </svg>

    </body>
</html>

地图
var映射;
函数初始化(){
变量映射选项={
缩放:8,
中心:新google.maps.LatLng(-34.397150.644),
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById('map-canvas'),
地图选项);
}
google.maps.event.addDomListener(窗口“加载”,初始化);

它必须削减谷歌地图,但它只能在Firefox中使用。例如,在Opera中,映射位于SVG路径之上。如果你知道如何解决其他浏览器的问题,请告诉我。谢谢。

如果您将foreignObject设置为
元素的子元素,并将剪辑应用到父元素上,是否解决了此问题?否。地图仍在顶部。我有完全相同的问题-@alex:您找到跨浏览器解决方案了吗?否。地图仍在顶部。我在上面做了个面具。