locked
Google Maps Api with Windows Store app using C#/Xaml RRS feed

  • Question

  • Is there a way to use google maps api in a windows store app using c#/xaml?

    i tried using a webview but it raised an exception because i think it was trying to load the Javascript from an external source.

    Sunday, July 28, 2013 10:16 PM

Answers

  • WebView uses invokeScript method to run javascript function from the html page loaded in it. From the exception you are facing, I can say that it is trying to call "alert" method in the js file or js part and not getting the method. I suggest you to define a javascript function in html and call it from webview.

    For example, javascript function in either js file or within html page itself.

    function test1() {
                alert "this is a test alert!";
            }

    C# method calling invokeScript:

      webview1.InvokeScript("test1", null);// Invokes javascript function

    This should call the test1() method from  javascript and display the alert. 

    Please try this.

    Monday, July 29, 2013 5:57 AM

All replies

  • Hi,

    What kind of exception did you get? Can you more specific about the issue you are facing and on doing what? 

    You may get this link helpful. Please check out. 

    http://www.creepyed.com/2012/11/how-to-use-the-google-maps-api-on-windows-8/

    Good Luck!

    Monday, July 29, 2013 4:43 AM
  • "An unhandled exception ("alert" is underfined) occured in *project name* [13092]."

    i checked that article out already but it was with JS/HTML

    Monday, July 29, 2013 4:54 AM
  • WebView uses invokeScript method to run javascript function from the html page loaded in it. From the exception you are facing, I can say that it is trying to call "alert" method in the js file or js part and not getting the method. I suggest you to define a javascript function in html and call it from webview.

    For example, javascript function in either js file or within html page itself.

    function test1() {
                alert "this is a test alert!";
            }

    C# method calling invokeScript:

      webview1.InvokeScript("test1", null);// Invokes javascript function

    This should call the test1() method from  javascript and display the alert. 

    Please try this.

    Monday, July 29, 2013 5:57 AM
  • Thanks.. figured where i made my mistake
    Monday, July 29, 2013 7:02 PM
  • That's good!

    Can you share what you figured out? I guess it would be helpful for others as well.

    And please mark the reply as answer which helped you out.

    Good Luck!

    Tuesday, July 30, 2013 6:51 AM