Cette fonction vous permet d'ajouter des rectangles sur une carte Google Maps.
addRectangle
- Paramètres spécifiques : aucun
- Nom de stockage : rectangle
- Résultat du Callback : google.maps.Rectangle
Cet exemple ajoute 3 rectangles sur la carte et montre 3 façons différentes pour en définir les contours.
$('#maCarte').gmap3(
{
action: 'addRectangle',
rectangle:{
options:{
bounds: {n:40.780, e:-73.932, s:40.742, w:-73.967},
fillColor : "#FFAF9F",
strokeColor : "#FF512F",
clickable:true
}
},
map:{
center: true,
zoom:12
}
},
{
action: 'addRectangle',
options:{
bounds: [40.775, -73.937, 40.747, -73.962],
fillColor : "#F4AFFF",
strokeColor : "#CB53DF",
clickable:true
}
},
{
action: 'addRectangle',
bounds: {ne:[40.770436, -73.942185], sw:[40.752828, -73.957377]},
radius : 750,
fillColor : "#008BB2",
strokeColor : "#005BB7"
}
);
Carte avec addRectangle
Code complet avec addRectangle
<!DOCTYPE html>
<html lang="fr">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta charset="UTF-8"/>
<title>Votre titre de page</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#maCarte{
height: 350px;
width: 100%;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://www.votredomaine.fr/js/gmap3.js"></script>
<script type="text/javascript">
$(function(){
$('#maCarte').gmap3(
{
action: 'addRectangle',
rectangle:{
options:{
bounds: {n:40.780, e:-73.932, s:40.742, w:-73.967},
fillColor : "#FFAF9F",
strokeColor : "#FF512F",
clickable:true
}
},
map:{
center: true,
zoom:12
}
},
{
action: 'addRectangle',
options:{
bounds: [40.775, -73.937, 40.747, -73.962],
fillColor : "#F4AFFF",
strokeColor : "#CB53DF",
clickable:true
}
},
{
action: 'addRectangle',
bounds: {ne:[40.770436, -73.942185], sw:[40.752828, -73.957377]},
radius : 750,
fillColor : "#008BB2",
strokeColor : "#005BB7"
}
);
});
</script>
</head>
<body>
<div id="maCarte"></div>
</body>
</html>
