Jump to content

Map Marker Map


ryan

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

Link to comment
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

Link to comment
Share on other sites

  • 4 weeks later...

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! 

Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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?

Link to comment
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.
Link to comment
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)

Link to comment
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
Link to comment
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 

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...