2012-12-19 33 views
6

Tôi đang làm việc trên chức năng chụp nhanh bản đồ google bằng các đường polylines và mở cửa sổ bật lên trên nhấp chuột đa tuyến trên bản đồ google. Ảnh chụp nhanh bản đồ google với polylines đang hoạt động nhưng không thể chụp nhanh cửa sổ bật lên trên polyline. polyline hiển thị trên ảnh sanpshot nhưng cửa sổ thông tin không hiển thị. Đây là mã để chụp nhanh.cách chụp nhanh bản đồ google bằng polyline và openInfoWindowHtml

Mã này là để khởi tạo kiểm soát mã trên onload javascript:

 var snapShotControlOptions = { hidden: true }; 
       snapShotControlOptions.buttonLabelHtml="<snap id='snap' style='display:none' >snap</span>" 
       snapShotControl = new SnapShotControl(snapShotControlOptions); 
       map.addControl(snapShotControl); 

đây là phương pháp Take chụp để chụp sanp của bản đồ google.

 function takeSnap() { 

      //static map size 
      var sizeStr = "640x640"; 
      var imgSize = ""; 
      if (sizeStr != "") { 
       var sizeArray = sizeStr.split("x"); 
       imgSize = new GSize(sizeArray[0], sizeArray[1]); 
      } 
      snapShotControl.setMapSize(imgSize); 
      var format = "jpg"; 
      snapShotControl.setFormat(format); 

      var url = snapShotControl.getImage(); 
      //   document.getElementById("snapshot_canvas").src = url; 
      SaveImage(url); 

      //   
     } 

//this will add polyline overlay to draw line on google map with different color of polyline on google map . 

    var polyline = directionsArray[num].getPolyline(); 
       polyline.setStrokeStyle({ color: streetColor, weight: 3, opacity: 0.7 }); 
       polyline.ssColor=streetColor;     
       map.addOverlay(polyline); 


///this code will open the pop info window on polyline those polyline created on google map 

và sự cố là cửa sổ pop của chúng không được bao gồm trên sanpshot khi tôi lấy sanpshot của bản đồ google.

var MousePoint = ""; 
       var marker; 
       GEvent.addListener(map, "mousemove", function (point) { 
        MousePoint = new GLatLng(point.lat(), point.lng()); 

       }); 

       GEvent.addListener(polyline, "click", function() {     
        map.openInfoWindowHtml(MousePoint, headMarkerHtml);     
       }); 
       GEvent.addListener(polyline, "mouseout", function() { 
        // map.closeInfoWindow(); 
       }); 

bạn có thể vui lòng cho biết tôi vượt qua cửa sổ bật lên trong lớp phủ đa giác hay không.

tôi có sử dụng tệp javascript snapshotcontrol.js để chụp nhanh.

+0

bạn có thể đưa ra tập lệnh jsfiddle không? Tôi có thể giúp bạn nhưng tôi nên xem mã của bạn khi chạy – Mehmet

Trả lời

0

từ nguồn snapshotcontrol

thư viện này làm cho nó dễ dàng để tạo ra một hình ảnh "chụp" của bản đồ tương tác của bạn, bằng cách sử dụng API của Google Maps tĩnh.

bản đồ tĩnh không hỗ trợ cửa sổ thông tin hoặc bất cứ điều gì giống như thêm văn bản tùy chỉnh để bản đồ https://developers.google.com/maps/documentation/staticmaps/index

Bạn có thể vẽ bản đồ trên một canvas trong trình duyệt sau đó vẽ cửa sổ thông tin trên hết sử dụng số này http://html2canvas.hertzen.com/ và sau đó tải xuống nội dung canvas

Các vấn đề liên quan