Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:40:23+00:00 2026-05-21T08:40:23+00:00

I am trying to use JSNI to display a Google Map within an Application.

  • 0

I am trying to use JSNI to display a Google Map within an Application. I have defined the script in my index.html page.

Here is the uibinder definition (snipped down to the essentials):

<g:HTMLPanel ui:field="mapboxV3ContentPanel">
    <!-- div for display of the actual map -->
    <div id="map"><!-- --></div>
</g:HTMLPanel>

Here is the initializeMap() native function:

private native void initializeMap() /*-{

    var latLng = new $wnd.google.maps.LatLng(-34.397, 150.644);
    var mapOptions = {
        zoom: 8,
        center: latLng,
        mapTypeId: $wnd.google.maps.MapTypeId.ROADMAP
    };
    var mapDiv = $doc.getElementById('map');
    if (mapDiv==null) {
        alert("MapDiv is null!");
    }
    var map = new $wnd.google.maps.Map(mapDiv, mapOptions);
}-*/;

Unfortunately, mapDiv is null. Any help out there?

I am aware of the gwt-maps and gwt-maps-v3 projects. The first only supports v2 of the API, and gwt-maps-v3 will not work for me, hence the JSNI approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:40:23+00:00Added an answer on May 21, 2026 at 8:40 am

    In principle, your code should work, and I’ve quickly tested it (by the way, it shouldn’t be related to the Google Maps API at all).

    The only important thing is, that you add your <div id="map"> to the document before you call initializeMap().

    Please try the following:

    @Override
    public void onModuleLoad() {
    
      RootPanel.get().add(new MyUiBinderWidget()); // your widget with the map div
      initializeMap();
    }
    

    Note especially, that you can’t call initializeMap() from inside the constructor of MyUiBinderWidget, because at that point, the widget isn’t attached to the document yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use gem tire to search in my application. I have tables
I am trying use Google Maps for my work; I have downloaded an example
I have been trying use zenity with standard re-direction in a shell script, something
i'm trying use facebook API to upload photo in my fan page. I downloaded
Hi I'm trying use a datepicker on a field I have. I'm trying to
I am need paint my image. I'm trying use JQuery in here this link:
Trying to use Powershell to script the removal of specific custom errors from an
I've encountered an curious problem while trying to use some objects through JSNI in
I have been trying use the edit_post_link() function to contain an image. All of
I'm a little confused here, I am trying use a partial view in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.