zoukankan      html  css  js  c++  java
  • baiduMap

    /*----百度地图-----*/
    var Forbaidumap = function(opat){
        this.opat = opat;
        this.base();
        }
    Forbaidumap.prototype = {
        base:function(){
            this.star();
            },
        star:function(){
            var _this     = this;
            _this.map     = new BMap.Map(_this.opat.id);
            _this.myGeo = new BMap.Geocoder();
            _this.searchLocation(_this.opat.add,_this.opat.city,_this.opat.x,_this.opat.y);
            /*-插件star-*/
            _this.map.enableScrollWheelZoom();
            _this.map.enableInertialDragging();
            _this.map.addControl(new BMap.NavigationControl()); 
            /*-插件end-*/
            },
        searchLocation:function(where,city,x,y){
            var _this         = this,
                 _findinfo     = _this.opat.findinfo,
                 _myGeo         = _this.myGeo,
                 _map         = _this.map,
                 _title         = _this.opat.title,
                 _content     = _this.opat.content;
                 _myGeo.getPoint(where, function(p){
                    var point = p || new BMap.Point(x,y);
                    if(_findinfo) point = new BMap.Point(x,y);
                    var marker = new BMap.Marker(point);
                    _map.centerAndZoom(point, 17);
                    _map.addOverlay(marker);
                    marker.setAnimation(BMAP_ANIMATION_BOUNCE);    
                    var opts = {
                        width : 250,
                        height: 100,
                        title : _title
                        }
                    var infoWindow = new BMap.InfoWindow(_content, opts);
                    marker.addEventListener("click", function(){          
                        this.openInfoWindow(infoWindow);  
                        })
                }, city);
            }
        }
    new Forbaidumap({
            id:"container",
            add:"宁波市火星",
            city:"宁波",
            title:"Hello",
            content:"嘟嘟嘟1",
            findinfo:false,            //默认为false,如果是true 匹配下面的经纬度
            x:120.845502,
            y:30.340754
            });
  • 相关阅读:
    洛谷P1084 [NOIP2012提高组Day2T3]疫情控制
    洛谷P1083 [NOIP2012提高组Day2T2]借教室
    洛谷P2736 “破锣摇滚”乐队 Raucous Rockers
    POJ1692 Crossed Matchings
    洛谷P1315 [NOIP2011提高组Day2T3] 观光公交
    阅读了几个别人写的轮播源码
    js遍历函数
    解决IE6的PNG透明
    04-树5 Root of AVL Tree
    平衡树实现
  • 原文地址:https://www.cnblogs.com/somesayss/p/2592760.html
Copyright © 2011-2022 走看看