1. Home
  2. >
  3. News
  4. >
  5. Overview of the version 5
01 11/12

Overview of the version 5

One of the main goal of this new version was to get a code more intuitive to write.

We will present the changes in this new version with some examples.

Consult the documentation for more information.

Request object

A request block can now handle many method call instead of having many differents request.

The API method requested is now the key of the block options associated instead of using the "action" one:

{
    action: "addMarker",
    address: "place de l'étoile, Paris",
    ...
},
{
    action: 'addRectangle',
    ...
}

Becomes :

{
    marker: {
        address: "place de l'étoile, Paris",
        ...
    },
    rectangle: {
      ...
    }
}

Google parameters

All Google API parameters are stored into "options" key.

Example: GroundOverlay : GroundOverlay(url:string, bounds:LatLngBounds, opts?:GroundOverlayOptions)

The groundoverlay gmap3 options takes 3 parameters: url {string} Url of the picture to display bounds {Google.maps.LatLngBounds} opts {Google.maps.GroundOverlayOptions}

Note: if Google API takes only 1 parameter, "options" is this one. LatLng / LatLngBounds are automatically cast into Google LatLng / LatLngBounds objects.

Multiples use

The key "values" makes the current request on each included values.
Each call use a merged between the current item in values and the request values

Example:

$("#test").gmap3({
  map:{
    options:{
      center:[46.578498,2.457275],
      zoom: 5
    }
  },
  marker:{
    values:[
      {latLng:[48.8620722, 2.352047], data:"Paris !"},
      {address:"86000 Poitiers, France", data:"Poitiers : great city !"},
      {address:"66000 Perpignan, France", data:"Perpignan ! GO USAP !", 
options:{icon: "http://maps.google.com/mapfiles/marker_green.png"}}
    ],
    options:{
      draggable: false
    }
  }
});

3 markers will be added thanks to a merged between each item into "values" and the globals options / events...

Tags

changelog
 
Close