Jump to content
ryan

Map Marker Map

Recommended Posts

Hey, today a newbie question from me: "Is it possible to get one of those addressboxes with the MapMarker-Field?"

I use it the first time and with a single marker only. Would be nice to have directly such a box displayed.

post-1041-0-32992700-1421919004_thumb.jp

Share this post


Link to post
Share on other sites

Im having troubles to make this work; for some reason on the admin area i can set my market fine; but when i render the map y de frontend the marker just go difrent from i save.
 
I dont see why the module is making the marks  difrente from save on the db.
 

$markers = $page->children();
$map = $modules->get('MarkupGoogleMap');
print $map->render($markers, 'field_map', array('type' => 'ROADMAP'));

post-1401-0-16949700-1422317602_thumb.pn

post-1401-0-55745400-1422317604_thumb.pn

Share this post


Link to post
Share on other sites

@Mats,

Thanks for this.

Please consider submitting your module to the modules directory as well as creating a new (support) thread for it :-)

  • Like 1

Share this post


Link to post
Share on other sites

No one with experience in that area? 

Tried to add that functionality  and  I made a big mess... 

Any help will be highly appreciated!

Hello there! 

Is it possible to add drawing tools to the module? 

https://developers.google.com/maps/documentation/javascript/examples/drawing-tools

On the current project i need to draw polygon on the map and save to DB for later use in front-end.

What changes are needed? 

Thanks in advance! 

Share this post


Link to post
Share on other sites

@mats

Awesome thank you very much for openstreetmap Version!!

Best regards mr-fan

Share this post


Link to post
Share on other sites

@horst

you can add such functionality to your map via google maps api. https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

@Mats

nice!

@awebcreature

i have no experience with this using google maps but using openlayers. of course that's quite a beast regarding complexity and file size - here you have an example: http://openlayers.org/en/v3.2.1/examples/draw-and-modify-features.html. you can also achieve that with the simpler framework leaflet - there are plenty of plugins like this one you would need

I'm thinking to create such a module for my master thesis - but you are 2 years early, sorry ;)

maybe you find some helpful code in my processwire mapping project "geowire": http://geowire.org/

  • Like 1

Share this post


Link to post
Share on other sites

@awebcreature

I have modified the MapMarker module so you can add a polyline (both admin and front-end). You can download it here: https://github.com/madebymats/FieldtypeMapMarkerDraw 

Please note that you should not use the module in production, but may give you an idea how to build the functionality you needed.

post-67-0-73304300-1425243809_thumb.png

post-67-0-36662900-1425243749_thumb.png

  • Like 4

Share this post


Link to post
Share on other sites

Hi there,

this spectacular plugin works just fine, but I have two issues...

1) I can't set the zoom on my front-end map; this code won't work for me:

$items = $pages->find("template=visite-detail, visite_map!='', sort=title");
$options = array('zoom' => '7', 'height' => '700px');
$map = $modules->get('MarkupGoogleMap');
echo $map->render($items, 'visite_map', $options);

2) looking at the rendered map you can see broken zoom controls, tested on a mac and on ubuntu (screenshot attached)

Any suggestions?

post-1363-0-81792000-1426081778_thumb.pn

Share this post


Link to post
Share on other sites

The zoom controls doesn't work because of the css. Try this:

#map_canvas_id img { max-width: none; }
  • Like 5

Share this post


Link to post
Share on other sites

you are absolutely right - how did you find this out? any way of debugging such things?

Share this post


Link to post
Share on other sites

thanks - a pity that i didn't google for "weird UI display glitches (with screenshot)" :D

  • Like 2

Share this post


Link to post
Share on other sites

@Mats: very clever, thanks.

...but still no luck with zoom settings: the rendered map doesn't change if I use zoom 1 or zoom 23...

Share this post


Link to post
Share on other sites

If you change the zoom to an integer?

$options = array('zoom' => 7, 'height' => '700px');

Share this post


Link to post
Share on other sites

Based on what Ryan said, the map automatically fits with all the markers:
 

This module can accept a single Page or a PageArray. If given a PageArray it'll map them all and fit the map to the markers. If given a single page, it should still map the marker and use the zoom setting from that marker.

That's good, I can live with that.

UPDATE: sorted out. There's an option, fitToMarkers, true by default. Make this false and you're done. Here's the code:

$items = $pages->find("template=visite-detail, visite_map!='', sort=title");
$options = array('fitToMarkers' => false);
$map = $modules->get('MarkupGoogleMap');
echo $map->render($items, 'visite_map', $options);

Now you can control your zoom via code or modifying your custom field in PW.

Now just wondering how to enable the hover tooltip: it seems that it works randomly for me. Yes, I put a div with position: relative; outside the map.

using:

'useHoverBox' => true

prevents the map from showing.

Does it work for you?

Share this post


Link to post
Share on other sites

Judging from the module description I'd say it does not work. Batch geocoding is a payed service by most providers. The only one I found is MapQuest, which provides a batch api with up to 100 addresses per request, but still no parallel requests like it's the case for all other free services.

Edit: Most likely such a thing would clash with the max_execution_time of php for most users. 

  • Type in a location or address into the "address" box for the map field. Then click outside of the address, and the Javascript geocoder should automatically populate the latitude, longitude and map location. The Google geocoder will accept full addresses or known location names. For instance, you could type in "Disney Land" and it knows how to find locations like that.

Share this post


Link to post
Share on other sites

thats not true, google maps geocoding api has a limit of 2.500 requests per day - so you are good here: https://developers.google.com/maps/documentation/geocoding/?hl=de#Limits..

Users of the free API:

  • 2,500 requests per 24 hour period.
  • 5 requests per second.

The Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.

So yeah, nope, it's not that easy. Also 5 requests/second would mean 100 seconds for 500 addresses, which is enough to exceed the 30 sec execution time of a standart php installation. 

For more details see here: https://developers.google.com/maps/documentation/geocoding/?hl=en#Limits (the german one isn't as detailed, but also has the part about using it with a visible map)

Share this post


Link to post
Share on other sites

never heard about the 5r/s limit - may be new, thanks for the hint... anyhow, never had any issues with it! but if anybody thinks he is violating google he could also use a free geocoding service (see example)

i just tried

<?php
for ($i=1; $i <= 200; $i++) {
	$p = new Page();
	$p->template = 'basic-page';
	$p->parent = $pages->get('/'); // set parent to root
	$p->name = "Wagramer Strasse " . $i;
	$p->title = 'Wagramer Straße ' . $i;
        $p->map->address = 'Wagramer Straße ' . $i . ', Wien'; // populate the mapmarker field in basic-page template

	// optional: use any other geocoding service like mapquest should be very easy:
	// http://stackoverflow.com/questions/18661189/getting-data-from-json-using-mapquest-and-php
	$result = '...';
	// then populate lat/lng manually
	$p->map->lat = $result->lat;
	$p->map->lng = $result->lng;

	
	$p->save(); 
}
?>

and it worked without any problems. took some seconds of course... but if you only need to geocode the addresses once that should not be a problem.

@iNoize

how did you populate your address fields?

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot. 

Ive importet already the adresses. 

<?php 



include("./index.php"); // bootstrap ProcessWire's API, if applicable



// // // the example template and parent we will be using, change for your use
$template = wire('templates')->get('city'); 
$parent = wire('pages')->get('/verkaufsstellen/de/'); 

// // get your file, read it into an array $archiveData and start to import it:

// // here some (pseudo/example)code
set_time_limit( intval(60 * 10) );  // give it 10 minutes, you may also increase this

$completeurl = "http://myhxmlurl.de/map.xml";
$xml = simplexml_load_file($completeurl);



foreach($xml as $node)
{
  

// create the new page to import
    $page = new Page();
    $page->template = $template;
    $page->parent = $parent; 

    $page->title = $node->Firma;
   
    $page->map->address = $node->StrasseNr.",".$node->Plz." ".$node->Ort;
  
   $page->save(); 
    // testing
echo 'id: '.$page->id.'<br/>';
echo 'path: '.$page->path;

}

// $t = Debug::timer();
// do some expensive code execution here
// echo Debug::timer($t);

How to renew the geocode without a new page ?? 

And have also trouble with the 'useHoverBox' => true options. 

maybe you have an 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild.  
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Steps (Read more) Manual override of the selected value (will still adhere to the rules above) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant If it's usable for others I'll add it to the Modules list  
      Changelog
      v002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional 
      v001
      - Initial release
       
      Thanks!
       
       
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...