How to get Mouse Coordination in GeoTools? - geotools

Firstly, i'm sorry that i m newbiew at Geotools. And i need to tackle mouse events in Geotools. How can i get mouse coordination as a Lat and a Lon in geotools?

You'll want to use a MapMouseEvent (http://docs.geotools.org/latest/javadocs/org/geotools/swing/event/MapMouseEvent.html)

Related

how to rotate the google map div with out changing the map dragging functionality

The question posted below
how to rotate a google map in a web application
can be use to rotate the map by rotating the div which contains the map
but if i do scroll or drag on the map the map is working in unpredictably way is there a way to retain those functionalities as it is
Note: i am rotating the map using div because the aerial tiles are not available at that location.
Please say whether this can be done with some other map api are how to go about it in google map API
It is difficult to answer with certainty unless you post a more complete answer, but I believe your issue is with the corrodinate system.
You are rotating the display of the map, but the x,y coordinates of your mouse are not. When you drag the mouse, the javascript is capturing the mouse movement relative to the screen and then you are rotating the output by 45 degrees. In other words, google maps has no idea that you have rotated it. It would be the same output if you just turned your monitor 90degrees, the mouse is still going to send the same x,y coordinates.
In order to do what I think you want you would need to take over the code handling the movement or accomplish it another way. You will notice that the dragging is disabled on the example you referenced.
This might be a place to start looking for getting the center of the map on mouse events:
https://developers.google.com/maps/documentation/javascript/3.exp/reference#MouseEvent
You might be able to get the current coordinates and "transform" the new coordiantes by looking at this example of getting pixels:
https://developers.google.com/maps/documentation/javascript/examples/map-coordinates
Here is a page explaining some things about transforming coordinate systems:
http://www.continuummechanics.org/cm/coordxforms.html
If this is something that you really have to do, it can probably be done, but it is likely a lot more trouble to get right than it is worth for an average map embed. It might also add a lot of processing that will make the interaction pretty laggy.
After saying all that, I'd still love to see an example of this working so if you do make it work please post some code.

Click / place object in map and get a circular selecion around it

im totally new to this, and I need some help.
I need to create an aviation range map. Look at the below link, and in the menu to the left theres a "Range maps".
I started with the Google Maps API Javascript V3, I thought it could be a good base to get rid of Flash.
Now I need some pointers for how I can either add an object to the map or just click in the map and that brings up a circle around the pointer with range for how far the aircraft can go.
I sure hope you understand, and can give me some pointers for how to start. Every tip is appreciated!
http://www.cessna.com/citation/citation-cj4/citation-cj4-performance.html
Sounds like you want a Circle overlay, which is pretty easy to make. The docs have easy examples to follow.
You'll also want an onclick event for each overlay and for the map itself. That way whenever someone clicks on the map or on an overlay, it creates your circle. Check out the events documentation.

How to animate a marker that is in a marker cluster

I have a web page with a google map (api v3) that has dozens of markers. I'm using markerclusterer to cluster the markers. And I have a separate panel div listing title info for each of the marker that appear on the map.
I've set up a hover event so that when the user hovers over one of the titles in the panel the corresponding marker on the map starts to bounce. This works fine if the marker hasn't been incorporated into an existing cluster. However, if the marker been incorporated into a cluster then it does not work because there is no marker to animate.
Is it possible to remove the marker from the cluster without removing it completely from the map, then animate the marker, then add the marker back to the cluster? (I took a look at the source code , but I couldn't figure out how to remove the marker from the cluster while still leaving it on the map.) Of course, if there is an easier way to tackle this problem I would love to hear about it.
After another day and another review of the source I figured out how to solve the problem, and it turns out that the answer is easy.
All you need to do is call marker.setMap(google.maps.Map object). Then, if you want to get fancy, you can call setSums on the ClusterIcon object to reduce the number of markers listed in the cluster overlay by one.
I figured out how to solve the problem.
#chuck w solution helped me.
call marker.setMap(map)
Then, if you want to get fancy, you can call
markerCluster.repaint();
to collapse to cluster

Draw area/polygon and retrieve coordinates with google maps

Is there any tool that can help me with getting the coordinates for a specific area/polygon?
I usually use Google Earth.
Draw a polygon, then move the mouse over and right click > copy.
Then you can paste it in the notepad and you will find the coordinates there (remeber the format (long, lat,n) the reverse of Google Maps format.
You can also use online tools to format the information or remove parts.
http://www.earthpoint.us/Shapes.aspx
So the idea is to have a map, draw a polygon on it (I assume by placing the vertexes) and then getting the coordinates of the vertexes?
You can make markers draggable when you create then. You can also get the lat/lng position of the markers when certain events fire: the 'dragend' event, for instance.
With these tools, you have the basics of your requirements here. Make a button that places vertexes on the map - just use a marker with custom graphics - and let the user drag the vertex to whatever position they need. Record the new position of the vertex whenever the dragend event fires. Draw lines on the map between the markers, to show to the user the area selected. Have a button to 'complete' the shape, linking the last vertex up with the first vertex.
There may be some existing code to do this, but I am not aware of it. However, it should be possible to throw something together with a bit of work.

How to utilise google maps to replicate functionality similar to rightmoves' draw-a-search?

I know this will be a complex solution. I would appreciate it if you could push me in the right direction.
Please have a look at http://www.rightmove.co.uk/draw-a-search.html. I am interested in finding out how this is possible. what steps do I have to take to achieve this?
There's quite a few things going on here.
You need to have event listeners for when the user clicks on the map.
You need to place markers where they click.
You need to draw two types of polylines; the static type connecting two markers, and the dynamic dotted line as they move the cursor or drag a marker.
When you've closed up the polygon, you need to make your search only return properties inside that shape (although they're actually doing it within X miles radius from that shape).
They're also inserting markers half-way along the lines that you can drag - this will require the geographical library, using the interpolate function.