更改标记的颜色-Google Map V2 Android [英] Changing colour of Markers - Google Map V2 Android
问题描述
我在理解如何更改Android Google Map项目中标记的颜色方面遇到了一些麻烦.
I'm having a little trouble understanding how to change the colour of a marker in an Android Google Map project.
我的标记代码是:
googlemap.addMarker(new MarkerOptions()
.position(new LatLng( 65.07213,-2.109375))
.title("This is my title"))
.setSnippet("and snippet");
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
当我在最后一行输入.icon代码时出现此错误,否则.position
,.title
和.setSnippet
可以正常工作并且在地图上可见.
I get this error when I put in the .icon code on the last line, otherwise the .position
, .title
and .setSnippet
work just fine and are visible on the map.
无法在原始类型void上调用icon(BitmapDescriptor)
Cannot invoke icon(BitmapDescriptor) on the primitive type void
这些也可以导入:
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
但是没有添加任何其他内容.我错过了至关重要的部分吗?
But nothing else is added in. Have I missed a vital part?
推荐答案
您在此输入的几个字符有误.将您的代码与此进行比较:
You have a couple of characters wrong there. Compare your code to this:
googlemap.addMarker(new MarkerOptions()
.position(new LatLng( 65.07213,-2.109375))
.title("This is my title")
.snippet("and snippet")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
在第三行中删除了)
,将setSnippet
更改为snippet
,并在第四行中删除了;
.
Removed )
on third line, changed setSnippet
to snippet
and removed ;
on forth line.
这篇关于更改标记的颜色-Google Map V2 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!