百度地图 JSAPI使用 mark 定位地址 与周边覆盖物




  1. var map = new BMap.Map("container");
  2. var preMarker = new BMap.Marker();
  3. map.addControl(new BMap.NavigationControl());//启用缩放轴
  4. map.addControl(new BMap.ScaleControl());//启用距离监测
  5. var myGeo = new BMap.Geocoder(); //创建地址解析实例
  6. myGeo.getPoint("${house.mapLocateaddress}", function (point) {
  7. if (point) {
  8. mPoint = new BMap.Point(point.lng, point.lat);
  9. map.centerAndZoom(mPoint, 16);
  10. displayPOI();
  11. } else {
  12. myGeo.getPoint("${house.mapLocateaddress2}", function (point) {
  13. if (point) {
  14. mPoint = new BMap.Point(point.lng, point.lat);
  15. map.centerAndZoom(mPoint, 16);
  16. displayPOI();
  17. }
  18. }, "广东省");
  19. }
  20. }, "广东省"); //必须设置城市
  21. /* map.enableScrollWheelZoom(); //启用滚轮缩放*/
  22. var mOption = {
  23. poiRadius: 10000, //半径为1000米内的POI,默认100米
  24. numPois: 30 //列举出50个POI,默认10个
  25. }
  26. //POI导航选中样式
  27. $("#map-indicator a").click(function () {
  28. $("#map-indicator a").removeClass("on");
  29. $(this).addClass("on");
  30. $("#env-list h3").text($("#map-indicator .on").html());
  31. displayPOI();
  32. })
  33. var allPois;
  34. var markers=[];
  35. function displayPOI() {
  36. map.clearOverlays();
  37. var poiType = $("#map-indicator .on").html();
  38. var circle = new BMap.Circle(mPoint,500,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.1, strokeOpacity: 0.1});
  39. map.addOverlay(circle);
  40. var local = new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false,panel: "map-result-list"}});
  41. local.searchNearby(poiType,mPoint,500);
  42. }



posted on 2017-03-22 08:58  signheart  阅读(1424)  评论(0编辑  收藏  举报

导航