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 7839655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:30:24+00:00 2026-06-02T15:30:24+00:00

Ok I am making a program in dart that fetches the user location and

  • 0

Ok I am making a program in dart that fetches the user location and then reverse geo location(openmapsapi)
and then displays the news with the particular city name(google news api)

I add use the following code for the openmap api and get the city in the local storage.
From there I wanna use the similar code for the google news api but it throws an error probably two window.on.data lines cannot be added.A part of the code was taken from Seth Ladd’s blog and am a little clueless how everything is working.

    window.on.message.add(locReceived);
    Element script = new Element.tag("script");
    var somelat=window.localStorage.$dom_getItem("LAT");
    var somelng=window.localStorage.$dom_getItem("LNG");
    var someurl="http://nominatim.openstreetmap.org/reverse?  format=json&lat="+somelat+"&lon="+somelng+"&addressdetails=1&json_callback=callbackForMapsApi";
    script.src=someurl;
    document.body.elements.add(script);

This is my relevant html code I am using

      <script type="text/javascript">
function callbackForJsonpApi(s) {
    window.postMessage(JSON.stringify(s), '*');
}

function callbackForMapsApi(s) {
    window.postMessage(JSON.stringify(s), '*');
}
</script>

Not really worked on web technologies before,any help would be appreciated.

  • 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-06-02T15:30:25+00:00Added an answer on June 2, 2026 at 3:30 pm

    You should only have one window.on.message.add since all message handlers will receive all messages from JavaScript which can lead to concurrency issues. Instead ensure the JavaScript code adds a target header to the message it sends:

    function callbackForJsonpApi(s) {
        s.target = "dartJsonHandler"
        window.postMessage(JSON.stringify(s), '*');
    }
    
    function callbackForMapsApi(s) {
        s.target = "dartMapsHandler";
        window.postMessage(JSON.stringify(s), '*');
    }
    

    And then switch on this target header in the Dart code. I do similar tricks in DartGap (a dart wrapper for PhoneGap) you can take a look at the relevant code here.

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

Sidebar

Related Questions

I'm making a program that asks for an integer from the user, it then
I'm making a program that generates a maze and then uses bredth first search
I am making a program that concatenates two strings given by user. Everything is
I'm making a program that fits the wizard concept ideally; the user is walked
I am making a program that loads videos from a server and then saves
Im making a program for class that manages a Hotel. I have a function
I am making a program that automates the seperation of a csv file. We
I am currently making a program which is supposed to prompt the user to
I am making a program that graphs a line based on data inputted by
I am currently making a program that will send an email if the date

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.