Git Product home page Git Product logo

acf-field-type-mapmore's Introduction

ACF MapMore Field

Complex map field for Advanced Custom Fields.

Preview Field in Wordpress admin

Supports

  • Areas
    • Circles
    • Polygons
  • Routes
  • Custom POIs

Usage

Displaying selected location

$value = get_field('mapmore_field');

switch ( $value['type'] ) {

	case 'rectangle':
	?>
	<script>
      	new google.maps.Rectangle({
      		bounds:     <?php echo json_encode($value['bounds']) ?>,
      		map:        map
      	});
	</script>
	<?php
	break;

  	case 'polyline':
	?>
	<script>
      	new google.maps.Polyline({
      		path:       <?php echo json_encode($value['path']) ?>],
      		map:        map,
      	});
  	</script>
  	<?php
  	break;

  	case 'polygon':
	?>
	<script>
      	new google.maps.Polygon({
      		path:       <?php echo json_encode($value['path']) ?>],
      		map:        map
      	});
  	</script>
  	<?php
  	break;

  	case 'circle':
	?>
	<script>
      	new google.maps.Circle({
      		center:     {lat: <?php echo $value['lat'] ?>], lng: <?php echo $value['lng'] ?>},
      		radius:     <?php echo $value['radius'] ?>,
      		map:        map
      	});
  	</script>
  	<?php
  	break;

  	case 'marker':
	?>
	<script>
      	new google.maps.Marker({
      		position:   {lat: <?php echo $value['lat'] ?>], lng: <?php echo $value['lng'] ?>},
      		map:        map,
      		animation:  google.maps.Animation.DROP
      	});
  	</script>
  	<?php
  	break;

}

Adding marker icons

Add any *.svg files to images/icons they will be automatically available as Marker icons

Setting Google API key

Add this to your theme's functions.php


function mapmore_acf_google_map_api() {

	acf_append_setting('mapmore_google_api_key', 'YOUR_GOOGLE_API_KEY');

}

add_filter('init', 'mapmore_acf_google_map_api');

Description

EXTENDED_DESCRIPTION

Compatibility

This ACF field type is compatible with:

  • ACF 5
  • ACF 4

Installation

  1. Copy the acf-mapmore folder into your wp-content/plugins folder
  2. Activate the MapMore plugin via the plugins admin page
  3. Create a new field via ACF and select the MapMore type
  4. Please refer to the description for more info regarding the field type settings

Tests

Unit Tests

composer run-script test

Integration Tests

With local setup

composer run-script test:wordpress

Using docker

docker-compose run phpunit
composer install
composer:test:wordpress

Changelog

Please see readme.txt for changelog

Credits

Icons

  • Map Marker, Pin, thumb tack, Flag, Tree, forest, Flower, Sun, Crescent Moon, Tornado, Hail, Lightning, Day Fog, Bicycle, Car, Bus, Train, Hot Air Balloon, Departure, Airplane Mode, Tent, Image, Color, Shop, Hanging board by (Pham Thi Dieu Linh)[https://thenounproject.com/phdieuli/] from (the Noun Project)[https://thenounproject.com]

acf-field-type-mapmore's People

Contributors

dwatts3624 avatar gweecl avatar rozklad avatar seeker5084 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

acf-field-type-mapmore's Issues

height: 0 in latest wordpress

There is problem with latest wordpress(5.3) - the window for map is set to height 0px, not auto(or 100%, in that matter) - which causes problem.

It looks like this:
https://i.postimg.cc/PrXFN8Z9/map.png
setting custom height for main wrap fixes it.

Also other thing - any chance to implement multimarker?

Is there any hope for an update?

I really loved this functionality you've been to add nicely to ACF. I've made the move to ACF 6 and things are partially working. Are you guys totally busy with other projects or have you dropped this project completely?

Would be really awesome if this one got an update!

On resave, field data is cleared

I have a custom post type that uses an ACF MapMore field that I'm experiencing issues with. When a post has an ACF MapMore field with a value already set, this value is cleared/removed upon resave. After saving I have to go back and reinput the location, which can be quite time consuming if it's using a polygon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.