Google Maps Creating two markers and a line between them - google-maps

I am wondering how I can create two markers on a google map (upon click) and have a line drawn between them. Ideally both markers would be draggable after they are initially dropped and the line would readjust accordingly.

Maybe you can check this example, though is already deprecated it might help you to get an idea
http://maps.forum.nu/gm_flight_path.html

Related

Google Maps v3 block map interaction

I am trying to make a Polyline editor, just like the one from Google Drawings Library. (for specific reasons, i can't use that one)
It works on the same principle. Start with a point, then for each click add new points and make the polyline.
On the editor from Google Drawings Library, while you are editing a polyline, you're mouse can't interact with other items from the map.
Inspecting with firebug, i see that they have an overlay of 20000000 z-index inside the map.
Is there any way of creating the same overlay for my map using default Google Maps functions?
It's a custom overlay inside the overlayMouseTarget-pane with the same size as the map and a draw-method that updates the position of the overlay. You may do the same.

Custom layer/overlay in google maps

Is it possible to create custom layers/overlays in google maps?
As an example, would it be possible to have one layer with polygons, another with circles, and a third with markers? and then hide/show these layers individually?
I tried looking at the documentation, but the layers seems to only be a fixed set of predefined layers. And overlays seems to only support image overlays.
Any help on this is appreciated.
I'm not sure if there exists a better way to do this, but I've found a workaround to a similar problem. My example utilizes markers and polylines, but it should be easy to extend the functionality to circles and polygons too.
Link to JSFiddle
Basically it works like this:
Initialize the map.
User selects an option what he would like to see on the map.
Click triggers a method (see HTML part of the fiddle) in the map object that first clears the map and then pushes new overlays on map.
The data that is currently shown on map is stored in arrays, and the map clearing method simply goes through these arrays and checks if there exists any content on map, and removes them if does.
Hope this helps. Cheers!

Google map API v3 markers overlapping

I am making an application with google maps.
When markers are overlapping only the last one is displayed even if the icons are different..
I do not want it to cluster in that case, rather it should show both maybe by changing the coordinates just a but??
Any solutions??
I think this is a pretty elegant solution, called Spiderfying the markers.
https://github.com/jawj/OverlappingMarkerSpiderfier
I'm thinking of using it.
What I do now is use JavaScript to make a fancy popup that hides and shows divs on one marker location (created problematically in PHP, but you could do it on JS too). It has the side benefit of allowing less markers on the map.
Click a black numbered marker on this map to see it in action.
http://www.yourmapper.com/map/111/crime-reports/crime-in-metro-louisville-ky-since-jan-2003.htm
Another option is to use Google Maps API 3 Utility Library, it has a Marker Clusterer.

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.

Google maps markers are hidden behind each other

I have a problem with markers hidden behind other markers.
The problem occurs when the addresses are too close to each other. e.g. street 20, street 22.
Changing zIndex will not help, because that is just "stacking".
How can I "float" the markers so that they are all visible on the map?
I recommend you look into marker clustering.
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/examples/advanced_example.html
UPDATE:
Google now support marker cluserting via a native library: https://developers.google.com/maps/documentation/javascript/marker-clustering
is this any use to you - it's called 'Spiderfier':
http://blog.mackerron.com/2011/06/22/overlapping-marker-spiderfier/
https://github.com/jawj/OverlappingMarkerSpiderfier
It might help to use smaller markers. When I had this problem, I changed the size of my marker images from 20x34 px down to 20x20 px.
So,you can use mysql spatial extensions and MBRContains(RectangleAroundYourPoint,GeometryColumnOfYourTable)
-if of course your table have a geometry column which is easy(upon creation you choose i.e. point as the column type,and when performing an insertion you have to do it with GeomFromText)-
to check if another place exist within that rectangle and if it is move the newcoming place until the mbrcontains return false or something like that.
Hope it helps
I use marker clusterer and had the same problem. I add a small random number to coordinates. I do not want to change the locations of markers so much therefore in satellite mode problem still exists but in map mode we can zoom much more.
This may not be a good solution but good enough for my application.