如何在具有多边形的同一地图上显示自定义标记
How do I Display a Custom Marker on the same map that has Polygons?
这是我当前的代码。在这个例子中,我试图让自定义标记显示在地图上,地图上也突出显示了一个多边形。下面的脚本是javascript。
<script>
function initialize() {
var mapOptions = {
zoom: 10,
center: new google.maps.LatLng(48.545936,-122.765734),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var bermudaTriangle;
var marker1 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(48.3544181, -123.138301),
draggable: false,
title: 'Troll Fishing2',
icon: "/images/fish.png"
});
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
// Define the LatLng coordinates for the polygon's path. Note that there's
// no need to specify the final coordinates to complete the polygon, because
// The Google Maps JavaScript API will automatically draw the closing side.
var triangleCoords = [
new google.maps.LatLng(48.7286, -122.8688),
new google.maps.LatLng(48.677, -122.7733),
new google.maps.LatLng(48.6901, -122.7507)
];
bermudaTriangle = new google.maps.Polygon({
paths: triangleCoords,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 3,
fillColor: '#FF0000',
fillOpacity: 0.35
});
bermudaTriangle.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
如有任何建议,我们将不胜感激。
在初始化映射后将标记1的定义移动到(或在映射初始化后调用其上的.setMap(map))。
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var marker1 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(48.3544181, -123.138301),
draggable: false,
title: 'Troll Fishing2',
icon: "/images/fish.png"
});
相关文章:
- 张贴到地图显示的限制
- 谷歌地图显示灰色方框
- 无法让谷歌地图显示在我的网站上
- Google Maps Javascript API v3 地图显示在桌面浏览器上,但不会显示在移动浏览器上
- 双击谷歌地图显示提示框不起作用
- 谷歌地图显示钦奈(印度)使用javascript
- 使用 IMG 地图显示更大的图像
- 当缩放级别为 1 时,谷歌地图显示 kml(内部是图像 URL)不正确
- 无法让我的 openlayers 地图显示在网页上
- 谷歌地图显示没有jQuery
- 谷歌地图显示问题
- 谷歌/必应地图显示所有城市
- Esri 地图显示信息窗口,无需单击地图
- 必应地图显示地图的左上角的北美
- 谷歌地图显示KML数据
- 谷歌地图显示新请求后的旧方向
- 谷歌地图显示什么,直到我最小化屏幕
- 谷歌地图显示多个地图而不是一个
- 为什么谷歌地图显示灰色,而没有初始化缩放&当使用jQuery按钮更改缩放时,居中,地图上的居中效果非常好
- 谷歌地图显示标题的信息框