您好我在Primefaces中阅读了有关gmap的文档,我根据文档说明了这些:
<script src="https://maps.googleapis.com/maps/api/js? key=YOUR_API_KEY&callback=initMap" async defer></script>
我用谷歌API密钥替换了YOUR_API_KEY并删除了它们之间的空格?和键
和
<p:gmap center="41.381542, 2.122893" zoom="15" type="hybrid" style="width:600px;height:400px" />
但是当我渲染页面时出现错误:
对实体“回调”的引用必须以“;”结尾分隔符。
所以我在google上搜索了&
并将&
替换为<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
,该行
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async="async" defer></script>
然后我有错误
与元素类型“script”关联的属性名称“async”必须后跟“=”字符。
在Google上阅读我将其更改为
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async="async" defer="defer" ></script>
然后我有错误
与元素类型“script”关联的属性名称“defer”必须后跟“=”字符。
在Google上阅读我再次更改了
open class PopupActivity(): AppCompatActivity() {
public var message:String = "This is a message string for the label"
val titleLabel: TextView by lazy {
val label = TextView(this)
label.gravity = Gravity.CENTER
label.setTextSize(Constants.FontSizePopupTitle)
return@lazy label
}
val popupView: ConstraintLayout by lazy {
val view = ConstraintLayout(this)
view.setBackgroundColor(Color.primary())
return@lazy view
}
val view: ConstraintLayout by lazy {
val v = ConstraintLayout(this)
return@lazy v
}
@SuppressLint("ResourceType")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
view.id = 1
popupView.id = 2
titleLabel.id = 5
var margin = 2 * Constants.SpacingStandard.toInt()
view.addView(popupView)
popupView.addView(titleLabel)
titleLabel.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_CONSTRAINT,
ConstraintLayout.LayoutParams.WRAP_CONTENT)
titleLabel.text = message
popupView.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_CONSTRAINT,
ConstraintLayout.LayoutParams.WRAP_CONTENT)
val popupConstraintSet = ConstraintSet()
popupConstraintSet.connect(popupView.id, START, view.id, START, margin)
popupConstraintSet.connect(popupView.id, END, view.id, END, margin)
popupConstraintSet.centerHorizontally(popupView.id, view.id)
popupConstraintSet.centerVertically(popupView.id, view.id)
view.setConstraintSet(popupConstraintSet)
setContentView(view)
}
}
然后我有这些错误:
ReferenceError:谷歌未定义
未捕获异常:InvalidValueError:initMap不是函数
我做错了什么?
答案 0 :(得分:0)
以下应该有效
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY></script>