Jump to content

Map Marker Map


ryan

Recommended Posts

maybe the problem is that the geocoder didn't find your address - try adding a space here:

post-2137-0-50403100-1426503868_thumb.pn

$page->map->address = $node->StrasseNr.", ".$node->Plz." ".$node->Ort; // use this
$page->map->address = $node->StrasseNr.",".$node->Plz." ".$node->Ort; // instead of this

of course use $page = $page->get( your page to edit ) instead of $page = new Page()

  • Like 1
Link to comment
Share on other sites

Thanks, 

no i tried to view the Map with thy RCDMap.js but something goes wrong. 

I get always the error with the mapNote

http://prntscr.com/6j2zmp

with one adress i see the Map without marker.

With more than one its only a grey div.

What could be the Problem ? 

I use this way 

https://processwire.com/talk/topic/690-map-marker-fieldtype/?p=18338 

Link to comment
Share on other sites

Thanks, 

I had to put jquery in the <head> also. 

Now It works with the cluster and custom icons https://processwire.com/talk/topic/690-map-marker-fieldtype/?p=25865 

One question for teh category field. 

Wchich kind of field it have to be ? Textfield ? 

echo "\n\n<div id='map'></div>"; //div to show in template map

$js = "<script type='text/javascript'>";

$js .= "RCDMap.options.zoom = 2;";
$js .= "RCDMap.init('map', 0, 0);";

foreach($page->children as $items) {
  $cat = $items->category ? $items->category->name : 'default-icon'; //Uses a field called category for icon.  
  $js .= "\nRCDMap.addMarker('{$items->title}', '{$items->url}', {$items->map->lat}, {$items->map->lng}, '{$cat}');";
}
$js .= "RCDMap.fitToMarkers();";

$js .= "</script>";
echo $js;

dont get really to work with the custom icon. 

$cat = $items->category ? $items->category->name : 'default-icon'; //Uses a field called category for icon.  
Link to comment
Share on other sites

  • 4 weeks later...

Hello, 

is it possible to get the Distance between two selected points ? 

I will try to get the distance between two points. 

The idea is to get near airport and show the distance to the choosen city near airport ? 

I have no idea how to start to realize this. Some one expierence with this kind of problem ? 

Thanks 

Link to comment
Share on other sites

I've got Map marker mod installed and put it on a template (which has a sidebar), I then created a page from that template, put in all the details of the lat/long etc. and can see the map and marker in edit mode.  I'm probably being stupid but how the heck do I make the map appear at the top of my sidebar in view mode (and published mode)?

Edited by LostKobrakai
Moved to the right forum
Link to comment
Share on other sites

@Mats

thank you so much for your OSM version of the module. Have you opened a thread dedicated to it, yet? Couldn't find it in the forums.

I forked your module and added basic support for leaflet-providers. In the field settings we can now choose the map tile provider.

post-1920-0-17713500-1429776568_thumb.pn

and the map renders accordingly

(example with MapQuest.Open)

post-1920-0-39407600-1429776974_thumb.pn

(example with OpenStreetMap.BlackAndWhite)

post-1920-0-87065700-1429776994_thumb.pn

I'm thinking adding this on a per marker basis also but I'm not quite sure yet if it makes sense at all to define tiles per marker?

We should definitely open a separate thread for your module, what do you think?

  • Like 3
Link to comment
Share on other sites

you have some code before your <html> that should be in the body!

<script type='text/javascript' src='/site/modules/FieldtypeMapMarker/MarkupGoogleMap.js'></script><div id='mgmap1' class='MarkupGoogleMap' style='width: 100%; height: 300px;'></div><script type='text/javascript'>if(typeof google === 'undefined' || typeof google.maps === 'undefined') { alert('MarkupGoogleMap Error: Please add the maps.googleapis.com script in your document head.'); } else { var mgmap1 = new MarkupGoogleMap(); mgmap1.setOption('zoom', 16); mgmap1.setOption('mapTypeId', google.maps.MapTypeId.ROADMAP); mgmap1.init('mgmap1', 51.606968, -0.552179); mgmap1.addMarker(51.606968, -0.552179, '/postcards/chalfont-st-peter/chalfont-st-peter-001/', 'csp-001-f', ''); }</script><!DOCTYPE html>
<html lang="en">
<head>
	<meta name="keywords" content="home improvement, home, improvement, improvements, plumbing, plumber, electrics, electrical, electric, tile, tiling, tiles, joiner, joinery, carpentry, door, doors, stair, stairs, wardrobe, wardrobes, cupboard, cupboards, kitchen, kitchens, bathroom, bathrooms, bedroom, bedrooms, chalfont st peter, buckinghamshire, UK, genealogy, family tree, family, history, tree, ancestor, relative, relation, postcard, postcards"> 
	<meta name="copyright" content="Worldwide, Simon and Thelma Dawson, 2015">
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<title>View over Chalfont St Peter</title>
	<meta name="description" content="" />
	<link href='http://fonts.googleapis.com/css?family=Raleway:500' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" type="text/css" href="/site/templates/styles/main.css" />
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script>
</head>

all before <!DOCTYPE html> has to be anywhere between <body> ... </body>

Link to comment
Share on other sites

I am really struggling as a beginner here.  I have the FieldtypeMapMarker mod installed and I've created a MapMarker field called location.  From a template called postcard.php (which has a sidebar and the location field) I have created a page.  I have filled in the details on the location section and can see the map and marker in edit view.  In the <head> section of _main.php I have added the line:

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

First question:  Why are the lat and long entries in the edit mode of my page to 15  decimal places?  Isn't that going to sl;ow up the database?

Second question:  If I now put the lines:

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

and nothing else into postcard.php all that code which BernhardB refers to above gets put at the beginning of the source code and not in the body.

Please will someone show me EXACTLY how to get the map to appear as the top item of the sidebar?

Thanks.

Link to comment
Share on other sites

I see '<script src="https://maps.gstatic.com/maps-api-v3/api/js/20/9/main.js"></script>'

In the body of your html after the map div.

Also you have meta tags in your body. This suggests that your template code is somehow messed up and things get loaded in the wrong order.

It would help if you could post your postcard.php and head.inc.

Sorry, have to go now. Can take a look again tomorrow.

Link to comment
Share on other sites

hey grumpy,

it seems you are using the default intermediate profile? you are mixing code in your map template php file and your _main.php file! thats some very basic PW stuff and not related to mapmarker, so i think it would be a good idea to start a new "general support" thread and stop messing this specific thread up (sorry) :)

as long as there is no extra thread, i'll try to help you here once more. have a look at this posting, thats the intermediate profile workflow: https://processwire.com/talk/topic/9690-sub-templates/?p=93247

so everything you echo in your map template will be placed BEFORE all the code in _main.php

to get something into the body of your _main.php you have 2 options:

1) create a whole new map template (i think you named it postcard.php) like this:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    ## your javascript here ##
</head>
<body>
    <?php
    ### render map here ###
    ?>
</body>
</html>

but that would remove all the other site elements that you already have on your website (menu, sidebar, search etc)

2) populate the $content variable with your map markup

postcard.php

$map = $modules->get('MarkupGoogleMap');
$content = $map->render($page, ## your div id here ##);

note its not echo ... but $content = ...

_main.php should look somehow like this

<!DOCTYPE html>
<html>
<head>
    <title></title>
    ## your javascript here ##
</head>
<body>
    <h1><?php echo $title ?></h1>

    <div>
        <?php
        echo $content;
        ?>
    </div>

</body>
</html>

so in the second case your map will be placed wherever you put your $content variable in your _main.php file. please take your time and read this thread carefully: https://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/

thats a lot of useful information and explanation of what's going on behind the scenes when you are using one file to handle all the markup.

especially this thread of ryan should help you: https://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/?p=6174

good luck :)

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