Jump to content
Gianluca73

google maps con più tappe

Recommended Posts

Gianluca73

Ciao a tutti, sapete come inserire mappe google con più tappe? Se aggiungo itinerari e poi condivido la mappa in un post prende solo il primo itinerario. Ad esempio Genova Spezia e Ritorno prende solo Genova Spezia  

grazie

Gianluca

Share this post


Link to post
Share on other sites
BomAle

Sembra che allo stato attuale legga solo la partenza e la prima coordinata

if ( preg_match( '/^https:\/\/[a-z]+?\.?google(' . implode( '|', array_map( 'preg_quote', $googleTLDs ) ) . ')\/maps\/(.+)/i', (string) $url, $matches ) )
{
	/* Extract the address and gps coordinates from the query string */
	$qbits = explode( "/", $matches[2] );
	switch ( $qbits[0] )
	{
		case 'place':
			/* This seems odd but sometimes the place names can already be url encoded and we don't want to double encode */
			return \IPS\Theme::i()->getTemplate( 'embed', 'core', 'global' )->googleMaps( urlencode( urldecode( $qbits[1] ) ), 'place' );
			break;
		case 'dir':
			$params = array( 'origin' => $qbits[1], 'destination' => $qbits[2] );
			return \IPS\Theme::i()->getTemplate( 'embed', 'core', 'global' )->googleMaps( $params, 'dir' );
			break;
		case 'search':
			return \IPS\Theme::i()->getTemplate( 'embed', 'core', 'global' )->googleMaps( urlencode( urldecode( $qbits[1] ) ), 'search' );
			break;
		default:
			$params = explode( ",", mb_substr( $qbits[0], 1, -1 ) );
			$coordinates = implode( "," , array( $params[0], $params[1]) );
			return  \IPS\Theme::i()->getTemplate( 'embed', 'core', 'global' )->googleMaps( $coordinates, 'coordinates', $params[2] );
			break;
	}
}

vedi la parte "dir"

bisogna segnalarlo se non già fatto notare

http://sandbox.onlinephpfunctions.com/code/62831dd715d684d16d5be3fd34a46568f503da5f

array(2) {
  ["origin"]=>
  string(20) "45.5237975,9.2441023"
  ["destination"]=>
  string(20) "45.5315843,9.2406691"
}
array(6) {
  [0]=>
  string(3) "dir"
  [1]=>
  string(20) "45.5237975,9.2441023"
  [2]=>
  string(20) "45.5315843,9.2406691"
  [3]=>
  string(20) "45.5317054,9.2683204"
  [4]=>
  string(25) "@45.5285048,9.2371835,14z"
  [5]=>
  string(31) "data=!3m1!4b1!4m2!4m1!3e2?hl=it"
}

 

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.

Loading...

×
×
  • Crea Nuovo...

Important Information

By using this site, you agree to our Terms of Use.