Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you make Mapper::image-overlay to add images to the map #69

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
991c8b3
Updated support for Laravel 5.
Jun 12, 2015
9c3fefb
Updated support for Laravel 5.
Jun 12, 2015
f88c31b
Merge branch 'develop'
Jun 16, 2015
4434fec
Updated support for Laravel 5.
Jun 12, 2015
97c6631
Merge branch 'develop'
Jun 16, 2015
84d9e6d
Updated support for Laravel 5.
Jun 12, 2015
b67cf58
Merge branch 'develop'
Jun 17, 2015
2505ea7
Intergrated marker clusters.
Jun 22, 2015
ba82249
Merge branch 'develop'
Jun 23, 2015
6c0f518
Use environment variable for Google api key instead of setting it in …
michellaurent Jun 23, 2015
784333e
Update README.md
michellaurent Jun 23, 2015
5610338
Change the class name to be as same as file name
syahzul Jun 28, 2015
c6eec38
Change the alias to be as same as file and class name
syahzul Jun 28, 2015
b7342ca
Merge pull request #3 from EquiPC/master
bradcornford Jul 6, 2015
05754e2
Adding an accessible maps variable for JS manipulation.
Jul 13, 2015
9ff77e6
Merge pull request #4 from syahzul/master
bradcornford Jul 14, 2015
25aa8fe
Fixing a bug where rendering multiple maps would cause an error. Fixi…
Aug 14, 2015
7d0ee84
Fixed marker icons
vjoao Nov 3, 2015
027a7b1
Merge pull request #14 from VicMota/master
bradcornford Nov 3, 2015
b38c386
Exposed markers for each map
vjoao Nov 3, 2015
5b5d1db
Merge pull request #15 from VicMota/master
bradcornford Nov 4, 2015
ee6f343
Exposed markers for each map
vjoao Nov 3, 2015
3cb6d1d
Fixed informationWindow
vjoao Nov 6, 2015
90bb508
Merge pull request #17 from VicMota/master
bradcornford Nov 9, 2015
0617c06
Fixed informationWindow
vjoao Nov 6, 2015
ac856db
Adding a scrollWheelZoom parameter to both the configuration file, an…
Nov 17, 2015
36f4f0e
Merge branch 'develop'
Dec 16, 2015
aa4aa36
Add option for draggable markers
Jan 2, 2016
a7a5488
fix
Jan 2, 2016
9a4f238
Update readme for draggable markers!
Jan 4, 2016
fe7eb23
Merge pull request #25 from eskrano/master
bradcornford Jan 5, 2016
fa09b49
Add option for draggable markers. Update readme for draggable markers.
Jan 2, 2016
af4bc42
Merge branch 'master' into develop
Jan 6, 2016
6852865
Added new mapper method location which takes a search term for a loca…
Nov 18, 2015
cd114b2
Added new mapper method location which takes a search term for a loca…
Nov 18, 2015
11b270d
Added drag events.
Jan 11, 2016
7fbea25
Added drag events.
Jan 11, 2016
38c33aa
Adding support for publishable views.
Jan 11, 2016
3b9ed04
Adding support for publishable views.
Jan 11, 2016
398ef72
Merge branch 'master' into develop
Jan 15, 2016
0f457d3
Added before and after load events for maps.
Jan 15, 2016
d821a1f
Added before and after load events for maps.
Jan 15, 2016
3cb4a87
Adding example file.
May 26, 2016
8964819
Adding settings for marker clusters.
Jun 7, 2016
69acc73
Merge branch 'develop'
Jun 14, 2016
66efa59
Adding illuminate package dependencies in composer.json.
Jun 14, 2016
0b69c5c
Merge branch 'develop'
Jun 14, 2016
9143291
Fixing issue with map not resizing to fit all markers when option cen…
Jul 11, 2016
3d35782
Merge branch 'develop'
Jul 11, 2016
abd5e74
Updating markers to json_encode both title and content.
Jul 14, 2016
baf9daa
Merge branch 'develop'
Jul 14, 2016
d5c06d3
Adding an option 'locate' to locate the users current position, and s…
Jul 25, 2016
f0bca50
Merge branch 'develop'
Jul 26, 2016
876e3b1
Fixing PHPSpec test for location searching.
Jul 26, 2016
df7bce8
Merge branch 'develop'
Jul 26, 2016
dba4395
Removing duplicate map events.
Jul 26, 2016
e327a7c
Adding an array of the maps current shapes into a maps.shapes array.
Jul 27, 2016
4f5a17a
Merge branch 'develop'
Jul 27, 2016
11c7b0d
Adding option 'fullscreenControl' to allow toggiling control of the f…
Aug 18, 2016
ce4d16f
Merge branch 'develop'
Aug 18, 2016
80da597
Adding option 'fullscreenControl' to allow toggiling control of the f…
Aug 18, 2016
6377ed6
Merge branch 'develop'
Aug 18, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 110 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
[![Build Status](https://travis-ci.org/bradcornford/Googlmapper.svg?branch=master)](https://travis-ci.org/bradcornford/Googlmapper)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bradcornford/Googlmapper/?branch=master)

Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, providing a variety of helpers to speed up the utilisation of mapping. These include:
### For Laravel 4.x, check [version 1.0.1](https://github.com/bradcornford/Googlmapper/tree/v1.0.1)

Think of Googlmapper as an easy way to integrate Google Maps with Laravel, providing a variety of helpers to speed up the utilisation of mapping. These include:

- `Mapper::map`
- `Mapper::location`
- `Mapper::stretview`
- `Mapper::marker`
- `Mapper::informationWindow`
Expand All @@ -22,7 +25,7 @@ Think of Googlmapper as an easy way to integrate Google Maps with Laravel 4, pro
Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlmapper`.

"require": {
"cornford/googlmapper": "1.*"
"cornford/googlmapper": "2.*"
}

Next, update Composer from the Terminal:
Expand All @@ -35,11 +38,13 @@ Once this operation completes, the next step is to add the service provider. Ope

The next step is to introduce the facade. Open `app/config/app.php`, and add a new item to the aliases array.

'Mapper' => 'Cornford\Googlmapper\Facades\Mapper',
'Mapper' => 'Cornford\Googlmapper\Facades\MapperFacade',

Finally we need to introduce the configuration files into your application.

Finally we need to introduce the configuration files into your application/
php artisan vendor:publish --provider="Cornford\\Googlmapper\\MapperServiceProvider"

php artisan config:publish cornford/googlmapper
You also need to set your Google API Key into the `GOOGLE_API_KEY` environment variable. To obtain an API key for your project, visit the [Google developers console](https://console.developers.google.com/).

That's it! You're all set to go.

Expand All @@ -54,11 +59,20 @@ You can now configure Googlmapper in a few simple steps. Open `app/config/packag
- `user` - Use custom Google Maps for users logged into the Google service, e.g. false.
- `marker` - Automatically add Google Maps marker for your maps initial location, e.g. true.
- `center` - Automatically center Google Maps around the initial location, when false, Google Maps will automatically center the map, e.g. true.
- `locate` - Automatically center Google Maps around the users current location, when false, Google Maps will automatically center the map, e.g. true.
- `zoom` - Set the default zoom level for Google Maps, e.g. 8.
- `scrollWheelZoom` - Set the default scroll wheel zoom Google Maps, e.g. true.
- `fullscreenControl` - Set the default fullscreen control for Google Maps, e.g. true.
- `type` - Set the default map type for Google Maps, e.g. ROADMAP, SATELLITE, HYBRID, TERRAIN.
- `ui` - Show the Google Maps default UI options, e.g. true.
- `markers.icon` - Set the default marker icon, e.g. img/icon.png.
- `markers.animation` - Set the default marker animation, e.g. NONE, DROP, BOUNCE.
- `cluster` - Set if map marker clusters should be used.
- `clusters.icon` - Display custom images for clusters using icon path.
- `clusters.grid` - The grid size of a cluster in pixels.
- `clusters.zoom` - The maximum zoom level that a marker can be part of a cluster.
- `clusters.center` - Whether the center of each cluster should be the average of all markers in the cluster.
- `clusters.size` - The minimum number of markers to be in a cluster before the markers are hidden and a count is shown.

## Usage

Expand All @@ -69,6 +83,7 @@ It's really as simple as using the Mapper class in any Controller / Model / File
This will give you access to

- [Map](#map)
- [Location](#location)
- [Streetview](#streetview)
- [Marker](#marker)
- [Information Window](#information-window)
Expand All @@ -84,14 +99,38 @@ The `map` method allows a map to be created, with latitude, longitude and option

Mapper::map(53.381128999999990000, -1.470085000000040000);
Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 15, 'center' => false, 'marker' => false, 'type' => 'HYBRID', 'overlay' => 'TRAFFIC']);
Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 10, 'markers' => ['title' => 'My Location', 'Animation' => 'DROP']]);
Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 10, 'markers' => ['title' => 'My Location', 'animation' => 'DROP']]);
Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 10, 'markers' => ['title' => 'My Location', 'animation' => 'DROP'], 'cluster' => false]);
Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 10, 'markers' => ['title' => 'My Location', 'animation' => 'DROP'], 'clusters' => ['size' => 10, 'center' => true, 'zoom' => 20]]);

##### Map Events

**Before Load**

This event is fired before the map is loaded.

Mapper::map(53.381128999999990000, -1.470085000000040000, ['eventBeforeLoad' => 'console.log("before load");']);

**After Load**

This event is fired after the map is loaded.

Mapper::map(53.381128999999990000, -1.470085000000040000, ['eventAfterLoad' => 'console.log("after load");']);

### Location

The `location` method allows a location to be searched for with a string, returning a Location object with its latitude and longitude.

Mapper::location('Sheffield');
Mapper::location('Sheffield')->map(['zoom' => 15, 'center' => false, 'marker' => false, 'type' => 'HYBRID', 'overlay' => 'TRAFFIC']);
Mapper::location('Sheffield')->streetview(1, 1, ['ui' => false]);

### Streetview

The `streetview` method allows a streetview map to be created, with latitude, longitude, heading, pitch and optional parameters for options.

Mapper::streetview(53.381128999999990000, -1.470085000000040000);
Mapper::streetview(53.381128999999990000, -1.470085000000040000, ['ui' => false]);
Mapper::streetview(53.381128999999990000, -1.470085000000040000, 1, 1);
Mapper::streetview(53.381128999999990000, -1.470085000000040000, 1, 1, ['ui' => false]);

### Marker

Expand All @@ -101,6 +140,68 @@ The `marker` method allows a marker to be added to a map, with latitude, longitu
Mapper::marker(53.381128999999990000, -1.470085000000040000, ['symbol' => 'circle', 'scale' => 1000]);
Mapper::map(52.381128999999990000, 0.470085000000040000)->marker(53.381128999999990000, -1.470085000000040000, ['markers' => ['symbol' => 'circle', 'scale' => 1000, 'animation' => 'DROP']]);

#### Draggable Markers

If you need draggable marker, you can add option draggable.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true]);

##### Draggable Events

**Click**

This event is fired when the marker icon was clicked.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventClick' => 'console.log("left click");']);

**Right Click**

This event is fired for a right click on the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventRightClick' => 'console.log("right click");']);

**Mouse Over**

This event is fired when the mouse enters the area of the marker icon.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventMouseOver' => 'console.log("mouse over");']);

**Mouse Down**

This event is fired for a mouse down on the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventMouseDown' => 'console.log("mouse down");']);

**Mouse Up**

This event is fired for a mouse up on the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventMouseUp' => 'console.log("mouse up");']);

**Mouse Out**

This event is fired when the mouse leaves the area of the marker icon.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventMouseOut' => 'console.log("mouse out");']);

**Drag**

This event is repeatedly fired while the user drags the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventDrag' => 'console.log("dragging");']);

**Drag Start**

This event is fired when the user starts dragging the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventDragStart' => 'console.log("drag start");']);

**Drag End**

This event is fired when the user stops dragging the marker.

Mapper::marker(53.381128999999990000, -1.470085000000040000, ['draggable' => true, 'eventDragEnd' => 'console.log("drag end");']);

### Information Window

The `informationWindow` method allows an information window to be added to to a map, with latitude, longitude, content, and optional parameters for options.
Expand Down Expand Up @@ -150,4 +251,4 @@ The `render` method allows all maps to be rendered to the page, this method can

### License

Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
Googlmapper is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.2.*"
"illuminate/view": "5.*",
"illuminate/support": "5.*"
},
"require-dev": {
"phpspec/phpspec": "2.0.*@dev",
Expand Down
57 changes: 57 additions & 0 deletions example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

require_once __DIR__ . "/vendor/autoload.php";

use Cornford\Googlmapper\Mapper;
use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\Engines\CompilerEngine;
use Illuminate\View\Factory;
use Illuminate\View\Engines\EngineResolver;
use Illuminate\View\FileViewFinder;

/**
* Env function.
*
* @param string $key
* @param string $value
*
* @return string
*/
function env($key, $value)
{
return $value;
}

$fileViewFinder = new FileViewFinder(new Filesystem, [__DIR__ . '/src/views']);
$fileViewFinder->addNamespace('googlmapper', [__DIR__ . '/src/views']);

$engineResolver = new EngineResolver();
$engineResolver->register(
'blade',
function () {
return new CompilerEngine(new BladeCompiler(new Filesystem(), sys_get_temp_dir()));
}
);

$viewFactory = new Factory($engineResolver, $fileViewFinder, new Dispatcher(new Container));

$config = include_once __DIR__ . '/src/config/config.php';

$mapper = new Mapper($viewFactory, $config);

// Location
$mapper->location('Sheffield')->streetview(1, 1, ['ui' => false]);

// Map
$mapper->map(53.3, -1.4, ['zoom' => 10, 'center' => false, 'markers' => ['title' => 'My Location', 'animation' => 'DROP']]);

// Information window
$mapper->informationWindow(53.4, -1.5, 'Content');
$mapper->informationWindow(52.4, -1.0, 'Content');
$mapper->informationWindow(51.4, -0.5, 'Content');

// Render
print $mapper->render();
Loading