Advertisements

MkrGeo

An original point of view

GIS

Link management in Google MyMaps and KML files

Hyperlink in placemark description in Google Earth

A typical simple example of the hyperlink in placemark description.

Google MyMaps is a very useful tool for people, who want to create their own map and base it on the Google Maps interface. Personally, I use it quite often, especially when planning some journey or place some interesting objects across the World or some region. An important thing is to refer the stuff, prepared in our document to a particular location on the map and another way round. To link up some text or element in our document with the rough location on the map is not a difficult thing. On the contrary, making it in the reverse sequence may be sometimes quite tricky, especially when you don’t owe a basic software to help you with. However, in this article, I am going to show you roughly how it works from both sides. Let’s go then!

  1. LINK THE TEXT OR OBJECT TO THE MAP

In most of the software used for writing, calculations or drawing issues you have a hyperlink option. It obviously enables you to link up the text or particular object to the desired destination. In our case, this destination will be an interactive map created in Google MyMaps.
First of all, we should know what elements does the Google MyMaps link includes. Basically, there are 2 link sections, which should draw our attention if we want to set our location properly (Pic. 1). There are:
– coordinates section,
– zoom factor.

Google MyMaps location and zoom link elements

Pic. 1 The most important elements of the Google MyMap link with respect to location hyperlink.

Apart from these, there are another 3, which we should know only out of interests for our purpose (Pic.2): user page, map mode (viewer or editor) and map ID.

Google MyMaps link elements

Pic. 2 Google MyMap link elements, where: 1 – user path, 2 – map mode, 3 – map ID, 4 – coordinates, 5 – zoom factor.

When you start to drag your map a bit, you will see in the link path with the coordinates section changes instantly. The coordinates value refers to the middle point of your map.
We can use this quite long URL to hyperlink some stuff in your document. For example in MS Excel (Pic. 3,4). We must choose the “Link” option and input our URL address. Don’t worry if it’s longer than an input frame. It will work.

Insert Google MyMap hyperlink to the MS Excel

Pic. 3 Insert our Google MyMap hyperlink to the MS Excel single cell.

MS Excel link to Google MyMap

Pic. 4 Our cell in MS Excel has been already linked with Google MyMap. When you click on it, the link redirects you to the particular location on the map.

Once you hyperlink your document to the particular location on your map, it will be open in default browser in the future (Pic.5).

Insert Google MyMaps hyperlink to MS Excel

Pic. 5 Insert our Google MyMap hyperlink to the MS Excel single cell.

Unfortunately, the link doesn’t switch you to the object directly, so you must click on the placemark located in the middle, however in my point of view is a minor thing.
Using hyperlinks from documents to the Google MyMaps such this is a very convenient way to pop out on the proper location. Furthermore, if your map is public, then everyone who is sharing your document can take a glimpse on the location, also in the mobile version. This is for sure the easiest and the quickest way to hyperlink your work to the map, wherever the hyperlink option is available (MS Office, GIS software, AutoCAD, etc), also after saving the file in PDF version (Pic. 6).

MS Excel hyperlink to Google MyMap works in PDF version.

Pic. 6 An MS Excel hyperlink to the Google MyMap after saving the file in PDF format.

2. LINK THE TEXT OR OBJECT TO THE .KML FILE

Unlike to Google MyMaps, linking our work to a particular .kml file, a default format for Google Earth software can be a bit tricky task. Firstly, the difference lies in the file location. When linking to Google MyMaps you don’t need the tool to open it, except the internet browser, installed by default. The .kml file must have a Google Earth to being open. Otherwise, you won’t see the location, even when the hyperlink refers to some .kml file located on the server. However taking into account, that Google Earth is free software and widely common I can assume, that most of people interested in GIS, geography or tourism have this application on their computers.
Basically the hyperlink from some document to the .kml file is straightforward, likewise a link to the map described above. Here we’ve got an option to hyperlink our .kml stuff offline, directly from our disk (Pic. 6).

Hyperlink from MS Excel to kml file

Pic. 6 Hyperlink from MS Excel to the .kml file located on your HDD directory.

The only gripe is, that usually our .kml file includes more than one object (placemark) based in its directory. If you want to gain a rough location for your MS Excel cell or some object in your document (in my case it was one of the points of my honeymoon journey), then the easiest way will be an extraction of the object from the .kml file. You can do it in Google Earth. When load your main .kml file you must open its content and find a specific placemark, which you need (Pic. 7).

Google Earth browsing the .kml file directory and searching for a specific placemark.

Pic. 7 Opening a .kml file in Google Earth and looking for a specific placemark, where: 1 – dark triangle “open” option for .kml file content; 2 – a search engine for a particular placemark and other .kml files located in the directory.

Once we find our placemark (Pic 8), we can download it to our private directory after right click and next hyperlink it to our document.

Google Earth saving our placemark as a separate object in Google Earth

Pic. 8 Saving the specific placemark from our .kml file as a separate .kml object (placemark).

Hyperlink .kml placemark in MS Excel cell

Pic. 9 Hyperlinking our newly saved .kml specific placemark in MS Excel cell.

Afterwards, you will be redirected directly to the location in Google Earth (Pic. 10).

Clark International Airport (CRK) seen in Google Earth

Pic. 10 Redirection our MS Excel to the particular location in Google Earth – in this case, Clark International Airport (CRK).

An only demerit here is obviously the scale. Google Earth zoom after loading is set to a maximum value, which closes-up our object as much as possible. This is nothing bad, although sometimes we would like to get around the area and make sure, that we hyperlinked the right place. Unfortunately, the .kml files are not equipped with zoom factor at the XML code stage and only what you can do here is zooming out via Google Earth. Alternatively, you can start work with regions, where through the command you can the coordinate borders for your point as per below (Pic. 11, 12).

A placemark position in KML file, when open an XML code

KML file shown in XML language work with regions

Pic. 11,12 Elements consisting on your .kml file shown in XML language with sections to be modified in order to final object appearance in Google Earth software, where: red box – shows your placemark location; green box – shows your region placemark location (with similar coordinates), which must be added below.

After these small alterations of your .kml file you can save it and open in Google Earth again (Pic. 13).

.kml file shown as a region in Google Earth

Pic. 13 Your placemark is shown in Google Earth with an optimal enlargement.

So great! You have got your placemark with an optional enlargement, where you can instantly make sure, that surrounding area is correct. However there is still one issue, which can annoy a user a bit. This is obviously a thin gray rectangle, that frames our region selected previously in XML code. To get rid of it we can simply thick off this element in our .kml file directory at sideline toolbar (Pic. 14).

KML placemark in Google Earth with optional zoom

Pic. 14 Our placemark with optional zoom and, what the most important, without framed region visible.

Remember, that this solution refers only to the situation, when your file comes from the computer directory. I believe, that more often nowadays the .kml files are based on the web, i.e in Google Spreadsheet. There you can also link your document to the specified placemark included in a whole .kml directory (Google Spreadsheet mapping), which was explained in details here.
You can also set your zoom level only in situation, when your .kml file is based on the web. In case for example, the Google spreadsheet the process has been described in details here. Another option is to set your own map based on Google Maps Javascript API, what is explained roughly here. Frankly speaking, the XML option is an alternative for someone, who is not clued up enough with the programming skills. Truth to be told more stuff and advises is available for the Google Maps JavaScript API, which I explain in the future.

3. LINK THE GOOGLE MYMAPS OBJECT TO THE DOCUMENT

Link some object (placemark) created in GoogleMyMaps is unfortunately, a tricky issue. First of all, GoogleMyMaps doesn’t support a hyperlink directly from the interface neither for point nor for linear objects (Pic. 15). Using at least a different interactive map builder will be beneficial if you don’t want to fight with XML code.

Google MyMaps linear object Anda Bohol

Pic. 15 An linear object example in Google MyMaps

The best for this purpose I believe is the Scribble Maps interactive map builder, being widely common between another dozen or so similar platforms. If you wish to have all placemarks linked, then you must generate the .kml file from your Google MyMap (or some single layer, when applicable)(Pic. 16, 17) and save it somewhere in your directory (Pic. 18).

Google MyMaps selecting layer to download as a .kml file

Google MyMaps layr download

Pic. 16, 17 Selecting a single layer from Google MyMaps to download as a .kml file.

Saving .kml file from Google MyMaps

Pic. 18 Saving your .kml file, created in Google MyMaps.

After this, you should import your file into new Scribble Map, which will open automatically after loading (remember to drag to your placemark locations!). At first glance, your placemark group won’t look fine. This is because the Scribble Maps doesn’t support icons from Google MyMaps (Pic. 19), although don’t worry about it, because when you do the saving and uploading in reverse sequence, then you retrieve all icons in Google MyMaps again.

Manila journey imported as an .kml file to ScribbleMaps

Pic. 19 Imported .kml file into ScribbleMaps interactive map builder won’t look good due to lack of icon support.

Having your .kml embedded in the Scribble Map interactive builder you can start to edit every single placemark, adding a link into the description.
On the new, single example I will show you how to do it effectively.

Well, I have created a single placemark, which is called a Lacher See (a volcanic lake in West Germany). Now, after open its editor I have a few options to input a link i.e pictures, Youtube, etc. For us, the most important is an anchor-looking signature (Pic. 20) called “Add link”.

Link in Scribble Maps interactive map builder

Pic. 20 An “Add link” option in the Scribble Maps platform.

Let’s input some random URL path, let that be some informative website about this place, which for instance the Wikipedia is. Obviously, don’t forget to set an “Open in new window” option (Pic. 21).

URL link in Scribble Maps placemark

Pic. 21 Input an URL link in Scribble Maps placemark.

We can add up more, than 1 link to a specified website, attaching for example a restaurant and hotel nearby (Pic. 22).

Input a multiple links in Scribble Maps placemark

Pic. 22 Input multiple links in Scribble Maps placemark.

Apart from a link only, you can embed both Youtube movie or picture (Pic. 23). Think over adding a picture as a link through the Scribble Map, because this builder requires the URL to the picture (Pic. 25), which not always work (Pic. 26). It will be better to fill up in Google MyMaps later (Pic. 27), alternatively, your picture has been already attached before you made a .kml file.

Scribble Maps link from Youtube

Pic. 23 Adding a Youtube stuff to your placemark in Scribble Maps.

Both your Youtube and image file either in Google MyMaps or Scribble Maps should be loaded automatically, showing you a graph miniature inside the placemark description (Pic. 24). Then you can be sure, that everything is fine with your link.

Youtube miniature inside placemark in Scribble Maps

Pic.24 A Youtube miniature shown in your placemark description in Scribble Maps.

Adding picture in Scribble Maps

Pic. 25 Adding a picture to the placemark in Scribble Maps.

Scribble Maps image issue in Google Earth.

Pic. 26 An error with an image as occurs sometimes in Scribble Maps will result in a question mark in your placemark description in Google Earth.

Returning to the images issue and their disappearance in Google Earth, we can use a Google MyMaps to check if our link is supported by GoogleUserContent at all. If so, you should have a graph loaded, if not, then you receive info like this (Pic. 27).

URL image error Google MyMaps

Pic. 27 An image URL error, which can occur when input image from the Web to GoogleMyMaps.

In general, links like Flickr or Wikimedia are not supported. In this case, better is to download your picture first to the computer and then upload to GoogleMyMaps from your drive.

When you add up everything, then you can generate a .kml file in Scribble Maps, download it, and upload to Google MyMaps. A basic demerit is, that every single .kml file in Google MyMaps is treated as a separate layer, which really restricts our work there because Google MyMaps provides 8 layers only. At the outcome, you are able to import an 8 single .kml files only. Much better is, when your .kml file includes all placemarks, that you need, unlike to my example provided.
Anyway, the link should be clearly visible in your Google MyMap now (Pic. 28-30).

Linked placemark in Google MyMaps

Linked placemark in Google MyMaps with picture attached

Pic. 28 – 30 Linked placemark in Google MyMaps with; 28 – Youtube movie attached; 29 – Youtube movie + image attached; 30 – all links created in Scribble Maps.

As you may have noticed, the hyperlinks are available, however, did we really want them in a form such that? We would rather have the main text hyperlinked instead of having these long hypertexts underneath.
So we can somewhat do this in Scribble Maps. However, we cannot write the text outside our link, because it won’t work. We cannot also select our text and mar as a hyperlink. One thing, that we can do is start writing our text inside the existing hyperlink (Pic. 31) and remove not needed pieces as shown below.

Manual link edition for placemark in Scribble Maps

Pic. 31 A placemark manual link edition in Scribble Maps.

Ok, when you prepare your hyperlinked text, then save your placemark, create the .kml file and import it to Google MyMaps. Unfortunately, the Google MyMaps doesn’t support solution like this, although your information will still look better, than previously (Pic. 32).

Google MyMaps hyperlink after edition in Scribble Maps.

Pic. 32 Hyperlink in Google MyMaps after manual edition in Scribble Maps.

In the result of manual hyperlink edition in Scribble Maps, you should get a solution in Google MyMaps as above. Your text won’t be linked, as you would like, although the form with bracketed link path can be accepted in general.

At the finish of the link issues in Google MyMaps, I would like to show link options supported by this platform (Pic. 33).

Google MyMaps links

Pic. 33 Link options supported by Google MyMaps platform.

Fortunately, Google Earth reads our hyperlink properly (Pic. 34).

linked text in .kml file in Google Earth

Pic. 34 Linked text in .kml file shown in Google Earth.

4. LINK THE .KML FILE TO THE DOCUMENT

Another important element is a link the .kml file, placed in Google Earth to the document. A basic placemark with one or more hyperlinks looks as per in the picture above (Pic. 34), where you can see linked information inside the description. These links can redirect both to URL’s and to some particular documents, placed on your hard drive.
If we would consider taking a look on our link structure in XML code, then it could look like this (Pic. 35).

KML file hyperlink in XML language

Pic. 35 A hyperlink for .kml file as shown in XML language, where: 1 – ![CDATA[…]] – the most important element, enabling you to input some HTML/CSS stuff inside the brackets; 2 – The HTML code with link, open way and short description. Click to enlarge.

The most important is the ![CDATA[…]] command, which enables us to input an HTML or CSS code inside. Then we can both create a link to some document or URL, directly from .kml file or styling the .kml description, which will be discussed in the future.

ML file with links to Youtube, text and image

Pic. 36 All links (Youtube, text and image) included in our placemark as shown in XML code.

The picture above shows us all the links used by myself for the purpose of this article (red frame). This is a simple HTML code with content and tags, dividing our description correctly. As you could spot, you have another placemark included in your .kml file with similar ([CDATA![…]]) description, as shown underneath (yellow frame). In Google Earth, our file will look as per in the picture below (Pic. 37).

Placemark with all links shown in Google Earth.

Pic. 37 Our .kml file with all links as shown on Google Earth.

Now we have got everything, what we need: Youtube link, text link, and image link. Remember, that there are some troubleshoots with image links in Scribble Maps, which has been mentioned earlier. Frankly speaking, some image URL links are not supported in that interactive image builder and better is input them manually in the XML code, as above (Pic. 36, 37).

Our .kml file may include also linear objects along with placemarks. However in this case we cannot rely on Scribble Maps at all, because this interactive platform features the text and link editor for point objects only. As far as we know, the description of the linear object is also possible, at least in Google MyMaps platform (Pic, 15), which unfortunately doesn’t support text link editor.
In this case, we must resort to the XML code again and implement the object features manually (Pic. 38).

Placemark XML code with hyperlink

Pic. 38 The XML code of linear placemark with a relevant description with hyperlink. Click to enlarge.

Afterwards, we can see a nice effect in Google Earth (Pic. 38).

Linked linear object show in Google Earth, Youtube and image

Pic. 39 A linked linear .kml object shown in Google Earth. Here are 3 kinds of link: text, image and Youtube.

Probably you spotted, that I input something special to this code. I decided to spice it up a bit and bring some CSS style codes inside in order to change the hyperlink text from thin blue to a strong red. This stuff will be better explained in a separate article in the future.

An analogous work should be done for some path or trail, which is also a linear object (Pic. 40, 41).

KML linear object with description

Pic. 40 An XML code for the linear object in .kml file with a relevant description including some external links. Click to enlarge.

KML file example path in Google Earth

Pic. 41 An example path with links and description shown in Google Earth.

I hope, that all this information will be helpful for you. As you have seen, the link management in .kml files can work in two different ways. One of them is interactive map builders, which are the easiest and the quickest way to manipulate. However in some cases, using the XML code in external software, like Notepad++ can be also required. It obviously doesn’t change the fact, that the link management in all .kml files is a relatively simple issue.
Another kind of links, which can be used in .kml files are network links. Network links play an important role when you would like to make your placemark more dynamic. It means, that you can input links straight to another .kml file, placed somewhere in the server i.e Dropbox and keep your placemark content most up-to-date. Moreover by network links you can include large datasets into your .kml file More about effective using of the network links you can read in this documentation or watch the video below.

Mariusz Krukar

 

References:

1. Gibson R., Erle S., 2006, Google Maps Hacks, O’Reilly Media Inc, North Sebastopol, CA

Links:

  1. Google Earth outreach: Mapping from a Google spreadsheet
  2. https://gokml.net/
  3. Keyhole Markup Language standard
  4. KML 2.1 tutorial
  5. KML reference
  6. XML managing data exchange – Google Earth
  7. Customize maps with JavaScript API
  8. Using Google Sites to host your KML
  9. Adding images to a Google Earth placemark
  10. Using .kml network links effectively

Forums:

  1. Hyperlinking placemarks within a KML file
  2. Opening a kml file with Google Earth at a specific placemark
  3. Network Linked KML to a Folder of KMLs
  4. How do I link to internal files in a KMZ file?
  5. Creating Links to PDF’s of boring logs in Google Earth
  6. Set zoom after loading KML layer
  7. Setting zoom level in KML/KMZ file?
  8. Working HREF inks in KML files stop working when zipped into a KMZ files
  9. Google Maps zoom gets overridden, when using a KML file

 

Youtube:

 

Advertisements

Theme by Anders Norén

Follow

Get the latest posts delivered to your mailbox:

%d bloggers like this: