Introduced Baidu Maps API file
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=your key" ></script> Create a map instance and set basic properties
function huaLine(id, sj, numSelect) {
Baidu Map API function
map = new BMap.Map(id, { mapType: BMAP_HYBRID_MAP }); Create Map instances, mix maps, both coordinates and satellite maps
map.centerAndZoom(new BMap.Point(104.06, 30.67), 5); Initialize the map, set the center point coordinates and map level
map.enableScrollWheelZoom(true); Turn on mouse wheel zoom
Introducing the Baidu map point aggregation plug-in
<script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script>
Create custom dimensions to implement point aggregation
Create an array
var markers = [];
Create a point with x and y coordinates in pixels
var pt = new BMap.Point(longitude, latitude);
Set the icon of the label and change the size of the imported image
var myIcon = new BMap.Icon(".. /.. /img/work/yuan.png", new BMap.Size(32, 32));
Create an annotation, set the latitude and longitude of the annotation, and the annotated image
var marker2 = new BMap.Marker(pt, { icon: myIcon });
Add the points that need to be aggregated to the array
markers.push(marker2);
Initialize point aggregation var markerClusterer = new BMapLib.MarkerClusterer(map, {markers:markers});
Note: The existing point aggregation plugins are relatively stuck, you can go to Baidu to search for some plugins modified by big guys to use
|