Some time ago i made a couple of posts in the forum concerning images.
I wanted to display google maps whithin navision. Downloading them on the fly.
This has proven to be quite difficult. First of al, navision cannot import an image from an URL, only from local drives. Next problem was that that the google maps images are PNG's while navision only imports BMP's.
And navision requires a fixed DPI resolution setting.
After that i also wanted to do some image processing to stitch different map parts together.
And i found an nice versatile solution, which i wanted to share.
I accomplished it using ImageMagick. It's a free opensource package with a lot of possibilities, such as conversion between image formats, image resizing, image editing, overlays and much more.
All the utilities in the package are commandline utilities. Therefore you can run everything from navision using the shell command (or a 'Windows Script Host Object Model'.WshShell automation object if you don't want to display a dos-box).
This way i got a nice map in navision.
Screenshot of Map utility
The possibilities are numerous, because you can also create images using this library, making it possible to create graphs for example, or you can use it to store png or jpegs and load them on the fly, reducing disk usage.
Comments
And i could post the code once i'm finished.
Google Maps - Show in Map / Show Route
http://www.mibuso.com/forum/viewtopic.php?t=17225
http://www.BiloBeauty.com
http://www.autismspeaks.org
Is it possible to post your example with PM? As you can see in the posted link from Savatage that i am interested in this integration too.
Thank you.
I missed your question in March, but better late than never i guess
The code is quite messy/ written for a specific purpose and i do not have a generic map form, so i will just try to explain what you have to do.
First thing to know is that you can access google map tiles using an unique URL for each tile
An URL could be:
http://mt1.google.com/mt?n=404&x=329&y=792&zoom=6
The important things to see here is that you have an X coordinate, and an Y coordinate (or tile number) and a zoom level.
With
http://mt1.google.com/mt?n=404&x=0&y=0&zoom=17
You get a map of the entire world
By lowering the zoom, you get a more closeup-view of the earth. At zoom level 16 there are 4 tiles to cover the entire earth.
At zoom lever 15 there are 16 tiles
etcetera etcetera... (Each tile is split up into 4 tiles at the next level)
To instantly calculate the x and y coordinate for a position given it's GPS coordinates, you have to do some simple calculations. You should note that google uses a mercator projection, and looking that up on wikipedia should give you the required formula's.
A small but important snippet of code is the following:
This basically gives you the x and y's given the GPS coordinates and a zoom level.
If you want to have a satellite image, you need a different URL. The idea is basically the same, but instead of X and Y coordinates, it uses a string of letters (qtrs).
You can use this to convert the X and Y numbers to this string of letters:
The resulting string should be appended to:
http://kh.google.com/kh?v=3&t=
Creating somthing like:
http://kh.google.com/kh?v=3&t=tqst
Where the zoom level is defined by the number of characters in the string.
After getting the URL, you need to download it to your PC, and since 1 tile is a bit small, i decided to stitch 9 tiles together.
And after that it has to be coverted to the BMP file format.
The solution for that is to use the opensource Imagick library.
Is consists of a couple of very useful commandline utilities, that can, amongs many other things, do exactly what we want.
You can put the commands in a Batch script file, or use multiple SHELL calls.
I won't explain this in too much detail because:
1. Imagick is quite easy to learn, and there are many examples on the website.
2. I use an outdated version with slightly different syntax.
****Important note
Use the following parameters
"-units" "PixelsPerInch" "-density" "96x96"
because this will make Navision use the correct size
(Navision uses actual size (such as mm or inch) instead of pixel sizes, so this will make sure it is displayed properly)
But there is still room for improvement:
1. Crop the image (use more tiles, and cut a bit of at the edges)
This will center the map at the given GPS position. (Otherwise the center is somewhere in the middle image)
2. Use a cache. Google bans users which request to many images
****Important note
this is al reverse engineerd, so i don't know what googles view on this is,
but i guess that if you want to make very heavy or commercial use of it, you should just buy Mappoint. In all cases: i am not responsible, and you should consult the google maps policy.
3. put icons on top of you map.
Maybe this will help:
4. Use 'Windows Script Host Object Model'.WshShell to hide the popup
Finally it is important to know that it won't plot routes.
And a final note is that the string contains a version number which might be subject to change, just like rest of the URL. Thus altough it has not changed for quite some time, you should never use it for a critical buissness process.
Just trying to read that has given me an Idea for that Feature Request post
http://www.BiloBeauty.com
http://www.autismspeaks.org
How did you get the images to your PC? Is it necessary to open your browser?
The coordinates are from Stuttgart Germany, but the tile I get are anywhere in the ocean.
Regards
Lichtens[/code]
I use the 'convert' command from the ImageMagick library. This command can take URL's as parameters, so no browser is required.
Not the calculation is wrong, but the coordinates are. If you want to get a tile near stuttgard, your Longitude should be positive (+9.6 instead of -9.6)
To get coordinates for certain locations, or vice versa, i used the following website. It is in dutch, but it might still be useful:
http://www.gpscoordinaten.nl/bepaal-gps-coordinaten.php
i want to import an image from url eg: url eg:--> abcd.com/.../test3.png into into NAV 6sp1
Thanks