Skip to main content
deleted 531 characters in body
Source Link
Rod
  • 3.3k
  • 2
  • 25
  • 41

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala"CityData["Sao Paulo", "Coordinates"]"Coordinates"];
c2 = CityData["Marsta"CityData["Rio de Janeiro", "Coordinates"]"Coordinates"];

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/22;

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

g1=Import["httpImport["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"center=" <>ToString[center[[1]]] <> "," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]<> ToString[center[[2]]] <> "&zoom=6&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...enter image description here

EDITED

After some research, I think it can also be done:

Define the cities:

from = ToString[c1[[1]]] <> "," <> ToString[c1[[2]]];
to = ToString[c2[[1]]] <> "," <> ToString[c2[[2]]];

Now use Mathematica to import data from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"35.3"429 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"30 mins"

EDITED

Now put everything together.

First define graphic with markers...

Import["http://maps.google.com/maps/api/staticmap?center=" <>ToString[center[[1]]] <> "," <> ToString[center[[2]]] <> "&zoom=10&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

and

{roadDistance,travelTime}

{"35.3 km","30"4 hours 44 mins"}

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

g1=Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = ToString[c1[[1]]] <> "," <> ToString[c1[[2]]];
to = ToString[c2[[1]]] <> "," <> ToString[c2[[2]]];

Now use Mathematica to import data from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"35.3 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"30 mins"

EDITED

Now put everything together.

First define graphic with markers...

Import["http://maps.google.com/maps/api/staticmap?center=" <>ToString[center[[1]]] <> "," <> ToString[center[[2]]] <> "&zoom=10&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

and

{roadDistance,travelTime}

{"35.3 km","30 mins"}

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Sao Paulo", "Coordinates"];
c2 = CityData["Rio de Janeiro", "Coordinates"];

Second step: define the center of the map:

center = (c1 + c2)/2;

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["http://maps.google.com/maps/api/staticmap?center=" <>ToString[center[[1]]] <> "," <> ToString[center[[2]]] <> "&zoom=6&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

EDITED

After some research, I think it can also be done:

Define the cities:

from = ToString[c1[[1]]] <> "," <> ToString[c1[[2]]];
to = ToString[c2[[1]]] <> "," <> ToString[c2[[2]]];

Now use Mathematica to import data from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"429 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"4 hours 44 mins"

added 618 characters in body
Source Link
Rod
  • 3.3k
  • 2
  • 25
  • 41

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["httpg1=Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = "Uppsala";ToString[c1[[1]]] <> "," <> ToString[c1[[2]]];
to = "Marsta";ToString[c2[[1]]] <> "," <> ToString[c2[[2]]];

Now use Mathematica to import datdata from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"34"35.43 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"29"30 mins"

EDITED

Now put everything together.

First define graphic with markers...

Import["http://maps.google.com/maps/api/staticmap?center=" <>ToString[center[[1]]] <> "," <> ToString[center[[2]]] <> "&zoom=10&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

and

{roadDistance,travelTime}

{"35.3 km","30 mins"}

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = "Uppsala";
to = "Marsta";

Now use Mathematica to import dat from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"34.4 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"29 mins"

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

g1=Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = ToString[c1[[1]]] <> "," <> ToString[c1[[2]]];
to = ToString[c2[[1]]] <> "," <> ToString[c2[[2]]];

Now use Mathematica to import data from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"35.3 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"30 mins"

EDITED

Now put everything together.

First define graphic with markers...

Import["http://maps.google.com/maps/api/staticmap?center=" <>ToString[center[[1]]] <> "," <> ToString[center[[2]]] <> "&zoom=10&size=400x400&sensor=false&maptype=roadmap&markers=color:blue%7Clabel:O%7C" <> ToString[c1[[1]]] <> "," <> ToString[c1[[2]]] <>"&markers=color:red%7Clabel:D%7C" <> ToString[c2[[1]]] <> "," <> ToString[c2[[2]]]]

enter image description here

and

{roadDistance,travelTime}

{"35.3 km","30 mins"}

added 618 characters in body
Source Link
Rod
  • 3.3k
  • 2
  • 25
  • 41

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = "Uppsala";
to = "Marsta";

Now use Mathematica to import dat from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"34.4 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"29 mins"

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

This is only an attempt to answer the question, if I understood it correctly. You want to "cover the actual road connection between cities (...) based on the GoogleMap".

First step: find the coordinates of the two cities you want to use as edges in your graphic:

c1 = CityData["Uppsala", "Coordinates"]
c2 = CityData["Marsta", "Coordinates"]

{59.86, 17.64}

{59.63, 17.84}

Second step: define the center of the map:

center = (c1 + c2)/2

{59.745, 17.74}

Third step: Import[] the actual Google Maps image based on the center you've specified

Import["http://maps.google.com/maps/api/staticmap?center="<>ToString[center[[1]]]<>"," <>ToString[center[[2]]]<>"&zoom=10&size=400x400&sensor=false&maptype=roadmap"]

enter image description here

I'm still wondering what exactly you want with "set the calculated distance as EdgeCost value of created edge"...

EDITED

After some research, I think it can also be done:

Define the cities:

from = "Uppsala";
to = "Marsta";

Now use Mathematica to import dat from Google with distance and time:

distdata = Import["http://maps.googleapis.com/maps/api/directions/json?origin=" <> from <> "&destination=" <> to <> "&region=es&sensor=false", {"HTML", "Source"}];

Now find distance by road:

roadDistance = StringSplit[StringSplit[distdata, ":"][[13]],","][[1]]

"34.4 km"

Now find travel time:

travelTime = StringSplit[StringSplit[distdata, ":"][[16]], ","][[1]]

"29 mins"

Source Link
Rod
  • 3.3k
  • 2
  • 25
  • 41
Loading