Controlling GDirections mini-popup-maps - google-maps

I am using the Google Maps API to code a campus map for my university. On the main map, when it is being viewed in the "Map" maptype, there is a custom overlay of the campus, which is set (by using GEvent.addDomListener) to be removed when the map is viewed in Satellite or Hybrid mode. When the user gets directions, through my map, to and from the campus, a polyline and 2 markers show up, like normal. When the marker is clicked, a small popup map is display, focused on the area of campus around that particular marker.
I was wondering if anyone knew of a way to set attributes of these mini-popup-maps. I need to extend the event listener to make sure that the overlay gets taken off when the mini map is clicked out of "Map" mode. I also need to be able to set the zoom level for these maps.
Any ideas?
(code can be provided as needed, wasn't really sure what parts would be needed and didn't want to post the whole f'n thing up here.)

Doesn't look like there are any built in options to modify the infoWindow you get from the GDirection markers, but you can explicitly replace the markers once you get them back.
This post describes the process.

Related

Google map URL to link to satellite map with a marker and respect zoom

I am trying to create a URL that will render google maps with:
satellite map
a marker (pin)
a specified zoom level
I feel like I'm going a little crazy!?
This one is close, it is a satellite map, and has a marker, but does not respect the zoom parameter: http://maps.google.com/maps?&z=18&mrt=yp&t=k&q=40.7028722+-73.9868281
This one is close too, it has a marker and respects the zoom level, but it's not a satellite map: https://www.google.com/maps/place/40.7028722+-73.9868281/#40.7028722,-73.9868281,11z
You can tell it to use the satellite image by adding t=k
http://maps.google.com/maps?t=k&q=loc:37.9531784+-122.3383102
I you want the regular map, use t=m
I get a marker and satellite image with this approach.
Take a closer look at the URLs, the second link you posted sounds like it is almost exactly what you want but it lacks the satellite view. When I went to that link I was able to enable satellite view from the bottom left button on the map. When I did that, the URL updates to...
https://www.google.com/maps/place/40%C2%B042'10.3%22N+73%C2%B059'12.6%22W/#40.7028722,-73.9868281,56377m/data=!3m1!1e3!4m5!3m4!1s0x0:0x0!8m2!3d40.7028722!4d-73.9868281
Compare that to the original URL...
https://www.google.com/maps/place/40%C2%B042'10.3%22N+73%C2%B059'12.6%22W/#40.7028722,-73.9868281,11z/data=!4m5!3m4!1s0x0:0x0!8m2!3d40.7028722!4d-73.9868281
The original URL has a parameter specifying what looks like zulu time, in this case 11z. The satellite map that you are wanting switches that parameter out with what appears to be a zoom level specified in meters.
This is as close as I got:
http://maps.google.com/maps?t=k&q=loc:-34.887091,-56.054322&ll=-34.887091,-56.054322
It works fine most of the times, but in some mobile devices the pin does not appear in the centre of the screen.
Got some info from this site: https://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
https://www.google.com/maps/#?api=1&map_action=map&basemap=satellite
is the way to do the URL.
Full google maps URL documentation here:
https://developers.google.com/maps/documentation/urls/get-started

How to hide points of interest in google maps and detect clicked coords

First, I have been reviewing some of the different Google Maps API docs, but I've never done much coding with it. I'm trying to build a simple game for kids in which, if the user clicks on a map within a certain distance of a key map point (could be within 1 mile, 100 yards, 5 miles...depending on situation), then the map point becomes visible and a custom message is displayed with it.
Which google maps api calls would enable this to work? How would I embed a hidden point on the map? With the map being rendered on the client, for security, if I could detect the point clicked and send that point via ajax to the server, then the server could send back whether there is a hidden point at that location, that seems like it could work. Or maybe there's a better way.
Can someone point me in the right direction, as to which API calls, and maybe code samples if possible? To summarize, I'm looking for the following functionality:
Track the lat/long coords of any user-clicked point on a google map. Have that click send the coords to my javascript function.
Have hidden points on the map that the user can't see, but either Maps (or at least just my server via ajax) can be aware of.
Ability to display a custom message right next to the clicked spot or hidden point, when needed.
Thanks!
When I understand correctly what you are trying to achieve it's much easier.
Draw a circle and hide the circle by setting the strokeWeight and fillOpacity to 0 . As radius use the allowed distance, as center the LatLng of the point
Although the circle now is not visible, the API will still respond to click-events on the circle, you only have to set a click-listener for the circle and create e.g. a marker at the center of the circle.
Note: a clickable circle will have a different cursor, you must set a unique cursor for the complete map, otherwise the users will be able to find the circle by hovering the map.
Demo: http://jsfiddle.net/doktormolle/0secbwuf/

How to add a business/"default" location marker and infoWindow to Google Maps (v3)

Is is possible to add a business location marker WITH IT'S "DEFAULT" INFOWINDOW bubble like the ones in maps.google.com?
I'm making a contact page for a a company, where I have the GMaps element with a location and a marker, naturally.
Example:
Go to maps.google.com and search for "Colosseum" (for example, any "known" location/business will do). When you click the Colosseum marker, you get an infoWindow that has the business/sight/whatever info in the window (screenshot: https://dl.dropbox.com/u/1122582/colosseum.jpg)
What I want to see, is:
When I click the marker on my map on my webpage, it will open the same style (or atleast very similar) infoWindow as in the example (this means logo, address, direction links etc. whatever it has). InfoWindow being provided by the API options, and not handmade by me.
In pseudocode, I would imagine seeing it like this:
myMarker.onClick({
position: myBusinessLocation,
useDefaultInfoWindow: true
map: myMap
});
Worth noting that since coordinates are actually just coordinates and named locations, I would need to make the API understand the Marker points to a business, and not just a point in the map.
Requirements
Client-side API usage
WITHOUT the use of Google's IFRAME embedding
WITHOUT making a custom infoWindow that just looks like the one in the example. The whole point is that I would use the "default" infoWindow (if GMaps API even provides one)
There is no built-in method to create such an infoWindow with the desired content automatically.
That's the nature of an API, it has to offer the ability to create an application, but must not create an application automatically.
You have to create the infoWindow on your own by using e.g. the implemented infoWindow-object.
The contents of the infoWindow you also must collect on your own, you may retrieve the details for a place by using a Place-Details-Request

How can I have a smooth animated move between 2 Google Maps locations?

When clicking from one marker to another in Google Maps, the map screen animates the move smoothly if both markers are within them initial map view but jumps if one of the markers is off screen.
I'm trying to set up a map which has several locations within the main map area but has one which is 'off screen'. I have a signpost icon to the more distant location within the initial map area which I want to smoothly scroll to the off screen location when clicked (so as to give a better sense of it's relative location). I can't find anything in the Maps API which would let me do this however.
I could zoom out, move and then zoom in again but this looks a bit jarring. Am I missing something in the API, or does anyone have any suggestions?
Unfortunately, I don't think this is possible (without a change from Google). From the v3 API reference for panTo:
Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.
which implies that if that change is not less than the dimensions of the map, the transition won't be smoothly animated. The other pan methods are similar.
You could try moving in multiple steps but that's a bit of a hack and I suspect the result will be poor.
Sorry that's not very helpful (I have the same problem).
For me this method works, but i'm using Google Maps API v2.
LatLng latLng = new LatLng(lat,lng);
map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, ZOOM_FACTOR));
This animates the camera from current position to the new one.
If you are using Gmaps API V2, then you can implement smooth animated move very easily by using panBy() method. You have to use fromLatLngToContainerPixel() method to find the amount of pixels to pan by.
Here is the bit of code:
var newLoc = map.fromLatLngToContainerPixel(new GLatLng(lat, lng));
map.panBy(new GSize( newLoc.x, newLoc.y ));
However, what I am trying to do is to achieve the same thing in maps API V3, but sadly fromLatLngToContainerPixel() method does not work anymore the way it did :(

Clickable markers on GTileLayerOverlay

I have a web application that needs to display 30,000 markers on a map at the same time. I don't want to use any kind of clustering. I need them to all be displayed.
I also need them to be clickable. The user can click on each point and a popup will come up with information about that point. Even at a low zoom level when there are thousands of markers in a single 256x256 square, the user needs to be able to click on them. It may be cumbersome for the user to click on a point thats bunched up with hundreds of other points, but if there happens to be one marker in the middle of nowhere, I want the user to be able to click on it right there instead of having to zoom in.
How do I do this? I know it's possible because I watched a video on google video where this guy creates a GTileLayerOverlay app that had clickable markers. He didn't explain how it was done though.
Is my only option to just remove the GTileLayerOverlay at high zoom levels and replace it with a true GMarker layer? I really don't want to do that. It seems over engineering to me.
If you were me, how would you go about this?
I found this example is in the Google Maps API Demo Gallery:
Clickable Tile Layer
This example creates a custom map type (GMapType) that shows regional borders and squares for county centers. When the squares are clicked, an info window opens with information about that county. The clickability is accomplished by passing in information about clickable pixel bounds in the cookies attached to the tiles, and doing a client-side check on mouseover for whether the mouse position was within the pixel bounds.
Here's some commentary on his method.
I don't have any experience with GTileLayOverlays, but I believe it is possible to accomplish what you're trying to do without using GMarkers.
Would it be possible to utilize clustering if each cluster could bring up a list of the markers it represents? It seems like having 30,000 markers visible at once would be visually confusing and difficult to navigate .