- This topic has 15 replies, 3 voices, and was last updated 11 years, 9 months ago by support-michael.
-
AuthorPosts
-
alonso100MemberHello
I created a google map following this example and some examples from internet so that whenever the user clicks on the map, it then shows the coordinates in an info box. It works fine if it runs as a single screen.
If I create a Main screen which calls that screen with the map, then it does not work any more; not even the centering of the map on a specific location works. Whenever I make a click application does not capture the event and therefore, the code behind it is not executed. The map itself is working. Neither the test center nor Chrome inform about bugs in the code.
In the attachment I am including the files for checking. It is a page1 which calls page2 (has the map). I can tell you about these bugs(?):
1) as step 1 I center the map on a location, which does not occur
2) as step 2 I declare the event handler ‘click’, which the application does not listen
3) clicking on it is not trapped4) not a bug but must be improved: Mobione assigns this line after the JS files in Main.htm, so this triggers an error because the application logically does not see variable google
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
I have to move it manually to the top but then, the next time that I execute the application it tells me that the file has been modified.
So, am I missing something or do we have here another bug ??
Attachments:
You must be logged in to view attached files.
jimMemberGoogle maps api and mobiOne are working fine. I’m working on a very complicated app that does centering, multiple markers and satellite updates. Everything is working in my App.
Your code looks much different than the example and what I’m doing. Your initialize routine doesn’t get called (put an alert in there and you’ll see) and it’s not in a **_custom.js file which I thought was pretty important. It looks like all you’re doing is showing the default Map centering on Berlin from the map widget.
alonso100MemberHi,
it is indeed called !! I didn´t send the *_custom files. As I explained, if page 2 starts standalone, it works fine. If page 1 starts and calls page 2, then it does not work. One must write manually the call to the Initialize function in page 2 or page 1.
support-michaelKeymasterresearching this now! will follow up after I’ve had some time to investigate.
support-michaelKeymaster1) you should not have to adjust the googlemap api import order. It works fine as is.
2) I simplified your code and the example seems to work with no issues. The gmapready() callback is not performed until the map is being prepared to render, e.g., when I click the button transition to page2 is when the map is prepared to render.
Here is how the initializeMap() is called from Coorden1_custom.js
/** * Called when document is loaded. */ phoneui.documentReadyHandler = function() { initializeMap(); }
Attachments:
You must be logged in to view attached files.
alonso100MemberHello,
thanks for your help!! This time it works for me too, but I still have some questions/comments:
to 1) googlemap api import order is necessary, because I get an error in the debugger. Should be considered for a future release.
to 2) what is the meaning of “map is being prepared to render” and this line of code: ??
$('[id$=map1]').gmapready(function(gmap){
map1 must be the name of the map widget on my application, so it must be renamed to avoid confusion with similar widgets. I assume that we´re waiting till the map has been fully loaded and is ready, so that we declare the code for catching the event click.
support-michaelKeymaster> 1) googlemap api import order is necessary, because I get an error in the debugger
Will give this a look but have not seen any error in debugger. I looked earlier before responding. I’ll bug the dev team about this. Can you post details about what debugger you are using and include a screenshot to help guide.
> 2) what is the meaning of “map is being prepared to render” and this line of code:
See section 3 of the Map Developers Guide here http://www.genuitec.com/mobile/docs/usingMaps/usingMaps.html
alonso100MemberHi,
in the attachment the requested image. The error occurs when I generate the application; Mobione writes the main.html file and after the declaration of the JS-files, it inserts the line for the google maps:
blah, blah, blah <script type="text/javascript" src="UpdateDB.js"></script> <script type="text/javascript" src="res/jplayer/jquery.jplayer.js"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"></script> </head> <body> etc. etc.
When I move the 2 last lines for the google APIs to the top (between the <link> and the <script> sections), then the message dissapears. Tested right now with Safari, but I see the line with Chrome and also in the test center.
The warning message is because of the line for the geometry library; without this one google maps cannot calculate the angle between 2 points on Earth. Should be considered for future releases.
Attachments:
You must be logged in to view attached files.
support-michaelKeymasterHi Alonso,
Apologies for being a little dense on the map api topic. I get it (finally). I have opened an enhancement to address this based on your feedback and google requirements as outlined here: https://developers.google.com/maps/documentation/javascript/libraries
Will follow up as soon as soon as we have a plan to address it.
support-michaelKeymasterUpdate on an improvement scheduled for MobiOne 2.3.1 to address the additional api’s issue.
The Google Map API settings will include additional apis to import: See attachment googlemap-prefs.png
Here is an example of the google map api import that is generated from the preferences: See attachment gmap-code.png
Attachments:
You must be logged in to view attached files.
alonso100Memberhi,
this is good to know but remember that the declaration of the links to the APIs goes on the top of the main.html; otherwise, we have to do manual work.
support-michaelKeymaster>this is good to know but remember that the declaration of the links to the APIs goes on the top of the main.html; otherwise, we have to do manual work
Is this because you have javascript in other files that is running as it is loaded and it expects the google map api to be already loaded? I want to learn more as I believe our dev team may argue that adding the api first is as arbitrary as adding it last since the apis are loaded asynchronously and maps are not instantly ready as the page loads.
alonso100MemberIt is correct as you mention it. It is not the same on top or on the bottom when you have JS-files which call the functionality behind the google maps APIs. I thought that the topic was very clear with my answer in this thread from the 13.01.2013. I attached some screenshot with the error message.
support-michaelKeymaster> I thought that the topic was very clear with my answer in this thread from the 13.01.2013.
Not to be difficult but the topic is not completely settled without the dev team signing off on it. We have a review tomorrow of all features planned for release and open topics, including your assertion on the specific ordering.
Q: for our review can you share a snippet of the code in your label.js that is being executed on load that references the google api?
The reasons for my asking is to provide my team more than a screenshot of an error. The tech team will research this to ensure there is not a race condition here such that relocating the gmap api import improves the odds that the api will be fully loaded before its use but can not be guaranteed… just a thought.
alonso100MemberI am sending the files per email. Check it now with subject “Google maps – declaration of APIs in main.html”
-
AuthorPosts