2013-12-11 15 views
5

utilizzando IE 11, Windows 8.1.Stampa google maps in un controllo del browser - non mostrerà la linea di direzioni

che sto collegando il seguente in un'applicazione Windows Form:

var html = "<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" " + 
       "src=\"https://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=Oklahoma+City,+OK&amp;daddr=texas&amp;hl=en&amp;" + 
       "geocode=FSgxHQIddAQw-imB0vh-VIqthzGdOk_RdBKiMw%3BFVfN5wEdi54L-ilJMoILNnBAhjE83ggYjxzrFg&amp;aq=t&amp;sll=39.632471," + 
       "-56.554076&amp;sspn=61.466508,135.263672&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;z=7&amp;output=embed\">" + 
       "</iframe>" + 
       "<br /><small><a href=\"https://maps.google.com/maps?f=d&amp;source=embed&amp;saddr=Oklahoma+City,+OK&amp;daddr=texas" + 
       "&amp;hl=en&amp;geocode=FSgxHQIddAQw-imB0vh-VIqthzGdOk_RdBKiMw%3BFVfN5wEdi54L-ilJMoILNnBAhjE83ggYjxzrFg&amp;aq=t&amp;" + 
       "sll=39.632471,-56.554076&amp;sspn=61.466508,135.263672&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;z=7\" style=\"color:#0000FF;" + 
       "text-align:left\">View Larger Map</a></small>"; 

     webBrowser1.DocumentText = (html); 

Ora voglio stampare questo come si è visto, ma non mostra le direzioni righe quando ho avuto modo di PrintPreview

private void button1_Click(object sender, EventArgs e) 
    { 
     this.webBrowser1.ShowPrintPreviewDialog();   
    } 

Ho provato diverse emulazioni del browser e ancora nessun modo per stampare le linee di direzione in google maps. IE6 - 11 senza fortuna.

SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); 

    public static UInt32 GetBrowserEmulationMode() 
    { 
     int browserVersion = 7; 
     using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", 
      RegistryKeyPermissionCheck.ReadSubTree, 
      System.Security.AccessControl.RegistryRights.QueryValues)) 
     { 
      var version = ieKey.GetValue("svcVersion"); 
      if (null == version) 
      { 
       version = ieKey.GetValue("Version"); 
       if (null == version) 
        throw new ApplicationException("Microsoft Internet Explorer is required!"); 
      } 
      int.TryParse(version.ToString().Split('.')[0], out browserVersion); 
     } 

     // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10. 
     UInt32 mode = 11000; 

     switch (browserVersion) 
     { 
      case 7: 
       // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control. 
       mode = 7000; 
       break; 
      case 8: 
       // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8 
       mode = 8000; 
       break; 
      case 9: 
       // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9. 
       mode = 9000; 
       break; 


      case 10: 
       // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9. 
       mode = 10000; 
       break; 

      default: 
       // use IE10 mode by default 
       break; 
     } 

     return mode; 
    } 

Qualcuno può aiutarmi a capire perché questo non stampa le linee di direzione? Tieni presente che, inserendo direttamente questo html in un file .html e aprendo con IE, verranno mostrate le linee delle direzioni. Ma non stampano.

Aggiornamento

Utilizzando Internet Explorer, è possibile collegare quanto segue in un documento con estensione html.

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"  marginwidth="0" src="https://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=Mesa,+AZ+85201&amp;daddr=85258&amp;hl=en&amp;geocode=FXkl_gEduWFV-Sm5aealKggrhzGuOvW7FLWhww%3BFQ8xAAIdIJBU-SmHMd6RyworhzFB0o03Vh1_HQ&amp;aq=t&amp;sll=34.168218,-111.930907&amp;sspn=16.819377,33.815918&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;ll=33.511629,-111.898842&amp;spn=0.100189,0.145912&amp;z=12&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=d&amp;source=embed&amp;saddr=Mesa,+AZ+85201&amp;daddr=85258&amp;hl=en&amp;geocode=FXkl_gEduWFV-Sm5aealKggrhzGuOvW7FLWhww%3BFQ8xAAIdIJBU-SmHMd6RyworhzFB0o03Vh1_HQ&amp;aq=t&amp;sll=34.168218,-111.930907&amp;sspn=16.819377,33.815918&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;ll=33.511629,-111.898842&amp;spn=0.100189,0.145912&amp;z=12" style="color:#0000FF;text-align:left">View Larger Map</a></small> 

Questo stamperà tutto correttamente in Firefox. L'ho provato su più stampanti.

Questo non viene stampato correttamente in IE. Ho provato la seguente:

https://support.google.com/maps/answer/21849?hl=en

Tutte le idee su come ottenere le linee di presentarsi?

+0

Eseguo il codice nella mia app, ma va bene, io uso framework3.5, un'app winform. –

+0

Quindi, quando sei andato su printpreview hai visto apparire le linee? – Watson

+0

può essere solo un problema di emulazione del browser, provare a impostare FEATURE_BROWSER_EMULATION http://stackoverflow.com/questions/15874565/how-to-set-ie9-by-default-for-web-browser/15883250#15883250 – volody

risposta

0

Non so se la soluzione sia qui da nessuna parte. Non riesco a ottenere il mio (IE8 su XP) per non mostrare correttamente l'anteprima di stampa. Che, a proposito, è la prima volta che qualcosa ha funzionato per me su XP ma non su qualcun altro su un SO più recente. Ma, qui ci sono le chiavi di registro che di solito finiscono scherzi con:

HKLM:

SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BROWSER_MODE (10) // la versione

SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BEHAVIORS (0 o 1)

HKCU:

softwar E \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_USE_LEGACY_JSCRIPT (0 o 1)

SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BROWSER_EMULATION (N000)

Inoltre, assicurarsi che questi (o equivelant) opzioni sono ambientati in Internet Security Zone di IE.

  • Consenti script di controllo del browser web di Microsoft
  • script controlli ActiveX contrassegnati come sicuri per lo scripting

Gook fortuna!

+0

Provato diverse combinazioni ma senza dadi. Tutto questo funzionava correttamente per me, l'aggiornamento di Windows o un aggiornamento del browser l'ha ucciso. Se provo ad emulare il browser sotto IE 10, questo errore si verifica: http://stackoverflow.com/questions/20506925/wpf-webbrowser-control-and-google-maps-overlays-gray-image – Watson

+0

Pensi che sia possibile se il webbrowsercontrol sopprime un errore di script ma quando viene stampato non viene soppresso? – Watson

+0

Forse. Provaci. Disabilita la soppressione e vedi se ottieni un errore quando tenta di eseguire il rendering dell'anteprima. – drankin2112

Problemi correlati