---
title: "百度地图使用在Chrome下报错“Cannot read property 'pb' of undefined”的解决办法"
author: "wktong"
date: "2013-06-20T17:12:57Z"
tags: []
categories: ["Web前端"]
slug: "chrome-cannot-read-property-pb-of-undefined"
draft: false
lastmod: "2013-06-20T17:14:27Z"
id: 1890767
url: "https://wktong.iteye.com/blog/1890767"
---

项目需要用到百度地图API，要在JSP里面嵌入一个地图DIV。

很奇怪为什么会报这个错。（在火狐下会报：TypeError: this.D is undefined）

解决办法：把js代码放到地图DIV容器的下面即可。

```
...
...
<body>
	<div id="allmap" style="width:800px;height:600px"></div>
	<script type="text/javascript"> 
		var map = new BMap.Map("allmap");
		var point = new BMap.Point(116.404, 39.915);
		map.centerAndZoom(point,15);
		map.enableScrollWheelZoom();
	</script>
</body>
...
...
```