2017-05-05 107 views
-2

我需要将图像放入自定义大小的多边形中,就像在图片中一样。我怎样才能得到这个?我认为这是一个坏主意。 彩色区域应该填充任何图像而不是颜色。如何将图像放入多边形谷歌地图

https://i.stack.imgur.com/qzJpu.png

+0

您可以使用图像叠加https://开头developers.google.com/maps/documentation/javascript/examples/maptype-image-overlay – scaisEdge

+0

谢谢,我alr eady使用它,但对于矩形区域。对于任意多边形,这是行不通的。 –

+0

你添加一个图像..如果图像不是矩形但透明区域应该工作.. – scaisEdge

回答

0

也许在你的情况自定义背景画面将是有益的: 检查这个exmaple

代码片段:

var bounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(62.281819, -150.287132), 
      new google.maps.LatLng(62.400471, -150.005608)); 

     // The photograph is courtesy of the U.S. Geological Survey. 
var srcImage = 'https://developers.google.com/maps/documentation/' + 
      'javascript/examples/full/images/talkeetna.png'; 

     // The custom USGSOverlay object contains the USGS image, 
     // the bounds of the image, and a reference to the map. 
overlay = new USGSOverlay(bounds, srcImage, map); 
+0

谢谢@Artem,但这不适用于任意多边形。你的例子只需要两个边界并只填充矩形区域。 –

+0

@pablo_ch你不能使用png与透明背景吗?.. –

+0

我正在使用已经绘制的项目里面的画布。 我想要什么==> http://image.prntscr.com/image/c5f7c82c0b7b45479ea315d922f363f9.png –