This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9746|Reply: 0

[Other] Baidu map point aggregation

[Copy link]
Posted on 7/7/2020 2:56:33 PM | | |
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








Previous:SQL Server returns the primary key after insertion
Next:【Primeng】Solution to the problem that the p-calendar date picker is obscured by modal boxes
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com