www.webdeveloper.com
Results 1 to 10 of 10

Thread: Can a Google maps infoWindow be on right or left side a marker?

  1. #1
    Join Date
    Feb 2011
    Posts
    81

    Can a Google maps infoWindow be on right or left side a marker?

    A Google maps infoWindow is shown above of its marker in default. Can it be on the right or left side of its binding marker? If yes, how? If not, how Google is so ...?

    Thanks,

  2. #2
    Join Date
    Feb 2011
    Posts
    81
    Only one place for Google maps infoWindow? Unbelievable!

  3. #3
    Join Date
    Nov 2010
    Posts
    1,085
    Have you looked at the documentation? I believe this is covered there.

  4. #4
    Join Date
    Feb 2011
    Posts
    81
    Quote Originally Posted by xelawho View Post
    Have you looked at the documentation? I believe this is covered there.
    Below is from Google Maps API "https://developers.google.com/maps/documentation/javascript/reference#InfoWindowOptions"

    google.maps.InfoWindowOptions object specification
    Properties
    Properties Type Description
    content string|Node Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.
    disableAutoPan boolean Disable auto-pan on open. By default, the info window will pan the map so that it is fully visible when it opens.
    maxWidth number Maximum width of the infowindow, regardless of content's width. This value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open.
    pixelOffset Size The offset, in pixels, of the tip of the info window from the point on the map at whose geographical coordinates the info window is anchored. If an InfoWindow is opened with an anchor, the pixelOffset will be calculated from the anchor's anchorPoint property.
    position LatLng|LatLngLiteral The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.
    zIndex number All InfoWindows are displayed on the map in order of their zIndex, with higher values displaying in front of InfoWindows with lower values. By default, InfoWindows are displayed according to their latitude, with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. InfoWindows are always displayed in front of markers.

    Do you see which one related to which side for you to put the infoWindow? pixelOffset? Surely not content / disableAutoPan / maxWidth / position / zIndex . If it's pixelOffset, how?

    Thank,

  5. #5
    Join Date
    Nov 2010
    Posts
    1,085
    yes, pixelOffset is a property of the infowindow that accepts a google.maps.Size as a value. So for example:

    Code:
      var infowindow = new google.maps.InfoWindow({
          content: "hello world",
    	  pixelOffset: new google.maps.Size(100,100)
      });
    play around with 100,100 as you see fit

  6. #6
    Join Date
    Feb 2011
    Posts
    81
    Thanks, xelawho, indeed it's pixelOffset which can be used to change the infoWindow place against its anchor. But unfortunately, the tip of the infoWindow doesn't change accordingly to the pixelOffset. The tip always points down from the middle of the bottom of the infoWindow. Not like Bing maps, which can point to the anchor nicely and correctly from left up, left middle, or left down, right up, right one quarter up....

    Can you tell how Google maps does this: when pixelOffset is used, the infoWindow tip is kept point to its anchor nicely?

    Thanks,
    Last edited by wow; 08-18-2014 at 08:42 PM.

  7. #7
    Join Date
    Nov 2010
    Posts
    1,085
    Ah, you want to move the tip. I don't think I've seen google maps do that. Which makes me guess that the g maps infowindow shape is a default rendering. If you wanted to move the tip around you would probably have to make your own. There are plenty of libraries out there for custom infowindows for google maps. Maybe try one of those?

  8. #8
    Join Date
    Feb 2011
    Posts
    81
    This is certainly a limit of google maps. Google surely should enhance its infoWindow by automatically placing infoWindow at the best fit place when pixelOffset is absent from InfoWindowOptions, and adjusting its tip nicely pointing to its binding marker, and also allowing loading its content from a file through AJAX call. From Google's point of view, it has done a wonderful job to provide an excellent google maps service, this is not that hard to implement, but this will be greatly simpler for developers to code google infoWindow and save a lot of network traffic too than developers coding by themselves these features.

    Colud you list some of these libraries which implement these features? gmap3 is possibly one. But I may be wrong. I haven't found how it enhance the infoWindow.

    Thanks for your great help
    Last edited by wow; 08-19-2014 at 08:54 PM.

  9. #9
    Join Date
    Nov 2010
    Posts
    1,085
    You can certainly load info window content via Ajax, although the repeated Ajax calls may make the performance sluggish, depending on connection, etc. what have you tried that makes you think you can't? as to the info window placement, generally a marker is shown at map center, making your idea a corner case at best. you can Google for custom info windows - I know there are quite a few, but don't know which best suits your requirements

  10. #10
    Join Date
    Feb 2011
    Posts
    81
    Unfortunately the best map application I have seen is not done in google maps, even I like it more. I don't think moving user's viewport unauthorized by user is a good practice for any real serious commercial site. Like the best maps app site, it needs marking more than ten thousand markers in the viewport at a time and it handles them all nicely and beautifully. I don't know how google maps can do the same. For my opinion, in order for google maps up to the speed, at least two need enhancing - marker cluster and infoWindow:
    1. Enhance marker cluster like MarkerCluster and support click event on the cluster like its normal marker which opens an infoWindow, not zoom in map, the one provided by MarkerCluster
    2. Enhance infoWindow placing automatically and nicely, like I said above, and including scrollbars when content is too much for it.

    Thanks,
    Last edited by wow; 08-23-2014 at 11:54 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles