Ron*_*Ron 15 android google-maps-api-3 google-maps-markers
我有一个图像(一个圆圈),它应该表示一个特定的都市区域.我也GeoPosition掌握了所有相关领域.
如果我放置标记,我的图像的底部中心位于标记处GeoPosition.但是因为它是一个鸟瞰图,我想给图像一个偏移,所以我的圆形图像的中心就是GeoPosition......
任何想法如何实现这一目标?
谢谢!
Ron*_*Ron 21
感谢LeJared,我找到了解决方案.我的问题是,我认为这MarkerImage取代了Marker.但是你必须首先定义图像并稍后将其插入Marker.
例:
首先定义图像:
var image = new google.maps.MarkerImage("some/path/image.png",
// This marker is 20 pixels wide by 32 pixels tall.
null,
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(75, 35)
);
Run Code Online (Sandbox Code Playgroud)
然后将其插入常规标记:
var myMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
title: "My Title",
});
Run Code Online (Sandbox Code Playgroud)
Ily*_*gan 10
从Google API 3.11版开始,MarkerImage被替换为Icon.因此,这是将标记缩放到50px并将其定位以使其中心位于地理位置的新方法:
var image = {
url: '/some/path/image.png',
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(25, 25),
scaledSize: new google.maps.Size(50, 50)
};
var myMarker = new google.maps.Marker({
position: position,
icon: image,
title: 'title',
map: map
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18369 次 |
| 最近记录: |