Adjust Scale to Less than 1 in JVectorMap

I am in the process of developing a website that includes a full-size map using JVectorMap. The map currently occupies 100% of the width and height of the page, but I would like to add a border around it when fully zoomed out. However, when the map is zoomed in, I still want it to extend to the edge of the page. In essence, I need the initial view of the map to be more zoomed out than the default setting.

Unfortunately, traditional HTML borders and padding won't work for this scenario because they maintain the border even when the map is zoomed in. The only solution I could think of was adjusting the 'scale' variable in the code snippet below to a value less than zero:

<script>
    $(function(){
        $('#map').vectorMap({
            map: 'world_mill',
            focusOn: {
                x: 0.5,
                y: 0.5,
                scale: 0.8
            }
        });
    });
</script>

However, changing the 'scale' value to anything below 1 didn't have any effect as it appeared to be disregarded. To better illustrate the issue, I've attached screenshots below.

Current Page (Full-Size Map) https://i.sstatic.net/lhgTl.png

Desired Page (Map with Border) https://i.sstatic.net/QaV1w.png

Any assistance on how to achieve this desired outcome would be greatly appreciated!

Answer №1

For those who may come across this query in the future, I have decided to share my own solution. It appears that the function setScale is limited to adjusting the zoom within the range specified by the zoomMin and zoomMax parameters. By lowering the zoomMin value to 0.9, I was able to successfully utilize setScale to set the zoom level to 0.9.

As a result, the final code snippet I utilized looks like:

$(function(){
    $('#map').vectorMap({
        map: 'world_mill',
        zoomMin: 0.9,
        focusOn: {
            x: 0.5,
            y: 0.5,
            scale: 0.9
        },
    });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using border-spacing on table body rows exclusively

In my table, I have 2 header rows and multiple body rows. To create a spacing of 10 pixels between body rows, I used the following CSS: border-collapse: separate; border-spacing: 10px; However, this also affected the spacing in the header rows, which I w ...

Creating a hierarchical JSON structure using a database query in JavaScript

Currently, I am in the process of building a nested JSON object by parsing a query string obtained from an SQL database. This constructed JSON object will then be utilized by Angular to display data in the user interface using angular2-query-builder. The ...

Overwriting Resolved Data in Angular UI-Router Child States

I'm facing an issue where the resolve function is the same in both parent and child states, but I need it to return different values based on the child state. Instead of customizing the implementation for each state, it seems to be inheriting the beha ...

Converting an array of arrays to an array of objects in a React application

I have an array of arrays as follows: const arrayOfArrays = [ ['Lettuce', 60], ['Apple', 80] ]; What is the best way to transform it into an array of objects with keys for name and price, like this: const arrayOfObjects = [ {name: ...

Can Node.js handle parsing this as JSON?

Attempting to parse a small API that returns somewhat invalid JSON. Trying the following approach: var request = require('request'), url = 'urlhere'; request({ url: url }, function(error, response, body) { ...

What is the best way to trigger a localstorage change event using Vue.js?

I'm currently facing an issue with my Vue app related to updating user information stored in localStorage. I've implemented a solution using websockets in App.vue within the mounted function, as shown below: window.Echo.channel("user." ...

Angular 2 with a jssor slider that adjusts seamlessly to different screen

After following the guidance provided in this answer on incorporating jssor into angular2, I have implemented the following JavaScript code snippet in a file and referenced it in angular-cli.json. jssor_1_slider_init = function() { var jssor_1_op ...

What is the best way to swap out elements in my string with those from an array?

Struggling to replace special characters in file names before saving them to the Windows filesystem due to compatibility issues. For my initial approach, I used the replace() method repeatedly on the string to replace specific special characters. Here&apo ...

Is there a way to achieve a XNOR-like response with necessary input?

I'm currently working with a form that looks like this: <form> <input type="text" name="input1"> <input type="text" name="input2"> <button type="submit"> ...

Encountering Error with NodeJS Typescript: Issue with loading ES Module when running sls offline command

I have come up with a unique solution using NodeJS, Typescript, and Serverless framework to build AWS Lambdas. To debug it locally in VS Code, I use the serverless-offline library/plugin. You can find my project on GitHub here However, when I run the comm ...

Unable to delete borders within the container

Is there a way to eliminate the borders within this container? Visit this link for reference. I've tried using firebug but I can't seem to locate it... Appreciate any assistance you can provide. Thank you! ...

Tips for parsing JSON using JavaScript

I am looking to iterate through a JSON object that looks like {"key1":"val1","key2":"val2","key3":"val3"} in a loop. Here is my attempt: var inobj = '[{"key1":"val1","key2":"val2","key3":"val3"}]'; var obj = eval(inobj); for (var i = 0; i ...

Determining the location of the hamburger item on the bar

As I work on creating a hamburger icon, I am faced with the challenge of accurately positioning the bars without guessing. The height of the hamburger is 24px, and I initially thought placing the middle bar at half the height (12px or top: 12px) would cent ...

How can I transform each word to resemble this format?

let sentence = "Hello+world + like+ this + name,bla"; sentence = sentence.replace(/\+\s\+/g, function(match){ return "*" + match.trim() + "*"; }); alert(sentence); // Output will be " *Hello*+*world*+like*+this*+name,*bla* "; How can I ...

What steps can be taken to properly display dateTime values in a data table when working with JavaScript (VueJS) and PHP (Laravel)?

I am facing an issue where I am unable to save user inputted date-time values from a modal into a data table. Despite receiving a success message, the dateTime values are not being added to the table. My payload only displays the state and approval fields ...

Using CSS styles in emails can lead to an unexpected horizontal scrolling effect

I am currently working on an application using Symfony, and I have implemented a basic confirmation email with minimal CSS styling. However, the email template is causing horizontal scrolling due to the layout. Below is the HTML code of my email template: ...

A guide on dynamically populating a dropdown menu based on the selected value from another dropdown menu using

Below are a few drop-down lists displayed, each based on the selection made in the previous drop-down list. Despite trying to retrieve the current drop-down value using a specific keyword, I have been unsuccessful. <td class="border-top-0 border-left-0 ...

The blocking of the HttpPost ActionResult due to the deprecation of synchronous XMLHttpRequest

After adding jquery references to my project, I encountered an issue where the Post from a View is not triggering. The Post ActionResult used to save user-chosen settings, but now a break point inside the Post isn't being hit. Visual Studio does not s ...

How to perfectly align an element within a div using Bootstrap

Utilizing bootstrap here. Currently trying to center the h1 element within the div, but so far I have been unsuccessful. It consistently remains aligned to the left. Attempts have included using bootstrap's center-block helper class, as well as the fl ...

Placement of text is incorrect on certain react cards

I have an application that retrieves videos and generates a card for each video, displaying the video title, creator, link, download option, views, and upload date on each card. Fetching and displaying these elements works well, for the most part. However ...