Jump to content

Map Marker Map


ryan

Recommended Posts

Success, adding to MarkupGoogleMap.js... (not RCDMap.js!)

        var ctaLayer = new google.maps.KmlLayer({
        url: 'http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml',
           map: this.map
          });

at line 126...

Thanks for help!

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

The MapMarker field does not seem to work properly in the following situations:

* In a Repeater in PW 3.0 with dynamic content loading. Only way here is to disable it completely so you have to save before every new item ;(

* With FieldsetTab if the field is not on the first page of adminpage ;(

Any chance of fixing this? 

All the best, D

Link to comment
Share on other sites

The MapMarker field does not seem to work properly in the following situations:

* In a Repeater in PW 3.0 with dynamic content loading. Only way here is to disable it completely so you have to save before every new item ;(

* With FieldsetTab if the field is not on the first page of adminpage ;(

Any chance of fixing this? 

All the best, D

Take a look at this PR (https://github.com/ryancramerdesign/FieldtypeMapMarker/pull/11) - I haven't tested it, but hopefully it will take care of what you need.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

is there a possibility to have multiple marker icons?

Right now I have "locations" pages, that belong to a category. Depending on the category I want to show different marker icons.

echo $map->render($locations, 'geo', array(
    'icon' => $icon,
    'markerTitleField' => 'title',
    'useMarkerSettings' => true,
    'fitToMarkers' => true
  ));

Thanks for any help.

Link to comment
Share on other sites

  • 2 weeks later...

@pmichaelis + @chugurk

maybe my answer help both of you...

i use MapMarker Field only in backend to get lat and long data from adresses and use them with leaflet cluster maps to generate frontend output from the geodata...

in your main template or header add needed scripts:

<!-- set extra scripts to load if there was a map on the page -->
<script type="text/javascript" src="<?php echo $config->urls->templates?>theme/js/jquery.min.js" ></script>
<script src="<?php echo $config->urls->templates?>theme/js/leaflet.js"></script>
<script src="<?php echo $config->urls->templates?>theme/js/leaflet.markercluster.js"></script>
<link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/leaflet.css">
<link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/MarkerCluster.css">
<link rel="stylesheet" href="<?php echo $config->urls->templates?>theme/css/MarkerCluster.Default.css">

in your template to show the map with many markers using marker cluster output you could use something like this:

//set output
$map = '';
$addressPoints = '';

//get all addresspoints for the JS of the MarkerCluster
$items = $pages->find("template=entry, map!=''");
foreach ($items as $m) {
	if  ($m === $items->last()) {
		$addressPoints .= '['.$m->map->lat.', '.$m->map->lng.', "<a title=\"'.$m->title.'\" href=\"'.$m->url.'\">read more</a>"]';
	} else {
		$addressPoints .= '['.$m->map->lat.', '.$m->map->lng.', "<a title=\"'.$m->title.'\" href=\"'.$m->url.'\">read more</a>"],';
	}
}

        //render cluster map with all items
	//centered to bavaria lat/long!!
	//set the needed inline JS for the map content
	$inlineJS = "
		<script>
			var addressPoints = [$addressPoints];
			var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
					maxZoom: 18,
					attribution: '© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'
			}),
			latlng = L.latLng(48.1835,11.8570);

			var map = L.map('map', {center: latlng, zoom: 8, layers: [tiles]});

			var markers = L.markerClusterGroup();

			for (var i = 0; i < addressPoints.length; i++) {
				var a = addressPoints[i];
				var title = a[2];
				var marker = L.marker(new L.LatLng(a[0], a[1]), { title: title });
				marker.bindPopup(title);
				markers.addLayer(marker);
			}

			map.addLayer(markers);
		</script>
		";

	$map .= '<div id="map"></div>';
	$map .= $inlineJS;
	$content .= $map;

This should render a map like the developer locations map http://directory.processwire.com/map/ with marker clusters...

for single marker output there should be a lot of information in the topic if you search or read for it....;)

https://processwire.com/talk/topic/9711-map-marker-map/page-2#entry18338

https://processwire.com/talk/topic/9711-map-marker-map/page-2#entry21061

https://processwire.com/talk/topic/9711-map-marker-map/page-3#entry28913

since post #98 you could use MarkupGoogleMap too render a map on frontend:

https://processwire.com/talk/topic/9711-map-marker-map/page-5#entry41984

please read carefully before asking and provide code examples if you get stucked....

best regards mr-fan

  • Like 5
Link to comment
Share on other sites

  • 3 weeks later...

As per Google recent announcement, usage of the Google Maps APIs now requires a key. I've tried to use @ryan's Map Marker (Google Maps) but it errors out due to this. I would assume the module needs updating to allow for an API key field?

I believe this line, within '' needs to be changed from:

public function init() {
	$this->config->scripts->add(($this->config->https ? 'https' : 'http') . '://maps.google.com/maps/api/js?sensor=false'); 
	return parent::init();
}

to

public function init() {
    $this->config->scripts->add(($this->config->https ? 'https' : 'http') . '://maps.googleapis.com/maps/api/js?key=API_KEY_HERE&callback=initMap'); 
    return parent::init();
}
  • Like 2
Link to comment
Share on other sites

Man Google is such a nice service provider. I cannot imagine how many google maps implementations they broke just by applying policy changes "as of now". I mean I didn't like instagrams move to only "approved apps", but at least they told people about is half a year beforehand. 

  • Like 2
Link to comment
Share on other sites

8 hours ago, Robin S said:

If you mean the message in your browser console I think it's just a warning rather than an error. I'm using the Map Marker module without an API key and it's working fine.

Doesn't for me; I got two error messages (which doesn't break the map) and then a forced error which returns this:

https://www.latecnosfera.com/2016/06/google-maps-api-error-missing-keymap-error-solved.html

  • Like 1
Link to comment
Share on other sites

22 hours ago, John the Painter said:

Doesn't for me; I got two error messages (which doesn't break the map) and then a forced error which returns this:

https://www.latecnosfera.com/2016/06/google-maps-api-error-missing-keymap-error-solved.html

Thanks for the info. Seems that this affects all new map applications and existing applications (like mine) are grandfathered.

Link to comment
Share on other sites

To complicate things, there are different api keys needed for LIVE / STAGING / LOCALHOST environments?  That's how I understand the changes.

Edit:

Just learned: localhost and staging can/needs to be added at google to share one api

Link to comment
Share on other sites

  • 2 weeks later...

To supplement @John the Painter's answer:

1. Update InputfieldMapMarker.module to get your API key however you're managing it:

public function init() {
	$apikey = // get my api key
	$script_path = ($this->config->https ? 'https' : 'http') . "://maps.googleapis.com/maps/api/js?key={$apikey}";
	$this->config->scripts->add($script_path); 
	return parent::init();
}

2. Enable 'Google Maps Geocoding API' in your Google API Console for your site's API key: https://console.developers.google.com/apis/api/geocoding_backend/overview

You may need to enable whichever other individual APIs (places, geolocation, etc.) from Google's API library for the client side if you use the same API key: https://console.developers.google.com/apis/library

 

Updating the MapMarker module will remove these changes if this file is affected by the update.

  • Like 2
Link to comment
Share on other sites

On 10.07.2016 at 6:24 PM, larrybotha said:

To supplement @John the Painter's answer:

1. Update InputfieldMapMarker.module to get your API key however you're managing it:


public function init() {
	$apikey = // get my api key
	$script_path = ($this->config->https ? 'https' : 'http') . "://maps.googleapis.com/maps/api/js?key={$apikey}";
	$this->config->scripts->add($script_path); 
	return parent::init();
}

2. Enable 'Google Maps Geocoding API' in your Google API Console for your site's API key: https://console.developers.google.com/apis/api/geocoding_backend/overview

You may need to enable whichever other individual APIs (places, geolocation, etc.) from Google's API library for the client side if you use the same API key: https://console.developers.google.com/apis/library

 

Updating the MapMarker module will remove these changes if this file is affected by the update.

 

Added pull request for this issue : #14

If you want, you can apply my changes to your files or you can directly download applied version.

 

I added 2 option for FieldtypeMapMarker module settings, api key and url parameters.

FieldtypeMapMarkerSettings.jpg

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

i am using processwire v3

i installed mapmarker module. crate a map field and add it to temple.

When i try to open template from admin field map not coming. ! mark comes and says js file error.

what should i do?

some people says api key related but i dont know what to do

Link to comment
Share on other sites

hi, i tried forked version of @ukyo , i installed it and and get the apikey (browser type) for my project.

then i add api key  from module config page. now admin panel works fine with map.

i add

<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>

to template file as told on the read me file.

When i try to load the template it said "opps ! something went wrong"

so i added

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=API_KEY&sensor=false"></script>

now it works fine.

Is it bad for me to use this with api key on my template? because everybody can see my key by view soruce of page

 

 

Link to comment
Share on other sites

  • 5 weeks later...
29 minutes ago, bernhard said:

@Kemal you are right, you have to add the api key to the google script! you can limit requests to the google api in your google console to your domain to prevent abuse from other people.

@ukyo thanks for the fork, any news about an official pull request / merge?

@ryan updated module, now you can update module directly from admin panel

  • Like 3
Link to comment
Share on other sites

Hey folks!

I managed to get this working with multiple markers (using a repeater).
Following this thread, I even got the hoverBox with a custom field working. 

Only Problem I have now, is that I need different icons for each marker.
With my noob developer skills I can't get it to work.

Here is what I tried:

<?php
    $map = $modules->get('MarkupGoogleMap'); 
    $options = array(
    'height' => '100%',
    'width' => '100%',
    'icon' => '$page->map_repeater->marker_icon->url',
);
      $items = $page->map_repeater;
echo $map->render($items, 'map', $options); 
                 ?>

"marker_icon" is an image field in the repeater I want to use for the Icons.
Can someone please help me with this?
Thanks for this awesome module btw.!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for creating a new measurement object from the sum or difference between two other objects. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.
      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      Screencasts
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      Exclusions
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
       
      https://github.com/Toutouwai/RepeaterEasySort
      https://processwire.com/modules/repeater-easy-sort/
×
×
  • Create New...