Code Monkey home page Code Monkey logo

maplocationfield's Introduction

Map Location Field

Ugly Slightly dirty hack from Nick Dunn’s original version.

  • Removed Tabs
  • Removed sensor option
  • Possibility to add API-Key in field settings
  • OSM Map included as Layer
  • Localisation

Installation

  1. Upload the /maplocationfield folder in this archive to your Symphony /extensions folder
  2. Enable it by selecting the "Field: Map Location", choose Enable from the with-selected menu, then click Apply
  3. The field will be available in the list when creating a Section
  4. You will need a Google Maps API Key in order to use geolocations services. If you have that, paste it in the appropriate field in the field settings.

Configuration

When adding this field to a section, the following options are available to you:

  • Default Marker Location is the address of a default marker. Enter any address/ZIP to be geocoded
  • Default Zoom Level is the initial zoom level of the map

The field works in both Main Content and Sidebar columns, collapsing to a smaller viewport if required.

Usage

When creating a new entry, drag the red marker on the map to change location. To tweak the latitude/longitude use the corresponding fields below the map. The address input also allows you to enter an address to be geocoded and placed on the map.

Example field

Data Source Filtering

The field provides a single syntax for radius-based searches. Use the following as a DS filter:

within DISTANCE UNIT of ORIGIN
  • DISTANCE is an integer
  • UNIT is the distance unit: km, mile or miles
  • ORIGIN is the centre of the radius. Accepts either a latitude/longitude pair or an address

Examples:

within 20 km of 10.545,-103.1
within 1km of 1 West Street, Burleigh Heads, Australia
within 500 miles of London

To make the filters dynamic, use the parameter syntax like any other filter. For example using querystring parameters:

within {$url-distance} {$url-unit} of {$url-origin}

Attached to a page invoked as:

/?distance=30&unit=km&origin=London,England

Data Source XML result

The XML output of the field looks like this:

<location latitude="51.6614" longitude="-0.40042">
	<map zoom="15" centre="51.6614,-0.40042" />
</location>

The first two attributes are the latitude/longitude of the marker on the map. The <map> element contains any information you need to rebuild the Google Map on the frontend of your website: its zoom level, centre-point and your API key.

If you are filtering using the Map Location Field using a "within" filter then you will see an additional <distance> element:

<location latitude="51.6614" longitude="-0.40042">
	<map zoom="15" centre="51.6614,-0.40042" />
	<distance from="51.6245572,-0.4674079" distance="3.8" unit="miles" />
</location>

The from attribute is the latitude/longitude resolved from the DS filter (the origin), the unit shows either "km" or "miles" depending on what you use in your filter, and distance is the distance between your map marker and the origin.

maplocationfield's People

Contributors

animaux avatar brendo avatar iwyg avatar lewiswharf avatar nickdunn avatar nimanthaharshana avatar nitriques avatar stuartgpalmer avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maplocationfield's Issues

extension.meta.xml does not include the required namespace

..at least, that's what Symphony says me when I updated to 2.3 (HEAD):

Symphony Fatal Error
The extension.meta.xml file for the maplocationfield extension is not valid XML: 
Missing default namespace definition.

Solution is very simple, but I can provide a pull request if you prefer. Thanks!

split() deprecated in 2.3.2Beta1

Hi Nick,

Had an error thrown when checking this out on 2.3.2.

Using explode instead of split seemed to have resolved it.

Do you think that is the correct change to make here?

IE7+Publish Tabs+Maplocationfield = crash

If I use this extension together with publish tabs, it makes IE7 crash as soon as the tab with Google Maps is shown.

Note: when maps is on the first tab, IE7 doesn't crash yet. When you select another tab and then jump back to the first tab with the maps field, then IE7 crashes.

Fatal error: Class 'extension_maplocationfield' not found on line 302 of fields/field.maplocation.php

Nick,

This is really odd. I don't know what is happening here. I updated from 3.1.1 to 3.2.3.

When I pulled up my locator page. I get the following error.

Fatal error: Class 'extension_maplocationfield' not found in /Sites/sitename/public/extensions/maplocationfield/fields/field.maplocation.php on line 302

I noticed when I remove the Map Location Field filter, I don't get the error. I deleted the Data Source altogether, and then rebuilt it, added the Map Location Field Datasource Filter and that error popped up again.

Here's the filter that I have... in the Value field... within {$url-range} miles of {$url-zipcode}

I didn't change a thing. I look at the code matches exactly what is on Github.

Actually, if you look at the fields/field.maplocation.php file on line 230, it refers to the Class extension_maplocationfield, but then it trips up on line 302. I commented out line 302, and then I don't get a fatal error... but I do get a MySQL error in the debug.

It doesn't make sense at all (or I can't make sense of it). Can you help me with this?

Multiple Pins

Not an issue, I'm just wondering if anyone has attempted to add multiple pin support before? Entries in my Section will have multiple locations, so at the moment I'm thinking of creating a separate Maps section and using Association field to create multiple.

But ideally, this beautiful extension would manage the lot and have multiple markers.

Keep up the great work!

Output Performance

A rather simple output of 5655 entries with only map location field lat/lng data takes 8.5s for the XML to be created, even though I have already commented out the output of the <map/> element containing centre and zoom attributes.

I see the future...

So then Mr Nick,

I've been having a good old think about the future of Geolocation in Symphony, while I've been working extensively with the new Google API (thanks for pulling the changes). We have lots of fields available to us, that all do the same kind of thing but slightly differently.

I think they need to be merged into one Geolocation field that fits the bill perfectly. The Address Field for me would be the start point for an end user to enter their address in the New Entry page, then hit a button to 'Locate on map'. If the field is in the main column, the map is already visible, if not it is tabbed, like you have it now.

Once the user hits the button, the JS will drop a marker on the map, and populate the Lat Lng fields under the address. The marker is draggable to allow the user to finely pinpoint the address entered, this action shouldn't edit the address though, but will edit the Lat Lng fields. The 'Locate on map' button should either be disabled or re-labelled at this point too.

I think that the developer should be able to specify whether the Lat Lng fields are editable or not too.

What are your thoughts on this approach?

I'm going to have a try at this, but I will fail.

Saving API Key fails

In one (just one) Symphony CMS installation I somehow cannot save any section when a maplocation field is part of it. More precisely: It does save everything but the Google Maps API Key and it won't reload the page. If I delete the maplocation field from the section, everything is back to normal, saving is no problem anymore. Updating the extension did not help neither completely uninstalling and then re-installing it.

How could I dive deeper into the problem, any hints on what to look for?

Unknown column 'latitude' in 'field list'

I have added the map location field to my section, however I'm getting a few errors and I'm not sure what's causing it.

Firstly when I go to set the default location it won't let me use anything other than the default 'London, England'. I get the following error when saving the section;

Column 'default_location_coords' cannot be null

That wasn't so much of an issue I could just use the default location.

However when I go to create an entry, I enter the postcode in the address box and update map. This finds the right area and puts the marker in the correct place on the map. Yet when I go to create the entry I get the following error;

Unknown column 'latitude' in 'field list'

But the entry is still saved.

I'm using Symphony 2.6.11 and maplocationfield 3.4.2

Has anyone else come across this before? Any help would be greatly appreciated.

Extension throws an error on PHP 7.2 and above

I'm using the maplocation field on event details. When I update to PHP 7.2 or 7.3 I get the following error:

<event-details>
    <error><![CDATA[count(): Parameter must be an array or an object that 
implements Countable on 236 of file /home/webgquzk2/html/
extensions/maplocationfield/fields/field.maplocation.php]]></error>
</event-details>

Everything is fine with PHP 7.1 or below.

Custom Sources + GeoJSON

From the Extension Updates thread in the forum:

Support for GeoJSON (pasting locations) as well as for different tile providers (custom, Mapbox – using Leaflet) would be helpful additions.

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.