Jump to content

Map Marker Map


ryan

Recommended Posts

6 hours ago, jploch said:

'icon' => '$page->map_repeater->marker_icon->url',

Variables in single quotes are not evaluated to their values, rather, they are treated as strings. You have to use double quotes to do that. However, @matjazp is right, you do not need any of them is this case, because the url is already a string.

Link to comment
Share on other sites

9 hours ago, jploch said:

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); 
                 ?>

The 'icon' value needs to be a single image url. A repeater returns a PageArray, so you need to get a single page from it and then a single url from that page. Assuming that the formatted value of the marker_icon field is set to "single item" you would do something like this:

'icon' => $page->map_repeater->first()->marker_icon->url

Also, the $options array is something that applies to the map as a whole. It allows you to set a single custom icon to be used across the whole map. I don't think the module provides support for setting different icons to different individual markers.

  • Like 2
Link to comment
Share on other sites

I wonder how to display plz (zip) areas in the map in additon to the markers.

What do I mean: If you search in google maps for e.g. "schöneberg, berlin, deutschland" you get an overlay for that city destrict. I wonder, if you can adress this by the api. Dont want to make own overlays.

Link to comment
Share on other sites

On 26.8.2016 at 11:18 PM, Robin S said:

Also, the $options array is something that applies to the map as a whole. It allows you to set a single custom icon to be used across the whole map. I don't think the module provides support for setting different icons to different individual markers.

Thanks for your reply. You are right the icon variable only allows a single value.
The post from nghi helped me to get it working with custom icons for each marker.

Here is the code I used in the MarkupGoogleMap.module:

/** Custom Fields */
		foreach($pageArray as $page) {
$marker = $page->get($fieldName); 
if(!$marker instanceof MapMarker) continue; 
if(!$marker->lat) continue; 
$url = $options['markerLinkField'] ? $page->get($options['markerLinkField']) : '';
$title = $options['markerTitleField'] ? $page->get($options['markerTitleField']) : '';
$icon = $page->marker_icon->url ? $page->marker_icon->url  : '';
$map_location_name = $page->map_location_name ? $page->map_location_name  : '';
$out .= "$id.addMarker($marker->lat, $marker->lng, '$url', '$title', '$icon', '$map_location_name'); ";
}

Maybe this will help someone.

  • Like 3
Link to comment
Share on other sites

On 28.8.2016 at 9:33 PM, Mats said:

Well, I tried to avoid this. Also found only similar solutions. But for those who are interested, here a link for plz files. Maybe I 'll give it a try.

http://www.suche-postleitzahl.org/downloads

Link to comment
Share on other sites

  • 2 weeks later...

@ryan It might be useful to update the module documentation regarding your latest release (2.0.8) from...

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

to something like...

<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key=<?=$modules->FieldtypeMapMarker->googleApiKey?>'></script>

...in order for the frontend to also use the API key when rendering a map.

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Today I've experienced interface issue - input fields were hidden (address, etc). After some inspection, I found that reason was in css - map has changed its relative position. I guess Google has changed smth in script that draws map as there were no changes in css locally. Do you have the same issue?

To fix the issue I had to add custom style clear tag to InputfieldMapMarker.module

line 161            "style='height: {$height}px;clear:left;' " .

 

  • Like 6
Link to comment
Share on other sites

On 9/21/2016 at 2:29 AM, valan said:

Today I've experienced interface issue - input fields were hidden (address, etc). After some inspection, I found that reason was in css - map has changed its relative position. I guess Google has changed smth in script that draws map as there were no changes in css locally. Do you have the same issue?

To fix the issue I had to add custom style clear tag to InputfieldMapMarker.module


line 161            "style='height: {$height}px;clear:left;' " .

 

Thanks for this @valan - any chance you could submit this as an Issue or PR to Github?

  • Like 1
Link to comment
Share on other sites

I am having problems with accessing the map marker api. No matter what I do it just outputs the entire information in all the fields

"address (lat, lng, zoom) [OK ROOFTOP]"

if i add $page->map->lat it just adds "->lat" at the end of the output

 

 

works now. needed to use {} brackets in my php

 

Link to comment
Share on other sites

Hi,

We recently migrated to a new server and we're been getting the following error when saving a page with a MapMarker on it:

Error saving field "marker" - SQLSTATE[01000]: Warning: 1265 Data truncated for column 'lat' at row 1

A little digging and I got this error when saving the field:

Geocode is not supported because 'allow_url_fopen' is disabled in PHP

Is it possible to get around this? Can this function be replaced with a CURL request?

Cheers,

Chris Thomson

Link to comment
Share on other sites

I have been using MapMarker on a client site for long. Recently I updated the website to Processwire 2.7.2. While trying to add a page using a template with FieldTypeMapMarker I noticed the address box has vanished even though the default map shows. Underneath the map I can see "N/A". Any idea how to get back address box.

Link to comment
Share on other sites

It appears as if renderReady ($this->config->scripts->add($url)) isn't actually firing before the scripts are rendered to the admin template.

I've prepended the script manually in default.php and this has fixed the issue, although I'd rather the module did it! We use a custom admin template, but I did switch over to the default one to test it, and the result was the same.

I also have had to implement valan's "clear:left;" CSS fix from above.

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
×
×
  • Create New...