Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Google Maps API to an open source alternative #20

Closed
TGRHavoc opened this issue Sep 15, 2018 · 15 comments
Closed

Migrate from Google Maps API to an open source alternative #20

TGRHavoc opened this issue Sep 15, 2018 · 15 comments

Comments

@TGRHavoc
Copy link
Owner

As of right now, the map is usable but certain features are disabled due to Google's crack down on keyless use of their APIs.

So, instead of making people (potentially) pay money to Google just to use the map, I want to migrate to a (preferably) open source alternative.

I've had a look around and at the moment, OpenLayers seems like the best alternative.

@TGRHavoc TGRHavoc added this to the v3 - Interface Overhaul milestone Sep 15, 2018
@JasonO99
Copy link

https://leafletjs.com/

Is this any good or not quite the thing you're looking for?

@davwheat
Copy link

davwheat commented Nov 17, 2018 via email

@JasonO99
Copy link

It has an option where you can use a single mapping image, avoids having to create tiles. For the simplicity of a 2d map that's probably good enough. You can then set your own coordinate range from corner to corner. All that in about 2 lines.

@davwheat
Copy link

davwheat commented Nov 17, 2018 via email

@matsn0w
Copy link
Contributor

matsn0w commented Nov 17, 2018

@davwheat tested an 2K pic which loaded quite good, so it will probably be fine

@davwheat
Copy link

davwheat commented Nov 17, 2018 via email

@JasonO99
Copy link

It's worth noting the tile option is still available too, should that be preferred.

@TGRHavoc
Copy link
Owner Author

Is this any good or not quite the thing you're looking for?

Hmmm... I'll have a look at this as well. Nice find.

It has an option where you can use a single mapping image, avoids having to create tiles

The plan was to just export GTA's map images and use them for the images which, would result in like 4 tiles instead of the however many there currently is. If we could make that into a single image and use that instead (think in total it would be 1024x1024 pixels) it would be the best of both worlds, easy exporting for custom maps such as the "postal" map and/or whatever other creations people have.

Mind you, OpenMaps has this as well so I would have to do a comparison of the two libraries to see which one best fits the resource (leaflet seems to be the better options ATM due to small size and easy integration, you mentioned two lines to get it working?)

That makes it waaay more simple! The issue is, do you go for a very high resolution image which might take a long time to load or a low resolution image that will load faster but look worse.

Well, the browser cache would hopefully help with that. If not, maybe we could implement a caching system with local storage or something so, it would only have to load the image once.

@JasonO99
Copy link

Regarding 2 lines. I fibbed - but it's no more than 5 for basic custom, single image, map layer.

var map = L.map('map', {
    crs: L.CRS.Simple
});
var bounds = [[0,0], [1000,1000]];
var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
map.fitBounds(bounds);

Source: https://leafletjs.com/examples/crs-simple/crs-simple.html

@davwheat
Copy link

davwheat commented Nov 17, 2018 via email

@TGRHavoc
Copy link
Owner Author

Ok guys. I've been working on it a bit in my spare time and I've managed to get Leaflet.js to work.

So. We can either stay with the ungodly amount of images we currently have, and have zooming. Or, we can replace it with fewer images (at a higher resolution, like 1024x1024 each) and sacrifice the zooming feature?

I'm for one am happy just using the fewer images. It allows people to use the postal map (or whatever other map they choose) with real ease. They get the PNGs, pop it into a folder and add it to an array,
Example of the array:

    var map_tiles = {
        "Normal" : L.tileLayer("images/tiles/normal/minimap_sea_{y}_{x}.png", {maxNativeZoom: 0}), //Originally had the "tileSize" attribute set. Removing it allows for the "zoomed out" look
        "Postal" : L.tileLayer("images/tiles/postal/minimap_sea_{y}_{x}.png", {maxNativeZoom: 0})
    };

Actually. Doesn't matter. Whilst writing this, I found the solution to the zoom problem.

I will be committing the changes to the development branch soon:tm:. In the mean time, the video below is what you can expect the map to look like in future,

https://tgrhavoc.me/fuck_you/tit_wank/livemap_update_2.mp4

@matsn0w
Copy link
Contributor

matsn0w commented Jan 14, 2019

Awesome!

@davwheat
Copy link

image

How pleasant.

@TGRHavoc TGRHavoc mentioned this issue Jan 16, 2019
@Starystars67
Copy link

Nice work sir! Glad to see this is not a dead project!

TGRHavoc added a commit that referenced this issue Jan 27, 2019
Hopefully this makes the map fully working with the new framework.

I still want to do a bunch of cleaning up. Make sure there's no left over code. And it should be good to deploy.
@TGRHavoc
Copy link
Owner Author

Guys, if you want to test the new framework and stuff before I release it to everyone (want to get the other features done first) then, I'd check out the development branch. The new map should be working as of 163a39a.

The new tile image location are hard-coded into js/src/map.js (lines 24 and 25) at the minute. That will change in the future, and use the config's location.

The images can be extracted by yourselves. Just extract the PNG files from the YTD files inside GTA with OpenIV. Or, extract them from the YTD files for the custom maps. I highly suggest you use the minimap_sea files as they're a higher resolution than the normal minimap files.

If you're too lazy to extract yourself, I have a ZIP file containing the images used in the previous comment. It's attached to this comment as "tiles.zip".

tiles.zip

@TGRHavoc TGRHavoc closed this as completed Feb 8, 2019
TGRHavoc added a commit that referenced this issue May 17, 2019
Hopefully this makes the map fully working with the new framework.

I still want to do a bunch of cleaning up. Make sure there's no left over code. And it should be good to deploy.

closes #20
TGRHavoc added a commit that referenced this issue Jul 28, 2021
Hopefully this makes the map fully working with the new framework.

I still want to do a bunch of cleaning up. Make sure there's no left over code. And it should be good to deploy.

closes #20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants