does google map event triggers the google map to be reloaded? - google-maps-api-3

I've recently created a website that display uses a Google map. I was wondering does the google.maps.event.trigger(map, 'resize') causes the map to be reloaded from Google? Or is it just plain UI redraw from local machine that doesn't call back to Google api?

from the documentation:
resize - None - Developers should trigger this event on the map when the div changes size: google.maps.event.trigger(map, 'resize').
This event informs the API that the map DIV has changed size, it will do what is needed, which may involve fetching additional tiles from the tile servers, but not necessarily (if the map got smaller, there shouldn't be any additional tiles required). It won't cause an additional load of the API.

Related

Prevent multiple loading of Google maps on a single element

I am binding a hidden DIV element with Google maps, when the DIV element is being shown. The user can show and hide the DIV multiple times. I want Google Maps to be loaded and bound to the element only once, and not everytime the DIV is (hidden and) shown. Is there any API method from Google Maps which will check if the element is already bound to a Google Map object?
map.getDiv()
gives you the current div the map is bound to.
Hope this is helpful. You can easily implement the functionality.
Initialize the Map once. Then just hide and show the div as per requirement.
Just make sure to Initialize the Map when the Div is visible or else you will run into problems of improper map rendering. (at least this happens if you have bootstrap).

Obtaining GE Plugin Client Coordinates

I am writing a WinForms application with a WebBrowser control. I use Google Earth Plugin in this application, and need to create some placemarks on Google Earth. Depending on the current range (zoom level) some of the placemarks may be very close to each other on screen (when the earth is zoomed out enough). In this case I want to create not all but just some of the placemarks to avoid over-crowding the map on screen with placemarks.
For example, suppose I have 1000 points I want to create placemarks. When I loop through all the points for the placemarks to be created I want to convert the lat/long of each point to the WebBrowser control's client coordinates so I can check to see if it is very close (on screen) to other placemarks already created. If it is very close to other placemarks I just skip the creation of this one. So if the user zoomed out to a certain degree the actual number of placemarks created may be much smaller than 1000 (for example, 400).
This is where I have difficulty with. I don't know if there is a way to convert lat/long to client coordinates of the WebBrowser control hosting Google Earth Plugin. I know that for mouse events the client coordinates are there for me to use but there is no mouse event involved in this case.
Anybody has an idea how this can be achieved? Thanks!
The approach you're trying to use to fix the problem is incorrect. However there a few options:
Going with your current approach -- you have two options:
You can ask the current view to convert a given lat/lon to screen X/Y.
https://developers.google.com/earth/documentation/reference/interface_g_e_view#a8c39d0324f2350c54fe2de981f1be418
You can get client mouse coordinates as part of KML mouse events that are fired off the GEWindow class:
https://developers.google.com/earth/documentation/reference/interface_g_e_window-members
The KMLMouseEvent that is fired contains client X/Y space:
https://developers.google.com/earth/documentation/reference/interface_kml_mouse_event
The correct approach would be to add KML region tags to your placemarks so that placmarks show/hide as the user pans/zooms etc.
http://www.google.com/earth/outreach/tutorials/region.html

Marker clusterer calls zoom_changed event of the map twice

I'm using this third party library, called Marker Clusterer with the Google Maps API. http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/docs/reference.html
I am trying to trigger an event when the map's zoom level is changed. The odd thing I've noticed though, is that when you click on a marker cluster, it calls the zoom event twice. Has anyone come across this odd error before? Why would it trigger the zoom callback twice? When I zoom normally without using clusters, the zoom callback is only called once.
Any ideas?
Looks like that behavior is a fix for an issue on IOS. You can download your own copy of the code and remove the additional call to fitBounds if you don't need it.

How to bind an infowindow as a property of a marker (google maps API v3)

Anyone know how to bind an infowindow as a property of a marker?
when I delete a marker, the infowindow goes with it also deleted.
I had a similar problem, my way around it was to suppress the built in info windows. From there I had the click event call a specific window from an array of info windows. That was my hackish way around making my own info windows without working with the given window.

Can a flex app (or a portion of a flex app) be made transparent to mouse clicks?

I need to superimpose my Flex app above a plain HTML control on a web page, and be able to click through the Flex app to interact with the HTML control. Is there any way to do this? No permutation of mouseEnabled="false" or mouseChildren="false" seems to have the desired effect.
Context: trying to integrate Google Earth API (JavaScript/HTML) with my flex app. I am leaving a portion of the flex app transparent and empty, and positioning the Google Earth widget just below that point in the z-index. Google Earth has to be behind flex, because there are some Flex controls periodically displayed in that space.
I'm pretty sure there is no direct way for you to get mouse events to go through a Flash app.
You may be able to accomplish this with a combination of Javascript. Flash can call Javascript on your page, so you can create a function that passes clicks detected by Flash to the function and it will send the event to the page below it. I'm not 100% this will work but it's worth a try (You might have some trouble getting the correct coordinates).
Have you considered embedding Google Earth into the Flex app?
Some example here

Resources