Checking my understanding of Google maps:
I am developing a web page that displays a number of different types of information for my employer's facilities. I have been using a multiview, and activating the proper view depending on user input (button toolbar). When I add a view to be a map to the selected building, I run into problems. I can make the map appear when the user navigates to the building map view. But when the user navigates away from that view, the maps api gives me the error
0x800a138f - JavaScript runtime error: Unable to get property 'offsetWidth' of undefined or null reference
As I understand it, this is because when another view becomes active, the view that contains the map is no longer rendered. The api is trying to access an object that no longer exists.
I could try to clean off the object - remove all listeners, delete the object, even delete the div that contains it. But I have just read through the related question on how to destroy a map instance and listened to Chris Broadfoot and Luke Mahe's discussion on the topic.
From this, my understanding is that the google maps api was not designed for this kind of handling. So, it is really not designed to be compatible with something like multi-views.
Is this right? If not, what am I missing? If so, any suggestions for a web app newbie on what to use instead of multiviews (I am thinking panels and hide/show as needed)?
Update and kind of an answer...
I switched to using multiple panels and hiding all the panels, except the one with the information the user chooses to use. The map then displayed blank unless I did one of two things: set the map to be created as an endRequest...
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(myInitMap);
If I understand that correctly, it means my handler (myInitMap) gets executed (map recreated) after every postback. Also, this seems to be a bit unstable - sometimes IE would give me errors, and I could not figure out a pattern or reason. Chrome would work ok every time.
The other way that worked was to not call the map creation on any particular event, but rather to register my map init script from the code-behind page_load event. My panels and my multi-view had been encased in an Update Panel, and I needed to register the script under that Update Panel...
ScriptManager.RegisterStartupScript(DataUpdatePanel, DataUpdatePanel.GetType(), "ShowGoogleMap", "myInitMap();", true);
This is because what is causing problems, I think, is that my panels (and my multi-view in the earlier version) were inside that UpdatePanel. The map creation script and API calls were not happening in the right sequence with everything else as the UpdatePanel performed a partial page update. Registering the map init scrip with the Script Manager basically told it to put it in the right place (at the end?) of that partial page update.
Also, I could not figure out how to update the map. The script is basically regenerating the map every time. I tried keeping a var pointer to the map so that I could test if that had already been created, and then just update it, but that did not work. The UpdatePanel partial page update is, I presume, working much like a whole page refresh, but for only what is contained in the UpdatePanel. So when the partial update happens, the previous contents are disposed of and recreated, so the map has to be recreated as well.
If anyone understands this differently, I would love some redirection.
Related
It is common to have multiple environments doing dev, staging and production. Forge App creation page also instruction that this is possible. However, no matter how I fill in the field, I always get a rejection. Please instruct how this field can be filled in with more than one callback URL.
Currently it is only possible to specify a single callback URL. You can however change it whenever needed, by clicking the EDIT button in your Forge application page.
Btw. we are already working on adding support to multiple callback URLs but don't have an ETA on when it's going to be available to the public.
Currently, I have a use case of returning to my application from google maps when the user reaches to the destination.
Having read some articles, it is known that performing this functionality in IOS may not be possible. However, on reading this article, i tried using
comgooglemapsurl://maps.google.com/maps?f=d&daddr=Tokyo+Tower,+Tokyo,+Japan&sll=35.6586,139.7454&sspn=0.2,0.1&nav=1
&x-source=nameOfMyApp
&x-success=urlOfMyApp://?resume=true
which does not trigger the callback. Is there any other settings that is to be made that I am missing?
Also, what would be the approach for the same in android?
We have a Microsoft Access App we use out in the field when inspecting properties. We are building/adding an embedded.html file that uses OpenLayer to display a map showing our current geolocation and our destination. After we finish an inspection, we select the next property in our route list and it's highlighted on the map.
How do we communicate the selected property to the embedded map without reloading the map each time?
Mockup: http://i.imgur.com/zOCIXpe.png
Current Solution
Currently, we embed the map using Access's web control. Each time we select a record, Access reloads the embedded map and passes the upcoming property via an append to the URL.
Pseudo Code URL: C:\Applications\Inspection App\map.html?highlight:address123
This is very slow, especially on the road where we use cellular data.
Desired/Potential Solutions
Our goal is to pass a new property to the embedded map each time we select a new record without reloading the map.
Two hypothetical options I'm aware of are:
Designing the .html file and passing the URL in such a way that that full page isn't reloaded.
Using Microsoft Access Visual Basic to pass a message to the .html file that it can use.
My company uses MS-Access extensively and I embed OL3 maps in pretty much all of the applications we use.
The method I use to communicate with the map without having to refresh the page is to write a JavaScript function that MS-Access then executes, either by button press, tab change, etc...
Assuming your Web Browser Control is called "WebBrowser", this would fire the specified JavaScript function.
Private Sub ExampleButton_Click()
WebBrowser.Object.Document.parentWindow.execScript "javascriptFunctionYouWishToExecute(" & Args & ")", "JavaScript"
End Sub
I've yet to find an elegant solution to get the reverse working, other than writing to a hidden HTML div and having MS-Access read that via a timer.
I have put together an app which locates a user's current position, geocodes a current address and then puts them on a map (using the google maps api) with a calculated route between the two.
It works fine in itself - but I am finding that the first time using it on a new phone or browser, the initial prompt as to whether the user would like to share their positioning data or not is stopping it from actually resolving a position.
Is there a way to pause the script while that prompt is visible or any other ways I could either delay the script or detect when this has happened?
Thanks!! :)
I would start a timer onCreate that checks once a second for permission to be true. Or create a function that starts location update and execute it when button is clicked. I'm not sure if that was your question though.
I have a testsite which loads at the push of the magnifying button .../forms/viewlab.php?sid=2 dynamically via jquery 'load' (ajax).
Viewlab.php contains a with id "map" and should load/display a google map.
Strange thing is that upon push of the button ("load map"), the goggle map only loads for a split second (depending on the speed of your computer you can actually see it flicker once) and then disappears.
I am using the google ajax api to load google maps and jquery. Any any idea how to make that work?
Try not calling GUnload() until your page exits. At present you're calling GUnload() before creating the map.
I guess that GUnload() might be asynchronous, so that you manage to create the map before GUnload() finishes destroying the API code, but as soon as you return control from your map creation the rest of the GUnload() processing executes, taking down the API, erasing the map and recovering the memory used.
I don't have a concrete maps example by hand, but it's rather an AJAX related issue, i assume.
the problem might be, when which events do happen and when which code gets triggered:
You might need to move some code out of the document ready function,
then you can bind the AJAX on document ready by a function call ...
... and later re-bind it by a callback function call within the form's success function.