How to handle several infowindows? - google-maps-api-3

Each time the mouse is moving over a marker I display an infowindow:
var optionMarker = {position:point, map:map,icon:image,shadow:ombre};
var marker = new g.Marker(optionMarker);
var infowindow = new g.InfoWindow({content: texte});
g.event.addListener(marker, 'mouseover', function()
{
infowindow.open(map,marker);
});
If I click several markers, then I have several opened infowindows.
These infowindows are superposed.
Which could be the better way to move from a infowindow to another infowindow ?
- by clicking the selected infowindow ?

The InfoWindows don't seem to have any events associated with them (click, mouseover, etc) so the next best thing, I think, is to manipulate the markers. I set up the markers so that when the mouse is over them, the linked InfoWindow rises to the top.
http://jsfiddle.net/XCCSL/

Related

Get DOM Reference of a SAPUI5 View/Control

I want show the info window for google maps. But the data or view is a ui5 view as below,
var oView = sap.ui.view({
type : sap.ui.core.mvc.ViewType.XML,
viewName :"com.example.view.ListView"
});
And this view is perfect.
Mainly I have the google info window and I need to place this inside that info window as follows,
var infowindow = new google.maps.InfoWindow({
content: view, //Here I am getting below error
position: coordinate
});
infowindow.open(map);
So i am getting
InvalidValueError: setContent: not a string; and Element-
In this I know I can place a domNode or string inside the google info window's content. So I need to know how can we convert this ui5 view to domNode or any other solution.
You can get the DOM Node of a SAPUI5 View or Control by using the method getDomRef
var infowindow = new google.maps.InfoWindow({
content: view.getDomRef(),
position : coordinate
});
infowindow.open(map);
Please be aware that a SAPUI5 View/Control only has a DOM Reference after it was first rendered. Furthermore after a potential rerendering you might have to re-apply the above code.
BR Chris

Auto display info windows on markers from directionsRenderer

The directionsRenderer creates a marker at the origin and end destination. Right now i have to click a marker to display the info window. How do i automatically display the info window? The process of creating the 2 markers is abstracted into the directionsRenderer so i'm not sure how to find the 2 markers.
1) Use the suppressMarkers parameter of the directionsRenderer
directionsDisplay = new google.maps.DirectionsRenderer({
suppressMarkers: true
});
2) Add your own markers on the start (and/or end) point(s)
JSFiddle demo
3) Call the open() method of the infoWindow to force it open
https://developers.google.com/maps/documentation/javascript/reference?#InfoWindow
Hope this helps.

Onclick on Google map marker but not when panning the map

I'm using something like this (javascript):
google.maps.event.addDomListener(new_marker, 'click', function(e) {
alert("hi");
});
But I don't want it to trigger when the user moves the map, and they just happened to do so while clicking on the marker. To be clear: I only want the code to run when the user clicked on the marker, without moving the map. How can I do that?

Google maps InfoWindow closing

I'm adding some info windows on my map with clicking button:
$(document).ready(function() {
$("input:#ekle").click(function(){//balon ekle ve listeye ekle
infoWindow3 = new google.maps.InfoWindow();
var en=$("input:#x").val();
var boy=$("input:#y").val();
var yazi=$("input:isim2").val();
var windowLatLng3 = new google.maps.LatLng(en,boy);
infoWindow3.setOptions({
content: yazi,
position: windowLatLng3,
});
infoWindow3.open(map);
ekle(yazi);//adding Infowindow contecnt(value) to listbox
});
So I can creating InfoWindows.Now I will closing my InfoWindow with clicking an other button :
function cikar(){//listeden cikarma
var cikarilacak=$('#liste option:selected').val();//looking listbox selected item value
$("#liste option[value='"+cikarilacak+"']").remove();
//at this step I will close my InfoWındow where I selected it's value from listbox
}
I will close InfoWindow which I selected it's value from listbox.what can I do
pass the infoWindow-instance as argument to the function that creates the option.
When you create the option, store the reference to the infoWindow with the option(you e.g. may use $.data()).
It's easy then to retrieve the reference to the infoWindow in cikar() and to close the infoWindow.

Marker drop event in google maps?

I need to trigger an event when the user drops a marker on the map. I have the code working for them to drop the marker, but I can't figure out how to trigger the event.
Any tips?
With Marker event dragend you have the latlng where the Marker is drop. This is that you need?
google.maps.event.addListener(Marker, "dragend", function(event) {
var lat = event.latLng.lat();
var lng = event.latLng.lng();
});

Resources