gmapmultiplot Plots multiple points on a embedded Google Map

  1. Documentation
  2. Change Log

GMapMultiplot gained inspiration from the Yii Gmap extension written by Konstantin Mirin. I rewrote the extension to plot multiple locations and upgraded the Javascript file to GMap API v3.

How it works:

  • Accepts an array of ActiveRecord Objects
  • Loops through the array, feeding the address and window data to gmapmultiplot.js
  • gmapmultiplot.js takes the address and sends it to maps.google.com, which returns a geocoded Latitude and Longitude
  • Mapmarker is created with the Lat/Lng and a window(bubble) is created with name, address and phone number
  • For multiple address, the map zooms out and centers so that all MapMarkers are visible.

While the class expects certain attributes, this can easily be edited to fit your needs.

You can view the extension in action by viewing a business profile on Rebates Hampton Roads

Documentation

Requirements
  • Yii 1.1 or above (only tested in 1.1)
Installation
  • Extract the release file under protected/extensions

This extension was originally written to plot a businesses 1 or more locations, but can be easily modified for different scenarios.

If you run into any problems, please feel free to send me an email and I will correct any errors asap. You can find my email address within the class comments.

Usage

See the following code example:

$this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array(
       'id' => 'gmap',//id of the <div> container created
       'label' => $label, //Title for bubble. Used if you are plotting multiple locations of same business
       'address' =>  $array, //Array of AR objects
  ));

If passing the extension a single record, simply wrap the record in an array. This prevents an error while the extension attempts to loop through the records:

$this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array(
       'id' => 'gmap',//id of the <div> container created
       'label' => $label, //Title for bubble. Used if you are plotting multiple locations of same business
       'address' =>  array($array), //Array of AR objects
  ));

For more code examples, please visit the following link Code Sample on Pastebin.com

Change Log

September 29, 2010
  • Initial release.
    October 3, 2010
  • Fixed issue with address format being sent to Google Maps. Map would come up blank if attribute "address2" was left empty.
2 0
3 followers
707 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Tags:
Developed by: jvickers
Created on: Sep 30, 2010
Last updated: 7 years ago

Downloads

show all