We have included some JavaScript functions to make it easier to use various funtions of the Google Maps API. Below you can find a description of them.
This function opens the info window of a marker. This function has one parameter: the id of the marker.
This function closes any info window that's visible on the map. This method takes no parameters.
This function opens a infowindow at the specified position with the text in it. It does not need a marker to open one. This method has 3 parameters: the latitude, longitude and the id of the marker.
This function removes a specified marker from the map. It has one parameter: the id of the marker to be removed.
This is not a function, but a class. You can use it to add markers to your page using javascript instead of the traditional <marker /> tag. It's constructor takes 7 parameters: id, name, address, city, country, latitude and longitude. You can then add several other properties to the object. Below is a list of possible properties. When you have set all properties, you can call the function yourDummyMarker.createMarker(). This will put a marker on the map with the specified options.
<ui:define name="content"> <script type="text/javascript"> function doCreateMarker(){ var dmarker = new DummyMarker("marker3", "Office Harelbeke", "Kortrijksesteenweg 307" ,"8530 Harelbeke", "Belgium",50.8430976, 3.2920447); dmarker.infoWindowText = "<b>Office Harelbeke</b><br />" + dmarker.address + "<br />" + dmarker.city; dmarker.searchValue="Office Harelbeke"; dmarker.iconLink="img/RDMarker.png"; dmarker.createMarker(); }; </script> <rd:map mapId="map_canvas" width="700px" height="500px" key="abcdefg" autoCenter="true" showDirections="false" onload="openInfoWindowAt(50.9955609, 3.6847499, 'BAM');"> <rd:marker name="Headquarters Huizingen" id="marker1" address="A. Vaucampslaan 42" city="1654 Huizingen" latitude="50.7520688" longitude="4.2634274" searchValue="Headquarters Huizingen" iconLink="img/RDMarker.png"> <rd:infoWindow for="marker1" text="<b>Headquarters Huizingen</b><br />A. Vaucampslaan 42<br />1654 Huizingen<br />" /> </rd:marker> <rd:marker name="Office Kontich Boudewijnlaan" id="marker2" address="Prins Boudewijnlaan 26" city="2550 Kontich" latitude="51.1410521" longitude="4.4378872" searchValue="Office Kontich Boudewijnlaan" iconLink="img/RDMarker.png"> <rd:infoWindow for="marker2" text="<b>Office Kontich Boudewijnlaan</b><br />Prins Boudewijnlaan 26<br />2550 Kontich<br />" /> </rd:marker> </rd:map> <h:commandButton value="Create a new marker!" onclick="doCreateMarker();" /> </ui:define>
Name | Description | Data type | Standard Value |
infoWindowText | The text to be displayed in this markers info window. | string | |
address | The street and housenumber of the marker. | string | |
city | The (postal code and) name of the city of the marker. | string | |
country | The full name or abbreviation of the country of the marker. | string | |
iconAnchorX | The x-value of the pixel coordinate relative to the top left corner of the icon image at which this icon is anchored to the map. | integer | 9 |
iconAnchorY | The y-value of the pixel coordinate relative to the top left corner of the icon image at which this icon is anchored to the map. | integer | 34 |
iconHeight | the height of the icon’s image | integer | 34 |
iconLink | The url to the icons’ image if a different image is desired. | string | |
iconWidth | The width of the icons’ image | integer | 20 |
id | The unique id of the marker. | string | |
infoShadowAnchorX | The x-value of the pixel coordinate relative to the top left corner of the icon image at which the info window’s shadow is anchored to this icon. | integer | |
infoShadowAnchorY | The y-value of the pixel coordinate relative to the top left corner of the icon image at which the info window’s shadow is anchored to this icon. | integer | |
infoWindowAnchorX | The x-value of the pixel coordinate relative to the top left corner of the icon image at which the info window is anchored to this icon. | integer | 9 |
infoWindowAnchorY | The y-value of the pixel coordinate relative to the top left corner of the icon image at which the info window is anchored to this icon. | integer | 2 |
latitude | If you already have the coordinates for the marker, you can add its latitude. If this is filled in together with longitude, the Google Webservice won’t be called. | decimal | |
longitude | If you already have the coordinates for the marker, you can add its longitude. If this is filled in together with latitude, the Google Webservice won’t be called. | decimal | |
name | Name of this marker, used to display in the search results and in the infowindow of the clusterer | string | |
searchValue | When search is enabled, the search method will look in this value to find suitable markers | string | |
shadowHeight | the height of the shadows’ image | integer | 34 |
shadowLink | The url to an image of the icons’ shadow | string | |
shadowWidth | the width of the shadows’ image | integer | 37 |
clickable | Specify whether or not the user can click on the marker. | boolean | true |
onclick | This event is fired when the marker icon was clicked. | String | |
ondblclick | This event is fired when the marker icon was double-clicked. | String | |
onmousedown | This event is fired when the DOM mousedown event is fired on the marker icon. | String | |
onmouseup | This event is fired when the DOM mouseup event is fired on the marker icon. | String | |
onmouseover | This event is fired when the mouse enters the area of the marker icon. | String | |
onmouseout | This event is fired when the mouse leaves the area of the marker icon. | String | |
oninfowindowopen | This event is fired when the info window of this marker was opened through this marker. | String | |
oninfowindowbeforeclose | This event is fired before the info window of this marker is closed through this marker. | String | |
oninfowindowclose | This event is fired when the info window of this marker is closed through this marker. | String |
This function makes a hidden marker visible. It has one parameter: the id of the marker to show.
This function returns the GPolyline object with the given id.
This function creates a polyline on the map. Note that you need to provide at least 2 GLatLng objects in the array.
The latLngArray-parameter must contain an array of GLatLng objects. For an explanation of the other parameters, please see the API.
<script type="text/javascript"> function doClick(){ var arr = []; arr.push(new GLatLng(50.7520688,4.2634274)); arr.push(new GLatLng(51.1410521,4.4378872)); arr.push(new GLatLng(50.8470177,4.352505)); arr.push(new GLatLng(50.9955609,3.6847499)); arr.push(new GLatLng(50.8430976,3.2920447)); arr.push(new GLatLng(51.019571,5.3599932)); arr.push(new GLatLng(51.1401392,4.4382415)); arr.push(new GLatLng(51.1414364,4.441827)); createPolyline("pl1", arr, "#0000FF", 5, 0.5, true, false, "", "", "", "", "", "", "", "", ""); }; </script> ... <h:commandButton value="Click" onclick="doClick();" />
With this function you can remove a polyline.
With this function you can add new points to an already existing polyline.
With this function you can remove a point from the polyline with id 'polylineId'.
With this function you can make a hidden polyline visible.
With this function you can hide a polyline.
With this function you can enable drawing on an existing polyline. This enables you to add extra lines to the polyline. Drawing can be terminated by double-clicking or click again on the latest point added.
With this function you can edit an existing polyline.
With this function you can make a polyline back uneditable.
This function returns the GPolygon object with the given id.
This function creates a polygon on the map.
The points-parameter must contain an array of GLatLng objects. For an explanation of the other parameters, please see the API.
<script type="text/javascript"> function doClick(){ var points = []; points.push(new GLatLng(50.943704737090826, 2.84820556640625)); points.push(new GLatLng(50.8059202661327, 3.044586181640625)); points.push(new GLatLng(50.73296396507139, 2.931976318359375)); points.push(new GLatLng(50.728617739899384, 2.72186279296875)); points.push(new GLatLng(50.806788108266225, 2.638092041015625)); points.push(new GLatLng(50.91167804783163, 2.673797607421875)); createPolygon("pol", points); }; </script> ... <h:commandButton value="Click" onclick="doClick();" />
With this function you can remove a polygon.
With this function you can add new points to an already existing polygon.
With this function you can remove a point from the polygon with id 'polygonId'.
With this function you can make a hidden polygon visible.
With this function you can hide a polygon.
With this function you can edit an existing polygon.