Obtaining GE Plugin Client Coordinates - google-earth-plugin

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

Related

drawing tools on Mapbox

I have added some drawing tools to my Mapbox map using the following code provided on the Mapbox website... https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
I removed anything to do with the area measurement calculation as I only wanted to be able to draw on the map.
However, the map is set to default draw without having to click the drawing icon. This means when the page opens rather than being able to pan around the map the cursor is a crosshair and begins drawing.
I noted the following section in the script but not sure what to put in place of "draw_polygon" to stop it from being the default.
// Set mapbox-gl-draw to draw by default.
// The user does not have to click the polygon control button first.
defaultMode: 'draw_polygon'
});
Anyone have any ideas how to stop draw polygon from being the default?
Also any other ideas on other/better drawing tools?
The default mode is simple_select, so you can either add this in place of draw_polygon, or just remove the defaultMode option altogether and it will start in simple_select mode.

Unity canvas overlap using networking

I am using the new unity networking using unity 5.3.1 , my player prefab is a UI canvas , so when another client joins the canvas's overlap and I cannot press any button on host or client .
What i want is to disable other canvase's on each players game and just leave the local players canvase active , I have tried islocalplayer , isclient ,isserver but nothing works .
Is there a way around this please do tell.
Here are some options I can think of:
1) Instead of making canvas a player object, make panel a player object, so that all your players are different panels under same canvas. Now, when object are under same canvas, they ray casting order is determined by the order in hierarchy.
The objects that are lower in the hierarchy occlude those that are higher. So, what you can do is moving your player object to the lowest position in objects hierarchy, so that it will occlude all other players. This can be done using Transform methods SetSiblingIndex and GetSiblingIndex, like
transform.SetSiblingIndex(100000/*some big number*/);
2) Disable raycasting on all other players - what if you can click some component on canvas or not is whether it is a raycast target. Images and Text components can be raycast targets, or more generally any component that inherits from Graphics. You can iterate over all components of type Graphics in all players except the local player and mark raycastTarget = false.
I figured it out and as #NikaKasradze said use only one canvas and put all gui listeners in the islocalplayer bool check .

does google map event triggers the google map to be reloaded?

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.

Google Maps Overlay Infowindow Div

I am hoping someone can point me in the right direction. I have a google map v3 with fusion table that I am looking to create a custom box with the content that would normally be displayed in an infowindow.
Much like http://www.instaearth.me or
http://chrismcaleenan.com/map/?page_id=7
So the user clicks on the marker and the content is loaded into a box/window/div that is not attached to the marker itself.
Does anyone know of any samples / tutorials where someone shows this being done.
Thanks
The FusionTablesLayer has a FusionTablesMouseEvent which is returned on a click (if you add a click event listener to the FusionTablesLayer). That Object contains the data in the row associated with that geographic object (icon, polyline or polygon), and you can use it to populate an HTML div on your page.
working example, zoom in past zoom level 2 to see the FusionTable code work, at zoom 0, 1 it uses the KmlLayer

How to scroll window contents using Direct2D api?

I would like to scroll window contents in which drawing is performed with Direct2D api through ID2D1RenderTarget.
In GDI I could create a buffer with CreateCompatibleDC and later scroll its contents with ScrollDC, redraw exposed area and BitBlt the buffer to window.
I cannot see any necessary API in Direct2D to perform the same operations. How can I achieve the same functionality without using GetDC (and GDI), and without using own third buffer?
There is no Scroll API in Direct2D. Your best solution to get hardware accelerated scrolling is to use a 2nd buffer. On the ID2D1RenderTarget that you want to scroll, use CreateCompatibleRenderTarget() to create an ID2D1BitmapRenderTarget (it's a good idea to cache this guy) with the same pixel size as ID2D1RenderTarget::GetPixelSize() and with the same resolution as returned from ID2D1RenderTarget::GetDpi(). Then, use ID2D1BitmapRenderTarget::GetBitmap() to get the underlying ID2D1Bitmap. Next, use ID2D1Bitmap::CopyFromRenderTarget() copy the contents with adjustments for the distance you're scrolling. Then copy that bitmap's contents back to the original render target, re-render the uncovered area, and present (via EndDraw).
You can use translation.
MSDN: To translate a 2-D object is to move the object along the x-axis, the y-axis, or both.
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(20, 10));
More details here
http://msdn.microsoft.com/en-us/library/windows/desktop/dd756691(v=vs.85).aspx
In DXGI 1.2 there is a new IDXGISwapChain1::Present1 API call with DXGI_PRESENT_PARAMETERS
parameter. It contains functionality supporting scrolling window contents.

Resources