I Have a div section named 'MapPanel' in which I defined the Google Earth Plug-in.
I have a form next to it and I wish that on a certain event the "focus" of the web page will be on the Google earth so that for example that I can move the map with the arrows.
I have tried $("#MapPanel").focus() without success.
The GEWindow object has a focus() method for this purpose.
You would call it like so, where ge represents the GEPlugin object.
ge.getWindow().focus();
Related
I have a project using the Google Maps JS API and I'm loading data onto it using the loadGeoJSON method. I also add a click listener to the map's data object.
In that click listener handler, I extract the mouseEvent which tells me the x,y that the user clicked as well as if they were holding down shift/alt/ctrl. Something changed recently though because I can't detect shift/alt/ctrl any more. They are always false.
Any help would be greatly appreciated. This fiddle should show more clearly what I'm talking about, just click on one of the 'google' letters.
fiddle
I use the following code (I quote parts of it) to post markers on a google map by right click to a point.
google.maps.event.addListener(map, 'rightclick', function(event) {
// code for open bubble for new marker
});
I need to open the bubble, also when someone do a long press tap on his tablet. Basically I need to make the application usable also for tablet/mobile users.
I read about jQuery plugins that handle touch events, but I don't know how to use them. I need a simple solution based on the code above (to run the "//code" which open the bubble.
Well, you can use the tabHold function on jQuery, with the click event in Google Maps JS API v2.
The taphold function in jQuery, can get the tab and hold action on tablet. But it does not return a lat lng to us.
For lat lng, we can grab it from the Google Maps Onclick function.
So we can combine the two like the following:
1. let tabhold set a flag, to indicate that this click function is from tabhold
2. on the onclick function, check if this current click event is from tabhold, if so, perform the action.
I have a quick demo on jsfiddle, I just copied and pasted some code so it looks kind of ugly. But hopefully it helps.
Google adds a javascript method to each search result (hyperlink).
Search any keyword from google, right click on a link, and copy link location or link address or just mouse down on a link and it will show the complete URL.
I need to simulate the onmousedown from c# to copy the complete link.
This is what Google render in HTML.
Canvas Wall Art Prints ยป Products
This link is shown on mouse down:
http://url/?sa=t&rct=j&q=&esrc=s&source=webhp&cd=1&cad=rja&uact=8&ved=0CDkQFjAA&url=http%3A%2F%2Fwww.canvaswallartprints.com.au%2Fproduct%2Fbonne-nuit%2F&ei=iQJtVZaBCsj8UKDqgMgE&usg=AFQjCNEAuSEgTR2_eYtjFFcXfNEHi8VVeA&bvm=bv.94455598,d.bGQ
There are lots of answers telling how to add events but in above case, the javascript function is already part of document, I just need to invoke it.
I am sharing my workaround to help if anyone else got stuck at same issue.
With GeckoFX I could not manage to invoke JavaScript method so, I had to move this part to WebBrowser control. Iterated HtmlElementCollection to reach the desired hyperlink and used the HtmlElement InvokeMember("onmousedown") to invoke the desired JavaScript function.
I want to add a google map in my website and letting my users pick a their location by clicking on the map in order to pass the address and coordinates to me (to store in my DB).
Does google provide this functionality? If yes, how?
It does, it's called geocoding.
edited:
You have to get the coordinates from the click first - add an event listener to the map for a 'click' event to call a function(event). Inside the function, you can access location by event.latLng. And from there, you can use the reverse-geocoding from the link above.
I am using Google Maps API to provide a form in a custom Map Overlay, similar to a native InfoWindow. I used an example by google to create a custom overlay, using their OverlayView Prototype.
Eventually this overlay doesn't have the same behaviour InfoWindow has regarding editing. Interacting with the window results in interaction with the map. One can neither select text in the window nor edit an input-field. Events are delegated to the map.
I already tried to play around with z-index, which won't work.
In their example you can't select text either - therefore you might have a look at their source.
It actually is a question of event propagation. Google provides another less obvious example which solves the problem:
http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/src/infobox.js
---> UPDATE 01/2015
Ian added another example that blocks propagation of all map events in comments.