Jump to content

Map Marker Map


ryan

Recommended Posts

I am currently using the RCD map class by Ryan (see post 18 of this thread) which happily accepts anchor tags for the marker URL like so:

$js .= "\nRCDMap.addMarker('{$marker->title} ({$marker->parent->title})', '#{$marker->parent->title} {$marker->title}', {$marker->map_marker->lat}, {$marker->map_marker->lng});";

How do I achieve the same with MarkupGoogleMap as the markerLinkField only accepts a page field?

Thanks!

UPDATE: Managed to do it using http://modules.processwire.com/modules/fieldtype-concat/

Would you mind sharing your solution? I'm in the same boat and don't know exactly how to achieve this with the fieldtype concat.

What I'd like to achieve is an anchor like this: #target_name

However, the field name has an output of "name", not the actual page name. The same happens with these fields as well: id, path, url, template

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

For anyone that has the map hidden initially before being opened resulting in bad rendering of the map.

I tried the following that was mentioned here on this post but with no success.

setTimeout(function() {
    google.maps.event.trigger(mgmap1, 'resize'); 
    mgmap1
.map.setCenter(mgmap1.options.center);
  }, 250);

After a while(2 hours :huh: ) scratching my head I changed it to the following:

setTimeout(function() {
    google.maps.event.trigger($("#mgmap1")[0], 'resize');
    mgmap1.map.setCenter(mgmap1.options.center);
  }, 250);

Now works perfectly.

  • Like 9
Link to comment
Share on other sites

  • 1 month later...

Is it possible to create custom markers? I have around 20 markers and want to show them as numbered coloured dots on the map. Its basically just a red spot (all CSS, no images) with the number right in the middle. Not sure if this has already been asked here before. Anyone else tried this before? 

Link to comment
Share on other sites

I wanted to use PW mapmarker.... but for frontend what I needed it was not suited.

I now use geocomplete from ubilabs for frontend. Looks great, works excellent. The google api3 docs have an excellent video on retrieving addresses.

So in my form I have 1 autocomplete address field that catches Country, State and City level (I explicitly set it to real addresses, NOT from hotels or anything) and use those values to populate fields for members. If any is missing, it would not be valid.

Yes, I could use a dropdown (thousands of cities), or use a input field (no way to validate). So this was a good solution.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I'm having trouble with removing the fit to markers functionality when using multiple markers. I've read through some of the previous post on the subject and Ryan seemed to indicate that I needed to use 'new PageArray()'? I tried what BFD Calendar did, and this resulted in the proper zooming and lat and long, but no markers. 

echo $map->render(new PageArray($pages->find("template=bfd_places, MapMarker!=''")), 'MapMarker', array('height' => '400px', 'zoom' => '2', 'lat' => '50.923813', 'lng' => '4.431493'));

I also tried: 

<?php 
$markers = new PageArray();
foreach ($page->children() as $c) {
  $markers->add($c);
}

echo $map->render($markers, 'loc_mapmarker_map', array(
  'fitToMarkers' => 'false', 
  'id' => 'newmap',
  'type' => 'ROADMAP',
  'icon' => '/site/templates/styles/images/pin.png',
  'height' => '583',
  'lat' => '49.8602016',
  'lng' => '-97.1510875',
  'zoom' => '10',
));
?>

Which resulted in it fitting to the markers again. 

Any help would be appreciated. 

Thanks,

Riz

Link to comment
Share on other sites

Riz, it took me a while to get things going. Here's the (working) code I use on my home template:

// MAP

	echo "<div style = 'width:85%'><br>";

	$landmarks = $pages->find("parent=/events/|/the-eyes/, bfd_month.name=$month, bfd_day.name=$day, sort=bfd_day, sort=bfd_year, sort=name");
	$markers = new PageArray();
	foreach($landmarks as $landmark) {
	$myentry = $landmark->bfd_events_places_id_list;
	$myentry->markerUrl = $landmark->url;
	$myentry->markerTitle = $landmark->title;
	$markers->add($myentry);
	}
	if ($markers && $landmark->bfd_day) {
	$map = $modules->get('MarkupGoogleMap'); 
	$options = array('width' => '100%', 'height' => '500px', 'markerLinkField' => 'markerUrl', 'markerTitleField' => 'markerTitle');

	echo $map->render($markers, 'MapMarker', $options);
	}
	else {
	echo "";
	};
    ?>
    </div>

"bfd_events_places_id_list" is a page field in every "event" template. It refers to pages that have the actual MapMarker field and other info as well (placename, street, district, city, state, country,...).

Maybe you can adapt it to your situation. And probably some guys here can smooth it all out or compact it.

DDV

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

This module has settled in well to my live site. However, the client often presents the site 'offline'. To do this the client has made a copy of the site using httptrack.

It's not my ideal solution but suits the client well.

The problem is when the site tries to load a page with the map marker displayed they get this error:

"Markup Google map error please add the maps.googleapis.com in your document head".

Is there a possible way around this? Any suggestions welcome....

Link to comment
Share on other sites

This module has settled in well to my live site. However, the client often presents the site 'offline'. To do this the client has made a copy of the site using httptrack.

It's not my ideal solution but suits the client well.

The problem is when the site tries to load a page with the map marker displayed they get this error:

"Markup Google map error please add the maps.googleapis.com in your document head".

Is there a possible way around this? Any suggestions welcome....

It might be possible to cache the tiles, but from a little reading, it sounds like that would be against the TOS:

https://groups.google.com/forum/#!topic/google-maps-js-api-v3/sALpJq12HjQ

It might be easier if you were using the google static maps API: https://developers.google.com/maps/documentation/staticmaps/ although this still might not be allowed (I haven't checked).

Link to comment
Share on other sites

  • 1 month later...

I don't understand why my MarkupGoogleMap won't work... I tried following the Skyscrapers example first, with RCDMap.js etc., that didn't work; so now I'm trying this MarkupGoogleMap and I get a blank map with just a gray background. 

In my head element, I have:

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>

and this snippet in my listing page template:

$map = $modules->get('MarkupGoogleMap');
echo $map->render($page, 'map_location');

and I just get a blank map canvas. No errors in JS console. Anyone know how I might get this to work? Thanks...

Although, I've been skimming through this thread, and I'm very interested possibly trying to implement something like what Bwakad did, with Geocomplete... mentioned here. There's the first benefit of having the input validation taken care of, and then also what I'd like to do, I don't know if it can be done using this but I would like ultimately for the listings to be searchable, by proximity... not just location. Like for the visitor to be able to choose "10" or "50 miles from {$location}". Anyone know how this might be achieved? 

But for now just the maps would be nice.

Link to comment
Share on other sites

I can't get this to work for the life of me. I've tried literally everything, everyone's snippets. I'm on localhost, PW 2.5.3. The closest I managed to get is a shot of the whole world, or a relative close-up of the correct location, without the ability to drag and see anything around it, and sans marker.

Link to comment
Share on other sites

I can't get this to work for the life of me. I've tried literally everything, everyone's snippets. I'm on localhost, PW 2.5.3. The closest I managed to get is a shot of the whole world, or a relative close-up of the correct location, without the ability to drag and see anything around it, and sans marker.

Repeating "I can't" wouldn't help.  It will be great if you change your mindset and look for some javascript errors in the browser console or in the code. Don't just copy/paste "everyone's snippets" but try to understand what they are doing. I can confirm that this module is working and used by hundreds. This is all I can say based on your "I can't". Peace!

  • Like 2
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...